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

Re-do the FreeBSD cross-builds to use Clang and libc++. Fixes #44433. #45077

Closed
wants to merge 1 commit into from

Conversation

jld
Copy link
Contributor

@jld jld commented Oct 7, 2017

The main goal here is to use FreeBSD's normal libc++, instead of
statically linking the libstdc++ packaged with GCC, because that
libstdc++ has bugs that cause rustc to deadlock inside LLVM.

But the easiest way to use libc++ is to switch the build from GCC to
Clang, and the Clang package in the Ubuntu image already knows how to
cross-compile (given a sysroot and preferably cross-binutils), so the
toolchain script now uses that instead of building a custom compiler.

This also de-duplicates the build-toolchain.sh script.

…ng#44433.

The main goal here is to use FreeBSD's normal libc++, instead of
statically linking the libstdc++ packaged with GCC, because that
libstdc++ has bugs that cause rustc to deadlock inside LLVM.

But the easiest way to use libc++ is to switch the build from GCC to
Clang, and the Clang package in the Ubuntu image already knows how to
cross-compile (given a sysroot and preferably cross-binutils), so the
toolchain script now uses that instead of building a custom compiler.

This also de-duplicates the `build-toolchain.sh` script.
@rust-highfive
Copy link
Collaborator

r? @aturon

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

@jld
Copy link
Contributor Author

jld commented Oct 7, 2017

cc @alexcrichton @dumbbell

I've tested this locally, but only after removing --enable-extended to avoid #43982 (which seems to affect my local setup but not the Rust Project CI for reasons passing understanding).

I could try splitting out the toolchain script deduplication so the history is easier to follow, although I wound up rewriting most of it so I'm not sure how much that would help.

@alexcrichton
Copy link
Member

@bors: r+

Nah looks great to me, thanks @jld!

@bors
Copy link
Contributor

bors commented Oct 7, 2017

📌 Commit 270c517 has been approved by alexcrichton

@carols10cents carols10cents added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 9, 2017
@bors
Copy link
Contributor

bors commented Oct 11, 2017

⌛ Testing commit 270c517 with merge 1079bd03418e3011e683fba6fe46fdee4851d17d...

@bors
Copy link
Contributor

bors commented Oct 11, 2017

💔 Test failed - status-travis

@kennytm
Copy link
Member

kennytm commented Oct 11, 2017

@bors retry

kennytm added a commit to kennytm/rust that referenced this pull request Oct 11, 2017
…chton

Re-do the FreeBSD cross-builds to use Clang and libc++.  Fixes rust-lang#44433.

The main goal here is to use FreeBSD's normal libc++, instead of
statically linking the libstdc++ packaged with GCC, because that
libstdc++ has bugs that cause rustc to deadlock inside LLVM.

But the easiest way to use libc++ is to switch the build from GCC to
Clang, and the Clang package in the Ubuntu image already knows how to
cross-compile (given a sysroot and preferably cross-binutils), so the
toolchain script now uses that instead of building a custom compiler.

This also de-duplicates the `build-toolchain.sh` script.
@kennytm
Copy link
Member

kennytm commented Oct 12, 2017

The rollup #45207 failed to build rustc_llvm on dist-i686-freebsd (Travis log: https://travis-ci.org/rust-lang/rust/jobs/286745957), and I think this PR is the cause.

[01:12:21]    Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> i686-unknown-freebsd)
...
[01:12:36]    Compiling rustc_llvm v0.0.0 (file:///checkout/src/librustc_llvm)
[01:12:36]    Compiling rls-data v0.10.0
[01:12:37]    Compiling syntax_pos v0.0.0 (file:///checkout/src/libsyntax_pos)
[01:12:43]    Compiling rustc_errors v0.0.0 (file:///checkout/src/librustc_errors)
[01:12:47] error: empty search path given via `-L`
[01:12:47]
[01:12:47] error: Could not compile `rustc_llvm`.
[01:12:47]
[01:12:47] Caused by:
[01:12:47]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_llvm /checkout/src/librustc_llvm/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=f46cd6013ef0998c -C extra-filename=-f46cd6013ef0998c --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/i686-unknown-freebsd/release/deps --target i686-unknown-freebsd -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/i686-unknown-freebsd/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/release/deps --extern bitflags=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/i686-unknown-freebsd/release/deps/libbitflags-ba18404efed9b8b2.rlib --extern rustc_cratesio_shim=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/i686-unknown-freebsd/release/deps/librustc_cratesio_shim-e1d5ea64cf9e4a2b.so -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/i686-unknown-freebsd/release/build/rustc_llvm-6f82be967e43dabf/out -L native=/checkout/obj/build/i686-unknown-freebsd/llvm/lib -L native= --cfg llvm_component="aarch64" --cfg llvm_component="arm" --cfg llvm_component="asmparser" --cfg llvm_component="bitreader" --cfg llvm_component="bitwriter" --cfg llvm_component="hexagon" --cfg llvm_component="instrumentation" --cfg llvm_component="interpreter" --cfg llvm_component="ipo" --cfg llvm_component="jsbackend" --cfg llvm_component="linker" --cfg llvm_component="lto" --cfg llvm_component="mcjit" --cfg llvm_component="mips" --cfg llvm_component="msp430" --cfg llvm_component="nvptx" --cfg llvm_component="powerpc" --cfg llvm_component="sparc" --cfg llvm_component="systemz" --cfg llvm_component="x86" -l static=rustllvm -l static=LLVMX86Disassembler -l static=LLVMX86AsmParser -l static=LLVMX86CodeGen -l static=LLVMX86Desc -l static=LLVMX86Info -l static=LLVMX86AsmPrinter -l static=LLVMX86Utils -l static=LLVMSystemZDisassembler -l static=LLVMSystemZCodeGen -l static=LLVMSystemZAsmParser -l static=LLVMSystemZDesc -l static=LLVMSystemZInfo -l static=LLVMSystemZAsmPrinter -l static=LLVMSparcDisassembler -l static=LLVMSparcCodeGen -l static=LLVMSparcAsmParser -l static=LLVMSparcDesc -l static=LLVMSparcInfo -l static=LLVMSparcAsmPrinter -l static=LLVMPowerPCDisassembler -l static=LLVMPowerPCCodeGen -l static=LLVMPowerPCAsmParser -l static=LLVMPowerPCDesc -l static=LLVMPowerPCInfo -l static=LLVMPowerPCAsmPrinter -l static=LLVMNVPTXCodeGen -l static=LLVMNVPTXDesc -l static=LLVMNVPTXInfo -l static=LLVMNVPTXAsmPrinter -l static=LLVMMSP430CodeGen -l static=LLVMMSP430Desc -l static=LLVMMSP430Info -l static=LLVMMSP430AsmPrinter -l static=LLVMMipsDisassembler -l static=LLVMMipsCodeGen -l static=LLVMMipsAsmParser -l static=LLVMMipsDesc -l static=LLVMMipsInfo -l static=LLVMMipsAsmPrinter -l static=LLVMMCJIT -l static=LLVMLTO -l static=LLVMPasses -l static=LLVMObjCARCOpts -l static=LLVMJSBackendCodeGen -l static=LLVMPNaClTransforms -l static=LLVMJSBackendDesc -l static=LLVMJSBackendInfo -l static=LLVMipo -l static=LLVMVectorize -l static=LLVMLinker -l static=LLVMIRReader -l static=LLVMInterpreter -l static=LLVMExecutionEngine -l static=LLVMRuntimeDyld -l static=LLVMInstrumentation -l static=LLVMHexagonDisassembler -l static=LLVMHexagonCodeGen -l static=LLVMHexagonAsmParser -l static=LLVMHexagonDesc -l static=LLVMHexagonInfo -l static=LLVMAsmParser -l static=LLVMARMDisassembler -l static=LLVMARMCodeGen -l static=LLVMARMAsmParser -l static=LLVMARMDesc -l static=LLVMARMInfo -l static=LLVMARMAsmPrinter -l static=LLVMAArch64Disassembler -l static=LLVMMCDisassembler -l static=LLVMAArch64CodeGen -l static=LLVMGlobalISel -l static=LLVMSelectionDAG -l static=LLVMAsmPrinter -l static=LLVMDebugInfoCodeView -l static=LLVMDebugInfoMSF -l static=LLVMCodeGen -l static=LLVMTarget -l static=LLVMScalarOpts -l static=LLVMInstCombine -l static=LLVMTransformUtils -l static=LLVMBitWriter -l static=LLVMAnalysis -l static=LLVMObject -l static=LLVMBitReader -l static=LLVMProfileData -l static=LLVMCore -l static=LLVMAArch64AsmParser -l static=LLVMMCParser -l static=LLVMAArch64Desc -l static=LLVMAArch64Info -l static=LLVMAArch64AsmPrinter -l static=LLVMMC -l static=LLVMAArch64Utils -l static=LLVMSupport -l static=LLVMDemangle -l static=c++` (exit code: 101)
[01:12:47] warning: build failed, waiting for other jobs to finish...
[01:12:56] error: build failed
[01:12:56] thread 'main' panicked at 'command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "i686-unknown-freebsd" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc llvm" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[01:12:56] expected success, got: exit code: 101', /checkout/src/bootstrap/compile.rs:883:8
[01:12:56] note: Run with `RUST_BACKTRACE=1` for a backtrace.

Problematic command line:

… -L native=/checkout/obj/build/i686-unknown-freebsd/llvm/lib -L native= --cfg llvm_component="aarch64" …
                                                              ^~~~~~~~~~

@bors
Copy link
Contributor

bors commented Oct 13, 2017

⌛ Testing commit 270c517 with merge 3878b454f953b7bf4c07b2a075147b8734baad16...

@bors
Copy link
Contributor

bors commented Oct 13, 2017

💔 Test failed - status-travis

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 14, 2017
@alexcrichton
Copy link
Member

triage ping for @jld, looks like there may be some test failures!

@kennytm
Copy link
Member

kennytm commented Oct 23, 2017

@bors r-

@kennytm
Copy link
Member

kennytm commented Oct 27, 2017

Hi @jld, do you have time to look into this issue again and see why the CI cannot compile rustc_llvm? Thanks!

@shepmaster
Copy link
Member

Thank you for your hard work in this PR, @jld! However, since we haven't heard from you in over 14 days, I'm going to go ahead and close this to keep things tidy. Please feel free to re-open it when you have some time to address the current issues with it!

@shepmaster shepmaster closed this Nov 3, 2017
@ScottAbbey
Copy link
Contributor

@jld:

It seems this is still very close to working. By eliminating the blank -L native=, I was able to successfully run the src/ci/docker/run.sh for FreeBSD. I also confirmed that ./x.py build still works with the current change.

The empty -L native= is from line 270 of src/librustc_llvm/build.rs, the final line here:

    let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP");
    // .....
    if !target.contains("msvc") {
        if let Some(s) = llvm_static_stdcpp {
            assert!(!cxxflags.contains("stdlib=libc++"));
            let path = PathBuf::from(s);
            println!("cargo:rustc-link-search=native={}",
                     path.parent().unwrap().display());

path comes from the environment variable LLVM_STATIC_STDCPP; I was able to determine that at least in my attempt to run this today, this contained the value libstdc++.a. Taking path.parent() results in just an empty string, hence the -L native=.

In order to pass the build today, I just made that particular println! conditional on path.parent() not being empty. I only tested the build for FreeBSD so I don't know how this approach would affect other targets. Perhaps the other targets are also getting blanks here or perhaps something else, I don't know enough to guess.

Looks like @alexcrichton wrote this section, maybe he can help point us to more information about LLVM_STATIC_STDCPP. Since the whole point here is to use libc++ instead of libstdc++, we'll probably need to modify something, somewhere....or ignore this line only in the case of FreeBSD, or something.

I've tested this locally, but only after removing --enable-extended to avoid #43982 (which seems to affect my local setup but not the Rust Project CI for reasons passing understanding).

The reason it worked for you but not on CI can be found in 1080a69, I was tipped off by @alexcrichton here #46781 (comment) -- when the CI is run, DEPLOY=1 is set in the environment, resulting in this option being turned on.

(That flag probably also has something to do with your comment, here #43982 (comment), about needing to remove --enable-extended -- I was able to get past that spot by only setting DEPLOY=1, as hinted by Alex, and not removing--enable-extended.)

If you aren't interested in working on this anymore, I might try to pick it up and add on to your original commit with whatever other changes are needed to get this working.

@ScottAbbey
Copy link
Contributor

ScottAbbey commented Dec 21, 2017

Hiding the previous version of the comment, me trying to find my way around:


> Looks like @alexcrichton wrote this section, maybe he can help point us to more information about LLVM_STATIC_STDCPP. Since the whole point here is to use libc++ instead of libstdc++, we'll probably need to modify something, somewhere....or ignore this line only in the case of FreeBSD, or something.

Looks like the libstdc++.a value comes from here:

// Building with a static libstdc++ is only supported on linux right now,
// not for MSVC or macOS
if build.config.llvm_static_stdcpp &&
!target.contains("windows") &&
!target.contains("apple") {
cargo.env("LLVM_STATIC_STDCPP",
compiler_file(build.cxx(target).unwrap(), "libstdc++.a"));
}

It's not quite clear whether the comment above considers FreeBSD to be "linux" or "not linux". I don't know enough to know why it would or wouldn't be supported.

The blank -L native= is happening during Stage 1 of the 2nd run through (Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> i686-unknown-freebsd)). During the same part of the 1st run (Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)), the value inserted from this code is:

-L native=/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0

So apparently during x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu, it's giving a correct value for the location of libstdc++.a: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/libstdc++.a, but during x86_64-unknown-linux-gnu -> i686-unknown-freebsd, this is resulting in the full path being just: libstdc++.a.

If we wanted a static stdcpp on FreeBSD with clang, (Do we? I don't know.), it would be named libc++.a instead of libstdc++.a, and it wouldn't be in a gcc directory.

I'm in over my head at this point unless the proper solution is to just add !target.contains("freebsd") to this section.


Edit: Now I have a better idea what's going on.

Okay, so I got far enough in debugging to find that:

fn compiler_file(compiler: &Path, file: &str) -> PathBuf {
let out = output(Command::new(compiler)
.arg(format!("-print-file-name={}", file)));
PathBuf::from(out.trim())
}

Is going to return something like:

/usr/lib/gcc/x86_64-linux-gnu/4.8/libstdc++.a

When using the GNU compilers.

But when target is i686-unknown-freebsd here, it's getting arguments like a path of i686-unknown-freebsd10-clang++ and a file of libstdc++.a. Since the file isn't found, it is just giving back libstdc++.a.

So we want to send it to look for libc++.a when using FreeBSD! I think? This seems like the right thing to do.

@ScottAbbey
Copy link
Contributor

ScottAbbey commented Dec 21, 2017

I think most of this path was wrong, hiding.

I attempted the following change here:

// Building with a static libstdc++ is only supported on linux right now,
// not for MSVC or macOS
if build.config.llvm_static_stdcpp &&
!target.contains("windows") &&
!target.contains("apple") {
cargo.env("LLVM_STATIC_STDCPP",
compiler_file(build.cxx(target).unwrap(), "libstdc++.a"));
}

     if build.config.llvm_static_stdcpp &&
        !target.contains("windows") &&
-       !target.contains("apple") {
+       !target.contains("apple") &&
+       !target.contains("freebsd") {
         cargo.env("LLVM_STATIC_STDCPP",
                   compiler_file(build.cxx(target).unwrap(), "libstdc++.a"));
-    }
+    } else if target.contains("freebsd") {
+        cargo.env("LLVM_STATIC_STDCPP",
+                  compiler_file(build.cxx(target).unwrap(), "libc++.a"));
+    }  

This time compiler_file() found /usr/local/x86_64-unknown-freebsd10/usr/lib/libc++.a (yay!) but:

 = note: /usr/local/x86_64-unknown-freebsd10/bin/ld: /usr/local/x86_64-unknown-freebsd10/usr/lib/libc++.a(valarray.o): relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
          /usr/local/x86_64-unknown-freebsd10/usr/lib/libc++.a(valarray.o): error adding symbols: Bad value
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Full output of error:

error: linking with `x86_64-unknown-freebsd10-clang` failed: exit code: 1
  |
  = note: "x86_64-unknown-freebsd10-clang" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-freebsd/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm0-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm1-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm10-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm11-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm12-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm13-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm14-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm15-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm2-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm3-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm4-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm5-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm6-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm7-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm8-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.rustc_llvm9-94cb567a73dadf8e83c2e0aaae7f3e50.rs.rcgu.o" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/librustc_llvm-2897cb3899437b86.so" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.crate.metadata.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/rustc_llvm-2897cb3899437b86.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/build/rustc_llvm-35af56c708b495ad/out" "-L" "/checkout/obj/build/x86_64-unknown-freebsd/llvm/lib" "-L" "/usr/local/x86_64-unknown-freebsd10/usr/lib" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-freebsd/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "rustllvm" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMX86Disassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMX86AsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMX86CodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMX86Desc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMX86Info" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMX86AsmPrinter" "-Wl
,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMX86Utils" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMWebAssemblyDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMWebAssemblyCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMWebAssemblyDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMWebAssemblyInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMWebAssemblyAsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSystemZDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSystemZCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSystemZAsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSystemZDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSystemZInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSystemZAsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSparcDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSparcCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSparcAsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSparcDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSparcInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSparcAsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPowerPCDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPowerPCCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPowerPCAsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPowerPCDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPowerPCInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPowerPCAsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMNVPTXCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMNVPTXDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMNVPTXInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMNVPTXAsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMSP430CodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMSP430Desc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMSP430Info" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMSP430AsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMipsDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMipsCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMipsAsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMipsDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMipsInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMipsAsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMCJIT" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMLTO" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPasses" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMObjCARCOpts" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMJSBackendCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMPNaClTransforms" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMJSBackendDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMJSBackendInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMipo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMVectorize" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMLinker" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMIRReader" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMInterpreter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMExecutionEngine" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMRuntimeDyld" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMInstrumentation" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMHexagonDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMHexagonCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMHexagonAsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMHexagonDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMHexagonInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMARMDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMARMCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMARMAsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMARMDesc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMARMInfo" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMARMAsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAArch64Disassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMCDisassembler" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAArch64CodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMGlobalISel" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSelectionDAG" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAsm
Printer" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMDebugInfoCodeView" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMDebugInfoMSF" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMCodeGen" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMTarget" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMScalarOpts" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMInstCombine" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMTransformUtils" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMBitWriter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAnalysis" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMObject" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMBitReader" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMProfileData" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMCore" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAArch64AsmParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMCParser" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAArch64Desc" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAArch64Info" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAArch64AsmPrinter" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMMC" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMAArch64Utils" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMSupport" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "LLVMDemangle" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-l" "c++" "-Wl,--no-whole-archive" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps" "-Wl,-Bdynamic" "-l" "rustc_cratesio_shim-641fd405ca330c12" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-freebsd/lib" "-l" "std-8acc138467f0221e" "-Wl,-Bstatic" "/tmp/rustc.5yWPeG5ieYcy/libcompiler_builtins-d9d9beeac165f19e.rlib" "-Wl,-Bdynamic" "-l" "execinfo" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-shared" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /usr/local/x86_64-unknown-freebsd10/bin/ld: /usr/local/x86_64-unknown-freebsd10/usr/lib/libc++.a(valarray.o): relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
          /usr/local/x86_64-unknown-freebsd10/usr/lib/libc++.a(valarray.o): error adding symbols: Bad value
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: aborting due to previous error

error: Could not compile `rustc_llvm`.

Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_llvm /checkout/src/librustc_llvm/lib.rs --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=2897cb3899437b86 -C extra-filename=-2897cb3899437b86 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps --target x86_64-unknown-freebsd -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/release/deps --extern rustc_cratesio_shim=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/librustc_cratesio_shim-641fd405ca330c12.so --extern bitflags=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/deps/libbitflags-a44fa4314bb7a41e.rlib -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-freebsd/release/build/rustc_llvm-35af56c708b495ad/out -L native=/checkout/obj/build/x86_64-unknown-freebsd/llvm/lib -L native=/usr/local/x86_64-unknown-freebsd10/usr/lib --cfg llvm_compone
nt="aarch64" --cfg llvm_component="arm" --cfg llvm_component="asmparser" --cfg llvm_component="bitreader" --cfg llvm_component="bitwriter" --cfg llvm_component="hexagon" --cfg llvm_component="instrumentation" --cfg llvm_component="interpreter" --cfg llvm_component="ipo" --cfg llvm_component="jsbackend" --cfg llvm_component="linker" --cfg llvm_component="lto" --cfg llvm_component="mcjit" --cfg llvm_component="mips" --cfg llvm_component="msp430" --cfg llvm_component="nvptx" --cfg llvm_component="powerpc" --cfg llvm_component="sparc" --cfg llvm_component="systemz" --cfg llvm_component="webassembly" --cfg llvm_component="x86" -l static=rustllvm -l static=LLVMX86Disassembler -l static=LLVMX86AsmParser -l static=LLVMX86CodeGen -l static=LLVMX86Desc -l static=LLVMX86Info -l static=LLVMX86AsmPrinter -l static=LLVMX86Utils -l static=LLVMWebAssemblyDisassembler -l static=LLVMWebAssemblyCodeGen -l static=LLVMWebAssemblyDesc -l static=LLVMWebAssemblyInfo -l static=LLVMWebAssemblyAsmPrinter -l static=LLVMSystemZDisassembler -l static=LLVMSystemZCodeGen -l static=LLVMSystemZAsmParser -l static=LLVMSystemZDesc -l static=LLVMSystemZInfo -l static=LLVMSystemZAsmPrinter -l static=LLVMSparcDisassembler -l static=LLVMSparcCodeGen -l static=LLVMSparcAsmParser -l static=LLVMSparcDesc -l static=LLVMSparcInfo -l static=LLVMSparcAsmPrinter -l static=LLVMPowerPCDisassembler -l static=LLVMPowerPCCodeGen -l static=LLVMPowerPCAsmParser -l static=LLVMPowerPCDesc -l static=LLVMPowerPCInfo -l static=LLVMPowerPCAsmPrinter -l static=LLVMNVPTXCodeGen -l static=LLVMNVPTXDesc -l static=LLVMNVPTXInfo -l static=LLVMNVPTXAsmPrinter -l static=LLVMMSP430CodeGen -l static=LLVMMSP430Desc -l static=LLVMMSP430Info -l static=LLVMMSP430AsmPrinter -l static=LLVMMipsDisassembler -l static=LLVMMipsCodeGen -l static=LLVMMipsAsmParser -l static=LLVMMipsDesc -l static=LLVMMipsInfo -l static=LLVMMipsAsmPrinter -l static=LLVMMCJIT -l static=LLVMLTO -l static=LLVMPasses -l static=LLVMObjCARCOpts -l static=LLVMJSBackendCodeGen -l static=LLVMPNaClTransforms -l static=LLVMJSBackendDesc -l static=LLVMJSBackendInfo -l static=LLVMipo -l static=LLVMVectorize -l static=LLVMLinker -l static=LLVMIRReader -l static=LLVMInterpreter -l static=LLVMExecutionEngine -l static=LLVMRuntimeDyld -l static=LLVMInstrumentation -l static=LLVMHexagonDisassembler -l static=LLVMHexagonCodeGen -l static=LLVMHexagonAsmParser -l static=LLVMHexagonDesc -l static=LLVMHexagonInfo -l static=LLVMAsmParser -l static=LLVMARMDisassembler -l static=LLVMARMCodeGen -l static=LLVMARMAsmParser -l static=LLVMARMDesc -l static=LLVMARMInfo -l static=LLVMARMAsmPrinter -l static=LLVMAArch64Disassembler -l static=LLVMMCDisassembler -l static=LLVMAArch64CodeGen -l static=LLVMGlobalISel -l static=LLVMSelectionDAG -l static=LLVMAsmPrinter -l static=LLVMDebugInfoCodeView -l static=LLVMDebugInfoMSF -l static=LLVMCodeGen -l static=LLVMTarget -l static=LLVMScalarOpts -l static=LLVMInstCombine -l static=LLVMTransformUtils -l static=LLVMBitWriter -l static=LLVMAnalysis -l static=LLVMObject -l static=LLVMBitReader -l static=LLVMProfileData -l static=LLVMCore -l static=LLVMAArch64AsmParser -l static=LLVMMCParser -l static=LLVMAArch64Desc -l static=LLVMAArch64Info -l static=LLVMAArch64AsmPrinter -l static=LLVMMC -l static=LLVMAArch64Utils -l static=LLVMSupport -l static=LLVMDemangle -l static=c++` (exit code: 101)

I'm not quite sure where to go next.

Edit:

The diff above produced a successful build with ./src/ci/docker/run.sh dist-i686-freebsd

bors added a commit that referenced this pull request Dec 26, 2017
Re-do the FreeBSD cross-builds to use Clang and libc++. Fixes #44433

Reviving #45077, from @jld:

> The main goal here is to use FreeBSD's normal libc++, instead of
> statically linking the libstdc++ packaged with GCC, because that
> libstdc++ has bugs that cause rustc to deadlock inside LLVM.
>
> But the easiest way to use libc++ is to switch the build from GCC to
> Clang, and the Clang package in the Ubuntu image already knows how to
> cross-compile (given a sysroot and preferably cross-binutils), so the
> toolchain script now uses that instead of building a custom compiler.
>
> This also de-duplicates the build-toolchain.sh script.

#45077 was close but didn't quite make it.  I rebased @jld's work off the current `master` and started with that.

I was able to determine that this Travis error (#45077 (comment)) was ultimately caused by `src/librustc_llvm/build.rs` attempting to follow a wrong value in `LLVM_STATIC_STDCPP` (#45077 (comment)).

I looked at the downstream port for FreeBSD (https://svnweb.freebsd.org/ports/head/lang/rust/) and it seems like they do not use `--enable-llvm-static-stdcpp`.

Since `libc++` is included in the FreeBSD 10+ base system, we don't need to statically link it either?

So in b989428 I have set the FreeBSD build to not actually use `LLVM_STATIC_STDCPP`.

I was able to run `./src/ci/docker/run.sh` with both `dist-i686-freebsd` and `dist-x86_64-freebsd` successfully and in about 1 minute of testing it seemed like the dist-x86_64-freebsd results worked on a FreeBSD 11 system.

It should fix #44433, which seems to be affecting many potential users.  Also FreeBSD users should be able to `./x.py build` which should help anyone who wants to upstream fixes for FreeBSD.

Questions:

Does this approach seem to be the right way to go? Do we actually really want to statically link `libc++`? (I tried that here, but it ultimately ran into a roadblock on x86_64: #45077 (comment))

Can we rewrite the comment here to be more clear about why some systems aren't going to actually use this option:
https://github.com/rust-lang/rust/blob/b989428f7dec7b52d68bed6a21e9b5b0a8086267/src/bootstrap/compile.rs#L550-L553

How does this affect users of older FreeBSD systems? It seemed like no one was complaining about using a 10.3 base version in the thread for #45077.  FreeBSD seems to only officially support 10.3, 10.4, and 11.x right now, do we have to consider older users? The `libc++` stuff came in for FreeBSD 10, older FreeBSD used `libstdc++`.

Looks like @alexcrichton was leading the discussion on the previous issue:

r? @alexcrichton

Let me know what I can do to help get this through.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants