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

rustdoc-tool does not build with --enable-llvm-link-shared #46995

Open
whitequark opened this issue Dec 25, 2017 · 10 comments
Open

rustdoc-tool does not build with --enable-llvm-link-shared #46995

whitequark opened this issue Dec 25, 2017 · 10 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@whitequark
Copy link
Member

Seems to be missing a -L flag:

  = note: /usr/bin/ld: cannot find -lLLVMX86Disassembler
          /usr/bin/ld: cannot find -lLLVMX86AsmParser
          /usr/bin/ld: cannot find -lLLVMX86CodeGen
...

Any ideas on fixing this?

@whitequark
Copy link
Member Author

whitequark commented Dec 25, 2017

Horrible hacky workaround:

diff --git a/src/Cargo.lock b/src/Cargo.lock
index bc1fdf40b0..e5024f0427 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -1858,6 +1858,7 @@ dependencies = [
 name = "rustdoc-tool"
 version = "0.0.0"
 dependencies = [
+ "rustc_llvm 0.0.0",
  "rustdoc 0.0.0",
 ]
 
diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index a05e58e6a2..e169e8bf12 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -313,6 +313,10 @@ impl Step for Rustdoc {
         cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
              .env("RUSTC_DEBUGINFO_LINES", builder.config.rust_debuginfo_lines.to_string());
 
+        if build.config.llvm_link_shared {
+            cargo.env("LLVM_LINK_SHARED", "1");
+        }
+
         build.run(&mut cargo);
         // Cargo adds a number of paths to the dylib search path on windows, which results in
         // the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
diff --git a/src/tools/rustdoc/Cargo.toml b/src/tools/rustdoc/Cargo.toml
index 344f617ef9..110f01b1bc 100644
--- a/src/tools/rustdoc/Cargo.toml
+++ b/src/tools/rustdoc/Cargo.toml
@@ -12,3 +12,4 @@ path = "main.rs"
 
 [dependencies]
 rustdoc = { path = "../../librustdoc" }
+rustc_llvm = { path = "../../librustc_llvm" }
diff --git a/src/tools/rustdoc/main.rs b/src/tools/rustdoc/main.rs
index 9c37e249ba..fd37235722 100644
--- a/src/tools/rustdoc/main.rs
+++ b/src/tools/rustdoc/main.rs
@@ -9,5 +9,6 @@
 // except according to those terms.
 
 extern crate rustdoc;
+extern crate rustc_llvm;
 
 fn main() { rustdoc::main() }

@eddyb
Copy link
Member

eddyb commented Dec 25, 2017

Huh, it should be getting it through rustdoc -> rustc_driver -> rustc_trans -> rustc_llvm.

cc @alexcrichton

whitequark added a commit to m-labs/rust that referenced this issue Dec 26, 2017
@alexcrichton
Copy link
Member

The link paths aren't propagated because rustdoc is in a separate Cargo project, we'll need to manually insert necessary link paths via a build script in rustdoc.

@eddyb
Copy link
Member

eddyb commented Dec 27, 2017

@alexcrichton Ah, so none of the information is in the Rust rlib / dylib metadata?

@alexcrichton
Copy link
Member

Correct yeah, link paths aren't stored in metadata, only libraries linked.

@whitequark
Copy link
Member Author

Related: LLVM_CONFIG should be properly set for rustdoc build, too, or the wrong llvm-config (from PATH) would be used:

Building rustdoc for stage2 (x86_64-unknown-linux-gnu)
   Compiling rustc_llvm v0.0.0 (file:///home/maglab/artiq-dev/artiq_3.1/rust/src/librustc_llvm)
error: failed to run custom build command for `rustc_llvm v0.0.0 (file:///home/maglab/artiq-dev/artiq_3.1/rust/src/librustc_llvm)`
process didn't exit successfully: `/home/maglab/artiq-dev/artiq_3.1/rust/build/build/x86_64-unknown-linux-gnu/stage2-tools/release/build/rustc_llvm-5f6e96f94cb8b094/build-script-build` (exit code: 1)
--- stdout
cargo:rerun-if-changed=llvm-config
cargo:rerun-if-env-changed=LLVM_CONFIG


**failed to execute command: "llvm-config" "--version"**
error: No such file or directory (os error 2)

This is not currently handled by my workaround above, though.

whitequark added a commit to m-labs/rust that referenced this issue Jan 12, 2018
@whitequark
Copy link
Member Author

The following takes care of it:

diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index e95a5e0743..5cea0ad1fc 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -313,6 +313,8 @@ impl Step for Rustdoc {
         cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
              .env("RUSTC_DEBUGINFO_LINES", builder.config.rust_debuginfo_lines.to_string());

+        cargo.env("LLVM_CONFIG", builder.llvm_config(target));
+
         build.run(&mut cargo);
         // Cargo adds a number of paths to the dylib search path on windows, which results in
         // the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"

@o01eg
Copy link
Contributor

o01eg commented Jan 14, 2018

It also affects compilation with system LLVM.

@pietroalbini pietroalbini added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. labels Jan 30, 2018
@whitequark
Copy link
Member Author

Any guidance on how to properly fix this upstream?

whitequark added a commit to m-labs/rust that referenced this issue Apr 6, 2018
@steveklabnik
Copy link
Member

Triage: not aware of any fixes here

@Enselic Enselic added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants