Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting target runner in the [profile] settings #13737

Open
masriomarm opened this issue Apr 11, 2024 · 4 comments
Open

Support setting target runner in the [profile] settings #13737

masriomarm opened this issue Apr 11, 2024 · 4 comments
Labels
A-configuration Area: cargo config files and env vars A-profiles Area: profiles C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@masriomarm
Copy link

Problem

I need to have different runners based on release/debug build
for now [target.'cfg(debug_assertions)'.runner] is always active even if --print=cfg shows no debug_assertions. I'm aware of the docs mentioning to not try to match on debug_assertions

Steps

1 - having .cargo/config.toml, this is based cargo generate --git https://github.com/rust-embedded/cortex-m-quickstar following the embedded book. I was trying to have different runners

[target.thumbv7m-none-eabi]
# uncomment this to make `cargo run` execute programs on QEMU
# runner = "qemu-system-arm -S -gdb tcp::3333 -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
runner = """
qemu-system-arm
-gdb tcp::3333
-cpu cortex-m3
-machine lm3s6965evb
-nographic
-serial mon:stdio
-semihosting-config enable=on,target=native
-kernel
"""

[target.'cfg(debug_assertions)']
runner = """
qemu-system-arm
-S
-gdb tcp::3333
-cpu cortex-m3
-machine lm3s6965evb
-nographic
-serial mon:stdio
-semihosting-config enable=on,target=native
-kernel
"""

[target.'cfg(not(debug_assertions))']
runner = """
qemu-system-arm
-gdb tcp::3333
-cpu cortex-m3
-machine lm3s6965evb
-nographic
-serial mon:stdio
-semihosting-config enable=on,target=native
-kernel
"""

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# uncomment ONE of these three option to make `cargo run` start a GDB session
# which option to pick depends on your system
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
rustflags = [
  # Previously, the linker arguments --nmagic and -Tlink.x were set here.
  # They are now set by build.rs instead. The linker argument can still
  # only be set here, if a custom linker is needed.

  # By default, the LLD linker is used, which is shipped with the Rust
  # toolchain. If you run into problems with LLD, you can switch to the
  # GNU linker by uncommenting this line:
  # "-C", "linker=arm-none-eabi-ld",

  # If you need to link to pre-compiled C libraries provided by a C toolchain
  # use GCC as the linker by uncommenting the three lines below:
  # "-C", "linker=arm-none-eabi-gcc",
  # "-C", "link-arg=-Wl,-Tlink.x",
  # "-C", "link-arg=-nostartfiles",
  # "--print=cfg"
]

[build]
# Pick ONE of these default compilation targets
# target = "thumbv6m-none-eabi"        # Cortex-M0 and Cortex-M0+
target = "thumbv7m-none-eabi"        # Cortex-M3
# target = "thumbv7em-none-eabi"       # Cortex-M4 and Cortex-M7 (no FPU)
# target = "thumbv7em-none-eabihf"     # Cortex-M4F and Cortex-M7F (with FPU)
# target = "thumbv8m.base-none-eabi"   # Cortex-M23
# target = "thumbv8m.main-none-eabi"   # Cortex-M33 (no FPU)
# target = "thumbv8m.main-none-eabihf" # Cortex-M33 (with FPU)

2 - cargo run

Finished dev [unoptimized + debuginfo] target(s) in 0.06s
Running qemu-system-arm -gdb 'tcp::3333' -cpu cortex-m3 -machine lm3s6965evb -nographic -serial 'mon:stdio' -semihosting-config enable=on,target=native -kernel target/thumbv7m-none-eabi/debug/app

3 - cargo run --release

Finished release [optimized + debuginfo] target(s) in 0.05s
Running qemu-system-arm -gdb 'tcp::3333' -cpu cortex-m3 -machine lm3s6965evb -nographic -serial 'mon:stdio' -semihosting-config enable=on,target=native -kernel target/thumbv7m-none-eabi/release/app

4 - There's a missing -S which is the difference.

Possible Solution(s)

add runner to profile flags

Notes

No response

Version

cargo 1.77.1 (e52e36006 2024-03-26)
release: 1.77.1
commit-hash: e52e360061cacbbeac79f7f1215a7a90b6f08442
commit-date: 2024-03-26
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.5.0-DEV (sys:0.4.70+curl-8.5.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Fedora 39.0.0 [64-bit]
@masriomarm masriomarm added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Apr 11, 2024
@weihanglo
Copy link
Member

Looks like you have a set of different configurations that need to be switched between. Instead of adding more configs to [profile] table, I might recommend using cargo --config <path/to/other-config.toml> to switch to a specific separate config.toml. It may look like:

├── .cargo/
│  ├── config.toml # base shared config
│  ├── thumbv7em-none-eabi-release.toml
│  └── thumbv6m-none-eabi-release.toml
├── Cargo.toml
└── src/

@weihanglo
Copy link
Member

You could also configure [alias] to make it easier to switch with less typing.

@weihanglo weihanglo changed the title different runners based on debug_assertions Support setting target runner in the [profile] settings Apr 11, 2024
@weihanglo weihanglo added A-configuration Area: cargo config files and env vars A-profiles Area: profiles S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. and removed S-triage Status: This issue is waiting on initial triage. labels Apr 11, 2024
@soloturn
Copy link

why do you need a different runner at all, @masriomarm ? is it only because of the location of the binary? there is a 5 years old flag in unstable, --out-dir which may help: #6790

@masriomarm
Copy link
Author

@soloturn Thanks, but that won't help. I need different runner to to change qemu call arguments. one to halt target at beginning, and another just run to completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars A-profiles Area: profiles C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

3 participants