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

Cargo -Z extra-link-arg= issues a warning #10170

Closed
berkus opened this issue Dec 5, 2021 · 3 comments
Closed

Cargo -Z extra-link-arg= issues a warning #10170

berkus opened this issue Dec 5, 2021 · 3 comments
Labels
C-bug Category: bug

Comments

@berkus
Copy link

berkus commented Dec 5, 2021

Problem

Related to #9426

I need to pass extra-link-args on command line from the makefile, but now cargo issues a warning

warning: flag `-Z extra-link-arg` has been stabilized in the 1.56 release, and is no longer necessary
  Additional linker arguments are now supported without passing this flag.

Does it mean I can now pass linker flags directly on the command line like --script=link.ld?

Steps

Parent Makefile.toml:

[env]
# This is passed to cargo if LINK_SCRIPT is set in sub-makefile
LINK_ARG = "-Z extra-link-arg=--script=${LINK_SCRIPT}"

Makefile.toml

[env]
# This script is specific per-project-binary.
# I do not use, neither need to use build.rs here.
LINK_SCRIPT = "bin/microboot/src/link.ld"

[tasks.build]
env = { "TARGET_FEATURES" = "" }
args = ["build", "--target=${TARGET_JSON}", "@@split(STD, )", "@@split(LINK_ARG, )", "--release", "--features=${TARGET_FEATURES}"]

Which gives a command line like

[cargo-make][1] INFO - Execute Command: "cargo" "build" "--target=/Metta/vesper/targets/aarch64-vesper-metta.json" "-Z" "build-std=compiler_builtins,core,alloc" "-Z" "build-std-features=compiler-builtins-mem" "-Z" "extra-link-arg=--script=linker/aarch64.ld" "--release" "--features="

Possible Solution(s)

  1. not issue the warning if -Z extra-link-arg will continue to work
  2. provide an alternative way to specify link-arg on command line if the above flag will be removed.

Notes

No response

Version

❯ cargo version --verbose
cargo 1.58.0-nightly (94ca096af 2021-10-29)
release: 1.58.0
commit-hash: 94ca096afbf25f670e76e07dca754fcfe27134be
commit-date: 2021-10-29
host: aarch64-apple-darwin
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.77.0 (sys:0.4.49+curl-7.79.1 system ssl:(SecureTransport) LibreSSL/2.8.3)
os: Mac OS 12.0.1 [64-bit]
@berkus berkus added the C-bug Category: bug label Dec 5, 2021
@ehuss
Copy link
Contributor

ehuss commented Dec 5, 2021

Maybe I'm a bit confused by the question, but -Zextra-link-arg never took arguments itself. It just enabled adding linker arguments via build scripts. There is more documentation on how that works at https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script (the cargo:rustc-link-arg instructions). Build scripts may now output those instructions without -Zextra-link-arg.

@berkus
Copy link
Author

berkus commented Dec 5, 2021

Ahh, that's fine then, thanks!

Let's pivot a bit: What about providing a linker script path directly from cargo invocation, how is it possible if at all?

@berkus
Copy link
Author

berkus commented Dec 5, 2021

On the other hand, build.rs files seem to work fine for this task.

@berkus berkus closed this as completed Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants