Skip to content

librustc_llvm: call llvm-config with correct linking mode #36854

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

Closed
leahneukirchen opened this issue Sep 30, 2016 · 5 comments
Closed

librustc_llvm: call llvm-config with correct linking mode #36854

leahneukirchen opened this issue Sep 30, 2016 · 5 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@leahneukirchen
Copy link

In 1.12, src/librustc_llvm/build.rs figures out which libraries it needs for external LLVM using llvm-config --libs which breaks if you have LLVM with -DLLVM_BUILD_LLVM_DYLIB=ON and -DLLVM_LINK_LLVM_DYLIB=OFF (which is needed for clang 3.9 these days), since then there is a dynamic libLLVM3.9.so and lots of libLLVM*.a, but the code sees the libLLVM and decides it has to link statically, which fails.

The code should decide whether to link static or dynamic first, and then call llvm-config --libs --link-shared resp --link-static, to get the correct library name.

@alexcrichton alexcrichton added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Sep 30, 2016
@alexcrichton
Copy link
Member

Thanks for the report! Sounds like it should be a relatively easy bug to tackle as well!

@leahneukirchen
Copy link
Author

In Void, we work around it by just adding --link-static, I guess for a general fix you need some policy how to link it.

https://github.com/voidlinux/void-packages/blob/79600b7b416c46191aefa079cd544c9a3b6779d7/srcpkgs/rust/patches/link-llvm-static.patch

@alexcrichton
Copy link
Member

Oh we basically always want to link LLVM statically, so we can probably just always pass it.

pweyck added a commit to pweyck/rust that referenced this issue Nov 6, 2016
Run llvm-config with "--link-static" if available, to force static linking of LLVM.
This option was added in LLVM 3.8.

Fixes rust-lang#36854
See also: rust-lang#36996
bors added a commit that referenced this issue Nov 6, 2016
Force static linking of LLVM

Run `llvm-config` with `--link-static` if available, to force static linking of LLVM.
This option was added in LLVM 3.8.

This is my first pull request, any feedback is welcome!

Fixes #36854
See also: #36996
@cuviper
Copy link
Member

cuviper commented Nov 9, 2016

Oh we basically always want to link LLVM statically, so we can probably just always pass it.

We emphatically don't want that in distro builds. Would you accept a patch to make this conditional?

@alexcrichton
Copy link
Member

@cuviper certainly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

3 participants