Skip to content
New issue

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

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

Already on GitHub? # to your account

problems with -C link-args that have arguments with spaces #45

Open
japaric opened this issue Sep 23, 2016 · 3 comments
Open

problems with -C link-args that have arguments with spaces #45

japaric opened this issue Sep 23, 2016 · 3 comments

Comments

@japaric
Copy link
Owner

japaric commented Sep 23, 2016

If you use something like this:

[ build]
rustflags = [
  "-C",
  "link-args=-Tlayout.ld -nostartfiles"
]

in your .cargo/config, the executable with fail to link because three arguments will be passed to rustc: -C, -link-args=-Tlayout.ld and -nostartfiles. This a problem with Xargo because it uses RUSTFLAGS to pass these (and --sysroot) as a string to Cargo and then Cargo parses RUSTFLAGS by splitting it at whitespaces.

There is no real solution for this other than to use -C link-arg (rust-lang/rust#36574) multiple times instead of -C link-args.

Once that PR lands in rust-lang/rust, let's have Cargo print a warning about this problem and also suggest using -C link-arg instead of -C link-args.

@sanmai-NL
Copy link

@japaric: Small reminder in response to your last paragraph: the PR has landed.

@flukejones
Copy link

flukejones commented Apr 11, 2018

A small note for anyone who stumbles across this via google.

If you need multiple args, the first arg must not have -s, while the rest do. For example:

-- -C link-arg='EXTRA_EXPORTED_RUNTIME_METHODS=["ccall","cwrap"]' -C link-arg='-s' -C link-arg='ASSERTIONS=1' -C link-arg='-s' -C link-arg='ALLOW_MEMORY_GROWTH=1'

Nils-TUD pushed a commit to Nils-TUD/xargo that referenced this issue Sep 17, 2019
46: Fix warning about implicit trait objects r=phil-opp a=phil-opp

Fixes japaric#45 

Co-authored-by: Philipp Oppermann <dev@phil-opp.com>
@timboudreau
Copy link

As one of those people who stumbled across @flukejones comment, which was very helpful: I'm not sure what all of the -s's were supposed to do on Linux, but on Mac OS's ld they will not be accepted - but simply a sequence of -C link-arg=blah -C link-arg=blee. It gets somewhat clunky - e.g. -C link-arg=-macos_version_min -C link-arg=13.0 but works.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants