Skip to content

rustbuild: allow dynamically linking LLVM #37822

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

Merged
merged 2 commits into from
Nov 19, 2016

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Nov 17, 2016

The makefiles and mklldeps.py called llvm-config --shared-mode to
find out if LLVM defaulted to shared or static libraries, and just went
with that. But under rustbuild, librustc_llvm/build.rs was assuming
that LLVM should be static, and even forcing --link-static for 3.9+.

Now that build script also uses --shared-mode to learn the default,
which should work better for pre-3.9 configured for dynamic linking, as
it wasn't possible back then to choose differently via llvm-config.

Further, the configure script now has a new --enable-llvm-link-shared
option, which allows one to manually override --link-shared on 3.9+
instead of forcing static.

Update: There are now four static/shared scenarios that can happen
for the supported LLVM versions:

  • 3.9+: By default use llvm-config --link-static
  • 3.9+ and --enable-llvm-link-shared: Use --link-shared instead.
  • 3.8: Use llvm-config --shared-mode and go with its answer.
  • 3.7: Just assume static, maintaining the status quo.

The makefiles and `mklldeps.py` called `llvm-config --shared-mode` to
find out if LLVM defaulted to shared or static libraries, and just went
with that.  But under rustbuild, `librustc_llvm/build.rs` was assuming
that LLVM should be static, and even forcing `--link-static` for 3.9+.

Now that build script also uses `--shared-mode` to learn the default,
which should work better for pre-3.9 configured for dynamic linking, as
it wasn't possible back then to choose differently via `llvm-config`.

Further, the configure script now has a new `--enable-llvm-link-shared`
option, which allows one to manually override `--link-shared` on 3.9+
instead of forcing static.
@rust-highfive
Copy link
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@cuviper
Copy link
Member Author

cuviper commented Nov 17, 2016

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned eddyb Nov 17, 2016
@alexcrichton
Copy link
Member

Looks good to me! It appears though that --shared-mode wasn't a flag with LLVM 3.7? (looking at Travis)

@cuviper
Copy link
Member Author

cuviper commented Nov 17, 2016

Ah, I hadn't noticed that mklldeps.py lets llvm-config --shared-mode fail, falling back to static. I'll try to either match that behavior, or call it conditionally on 3.8 only (since on 3.9+ we'll always force a --link-*).

@alexcrichton
Copy link
Member

Ah ok, either's fine by me!

There are now four static/shared scenarios that can happen for the
supported LLVM versions:

- 3.9+: By default use `llvm-config --link-static`
- 3.9+ and `--enable-llvm-link-shared`: Use `--link-shared` instead.
- 3.8: Use `llvm-config --shared-mode` and go with its answer.
- 3.7: Just assume static, maintaining the status quo.
@cuviper
Copy link
Member Author

cuviper commented Nov 18, 2016

OK, that push will hopefully help 3.7, and I updated the PR summary with the four linking scenarios.

@cuviper
Copy link
Member Author

cuviper commented Nov 18, 2016

Hmm, those latest travis jobs don't look like they actually tried anything...

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Collaborator

bors commented Nov 18, 2016

📌 Commit f324037 has been approved by alexcrichton

@bors
Copy link
Collaborator

bors commented Nov 19, 2016

⌛ Testing commit f324037 with merge b1da18f...

bors added a commit that referenced this pull request Nov 19, 2016
rustbuild: allow dynamically linking LLVM

The makefiles and `mklldeps.py` called `llvm-config --shared-mode` to
find out if LLVM defaulted to shared or static libraries, and just went
with that.  But under rustbuild, `librustc_llvm/build.rs` was assuming
that LLVM should be static, and even forcing `--link-static` for 3.9+.

Now that build script also uses `--shared-mode` to learn the default,
which should work better for pre-3.9 configured for dynamic linking, as
it wasn't possible back then to choose differently via `llvm-config`.

Further, the configure script now has a new `--enable-llvm-link-shared`
option, which allows one to manually override `--link-shared` on 3.9+
instead of forcing static.

Update: There are now four static/shared scenarios that can happen
for the supported LLVM versions:

- 3.9+: By default use `llvm-config --link-static`
- 3.9+ and `--enable-llvm-link-shared`: Use `--link-shared` instead.
- 3.8: Use `llvm-config --shared-mode` and go with its answer.
- 3.7: Just assume static, maintaining the status quo.
@bors bors merged commit f324037 into rust-lang:master Nov 19, 2016
@cuviper cuviper deleted the llvm-link-shared branch September 26, 2017 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants