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 install does not respect LDFLAGS #3694

Closed
ChrisMacNaughton opened this issue Feb 13, 2017 · 9 comments
Closed

cargo install does not respect LDFLAGS #3694

ChrisMacNaughton opened this issue Feb 13, 2017 · 9 comments
Labels
A-configuration Area: cargo config files and env vars A-linkage Area: linker issues, dylib, cdylib, shared libraries, so C-bug Category: bug Command-install

Comments

@ChrisMacNaughton
Copy link

When the building system has LDFLAGS set, cargo / rustc should respect the system's LDFLAGS

@alexcrichton
Copy link
Member

Right now Cargo respects RUSTFLAGS but that's the only env var for passing flags down. What sort of LDFLAGS are you thinking of?

Note that the exact linker that the compiler invokes isn't guaranteed to not change over time, so there's not always a valid interpretation of LDFLAGS even if it exists.

@ChrisMacNaughton
Copy link
Author

Sorry for the delay, @sergiusens would be able to go into more depth on the specifics. The goal was to get a Rust project built into a Snap with Snapcraft but the built binary wasn't using the correct libraries

@sergiusens
Copy link

where are RUSTFLAGS documented? The linker flags we want to pass on are runpath/rpath related as well as the one that sets the linker loader the binary should use.

@alexcrichton
Copy link
Member

@sergiusens it's documented here

@ChrisMacNaughton
Copy link
Author

expanding a bit on this, some issues we're having with getting this working: https://gist.github.com/ChrisMacNaughton/a81233e05995013ebb9a0c333c157b76

@carols10cents carols10cents added A-configuration Area: cargo config files and env vars A-linkage Area: linker issues, dylib, cdylib, shared libraries, so C-bug Category: bug Command-install labels Sep 29, 2017
@stale
Copy link

stale bot commented Sep 20, 2018

As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it.

I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect?

The team would be especially grateful if such a comment included details such as:

  • Is this still relevant?
  • If so, what is blocking it?
  • Is it known what could be done to help move this forward?

Thank you for contributing!

(The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.)

If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!

@stale stale bot added the stale label Sep 20, 2018
@stale
Copy link

stale bot commented Oct 20, 2018

As I didn't see any updates in 30 days I'm going to close this. Please see the previous comment for more information!

@paugier
Copy link

paugier commented Dec 9, 2020

A simple question related to this issue.

I need to send the options -Wl,-rpath,/data0/opt/miniconda3/envs/env_hg_rust/lib -Wl,-rpath-link,/data0/opt/miniconda3/envs/env_hg_rust/lib to the linker.

Is it possible to do that with an environment variable (I don't control the cargo or rustc command)?

I can use RUSTFLAGS for things like -L/data0/opt/miniconda3/envs/env_hg_rust/lib but what about more advanced linker options?

@adam-azarchs
Copy link

I'm running into a related issue - we have --coverage (amongst other things) set in our CFLAGS. For some build script builds this is resulting in link errors such as undefined symbol: llvm_gcov_init because --coverage isn't also being passed to the link step as well. Leaving aside the question of whether or not CFLAGS should be having an effect on a build script build, there are several similar flags which will cause problems if used in CFLAGS (which usually applies because it's consumed by something like cc::Build in a build script) but not in LDFLAGS, for example -fopenmp or -flto. Particularly in a context where cargo is being used as one step in a larger build process, honoring CFLAGS but not LDFLAGS can cause all kinds of problems.

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-linkage Area: linker issues, dylib, cdylib, shared libraries, so C-bug Category: bug Command-install
Projects
None yet
Development

No branches or pull requests

6 participants