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

libunwind: use correct compiler for cross compilation #61544

Closed
wants to merge 1 commit into from

Conversation

Keruspe
Copy link
Contributor

@Keruspe Keruspe commented Jun 5, 2019

Fixes #59917

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 5, 2019
@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 5, 2019

Hmm, actually the change wasn't properly tested, fixing it.

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 6, 2019

Works fine in one of my two environments and not in another one, still digging, but at least that's an improvement, as it worked on none of those before

Fixes rust-lang#59917

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
@Centril
Copy link
Contributor

Centril commented Jun 10, 2019

r? @alexcrichton

@alexcrichton
Copy link
Member

Thanks for the PR, but I don't think that this is the best way to solve the issue since the build script should already be using cc which should be reading appropriate env vars. Do you know why that's not happening?

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 10, 2019

@alexcrichton In my case, i'm building from x86_64 a rustc with both x86_64 and i686 targets. CC, AR, etc env vars point to the x86_64 compiler, are picked by cc and thus the x86_64 toolchain gets used for i686, which fails.

I don't have enough time right now but I'll provide logs with and without the patch so you can see the difference.

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 10, 2019

Logs without the patch (in a clean environment which doesn't set the CC & friends env vars)

   Compiling unwind v0.0.0 (/home/keruspe/Sources/rust/src/libunwind)
     Running `/home/keruspe/Sources/rust/build/bootstrap/debug/rustc --edition=2018 --crate-name rustc_std_workspace_core src/tools/rustc-std-workspace-core/lib.rs --color always --error-format json --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C metadata=72e4d0af026191c2 -C extra-filename=-72e4d0af026191c2 --out-dir /home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps --target i686-unknown-linux-gnu -L dependency=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps -L dependency=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/release/deps --extern core=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcore-a33d9cdb501fe3a7.rlib`
     Running `/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/release/build/unwind-a7c5de98df2e44af/build-script-build`
rustc command: "LD_LIBRARY_PATH"="/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2/lib:/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/release/deps:/usr/x86_64-pc-linux-gnu/lib" "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--edition=2018" "--crate-name" "rustc_std_workspace_core" "src/tools/rustc-std-workspace-core/lib.rs" "--color" "always" "--crate-type" "lib" "--emit=dep-info,metadata,link" "-C" "opt-level=2" "-C" "metadata=72e4d0af026191c2-rustc" "-C" "extra-filename=-72e4d0af026191c2" "--out-dir" "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps" "--target" "i686-unknown-linux-gnu" "-L" "dependency=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps" "-L" "dependency=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/release/deps" "--extern" "core=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcore-a33d9cdb501fe3a7.rlib" "-Cdebuginfo=0" "--sysroot" "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2" "-Zexternal-macro-backtrace" "-Cprefer-dynamic" "-Clinker=i686-pc-linux-gnu-cc" "-C" "debug-assertions=n" "-C" "codegen-units=1" "-Zsave-analysis" "-C" "target-feature=-crt-static" "--remap-path-prefix" "/home/keruspe/Sources/rust=/rustc/a73ecb3d9c432f8f53117b1a6b6c209dc802dee7" "-Zunstable-options" "-Z" "force-unstable-if-unmarked"
sysroot: "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2"
libdir: "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2/lib"
error: failed to run custom build command for `unwind v0.0.0 (/home/keruspe/Sources/rust/src/libunwind)`

Caused by:
  process didn't exit successfully: `/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/release/build/unwind-a7c5de98df2e44af/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build.rs
TARGET = Some("i686-unknown-linux-gnu")
OPT_LEVEL = Some("2")
HOST = Some("x86_64-unknown-linux-gnu")
CXX_i686-unknown-linux-gnu = None
CXX_i686_unknown_linux_gnu = None
TARGET_CXX = None
CXX = None
CROSS_COMPILE = None
CXXFLAGS_i686-unknown-linux-gnu = None
CXXFLAGS_i686_unknown_linux_gnu = None
TARGET_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,mmx,sse,sse2")
running: "c++" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m32" "-march=i686" "-I" "../llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-o" "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-ea5f1715daebce5e/out/../llvm-project/libunwind/src/Unwind-EHABI.o" "-c" "../llvm-project/libunwind/src/Unwind-EHABI.cpp"
cargo:warning=cc1plus: warning: command line option '-std=c99' is valid for C/ObjC but not for C++
exit code: 0
running: "c++" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m32" "-march=i686" "-I" "../llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-o" "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-ea5f1715daebce5e/out/../llvm-project/libunwind/src/Unwind-seh.o" "-c" "../llvm-project/libunwind/src/Unwind-seh.cpp"
cargo:warning=cc1plus: warning: command line option '-std=c99' is valid for C/ObjC but not for C++
cargo:warning=In file included from /usr/x86_64-pc-linux-gnu/include/features.h:474,
cargo:warning=                 from /usr/x86_64-pc-linux-gnu/include/assert.h:35,
cargo:warning=                 from ../llvm-project/libunwind/src/config.h:17,
cargo:warning=                 from ../llvm-project/libunwind/src/Unwind-seh.cpp:14:
cargo:warning=/usr/x86_64-pc-linux-gnu/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-32.h: No such file or directory
cargo:warning=    7 | # include <gnu/stubs-32.h>
cargo:warning=      |           ^~~~~~~~~~~~~~~~
cargo:warning=compilation terminated.
exit code: 1

--- stderr
thread 'main' panicked at '

Internal error occurred: Command "c++" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m32" "-march=i686" "-I" "../llvm-project/libunwind/include" "-std=c99" "-std=c++11" "-nostdinc++" "-fno-exceptions" "-fno-rtti" "-fstrict-aliasing" "-funwind-tables" "-o" "/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-ea5f1715daebce5e/out/../llvm-project/libunwind/src/Unwind-seh.o" "-c" "../llvm-project/libunwind/src/Unwind-seh.cpp" with args "c++" did not execute successfully (status code exit code: 1).

', /home/keruspe/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/cc-1.0.35/src/lib.rs:2398:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: "/usr/host/bin/cargo-beta" "build" "--target" "i686-unknown-linux-gnu" "-j" "8" "-v" "--release" "--locked" "--features" "panic-unwind llvm-libunwind backtrace compiler-builtins-c" "--manifest-path" "/home/keruspe/Sources/rust/src/libstd/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101
Traceback (most recent call last):
  File "./x.py", line 11, in <module>
    bootstrap.main()
  File "/home/keruspe/Sources/rust/src/bootstrap/bootstrap.py", line 847, in main
    bootstrap(help_triggered)
  File "/home/keruspe/Sources/rust/src/bootstrap/bootstrap.py", line 833, in bootstrap
    run(args, env=env, verbose=build.verbose)
  File "/home/keruspe/Sources/rust/src/bootstrap/bootstrap.py", line 141, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /home/keruspe/Sources/rust/build/bootstrap/debug/bootstrap build libstd

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 10, 2019

Relevant parts of config.toml:

[llvm]
cflags = "-march=native -pipe -O2"
cxxflags = "-march=native -pipe -O2"
ldflags = "-Wl,-O1 -Wl,--as-needed"
[build]
build = "x86_64-unknown-linux-gnu"
host = ["x86_64-unknown-linux-gnu"]
target = ["i686-unknown-linux-gnu","x86_64-unknown-linux-gnu"]
[rust]
backtrace = true
default-linker = "x86_64-pc-linux-gnu-cc"
codegen-backends = ["llvm"]
llvm-libunwind = true
[target.i686-unknown-linux-gnu]
cc = "i686-pc-linux-gnu-cc"
cxx = "i686-pc-linux-gnu-c++"
ar = "i686-pc-linux-gnu-ar"
ranlib = "i686-pc-linux-gnu-ranlib"
linker = "i686-pc-linux-gnu-cc"
[target.x86_64-unknown-linux-gnu]
cc = "x86_64-pc-linux-gnu-cc"
cxx = "x86_64-pc-linux-gnu-c++"
ar = "x86_64-pc-linux-gnu-ar"
ranlib = "x86_64-pc-linux-gnu-ranlib"
linker = "x86_64-pc-linux-gnu-cc"

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 10, 2019

Logs with the patch applied:

    c Sysroot { compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" } }
  < StdLink { compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" }, target_compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" }, target: "i686-unknown-linux-gnu" }
< Std { target: "i686-unknown-linux-gnu", compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" } }
Build completed successfully in 0:25:15

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 10, 2019

Now, in an environment (our package manager) which sets a lot of env vars such as CC, LD, AR and friends, it still fails (at link time though, not the same failure), didn't find the reason yet.

But as it builds just fine in a "clean" environment, that's already a great progress.

I'm 100% fine with doing all this differently, I just posted that to gather some cmoments about how the proper way would look like. At least it shows that if we cc chooses the right compiler to use, it works

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 11, 2019

The fail I'm seeing when building from our package manager (beta branch) with the patch applied.
Not sure which part of the env is causing it yet.

   Compiling std v0.0.0 (/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/src/libstd)
     Running `/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/bootstrap/debug/rustc --edition=2018 --crate-name std src/libstd/lib.rs --color always --error-format json --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 --cfg 'feature="alloc"' --cfg 'feature="backtrace"' --cfg 'feature="backtrace-sys"' --cfg 'feature="compiler_builtins_c"' --cfg 'feature="default"' --cfg 'feature="llvm-libunwind"' --cfg 'feature="panic-unwind"' --cfg 'feature="panic_unwind"' --cfg 'feature="std_detect_dlsym_getauxval"' --cfg 'feature="std_detect_file_io"' --cfg 'feature="unwind"' -C metadata=905d9a5343fb7f0b -C extra-filename=-905d9a5343fb7f0b --out-dir /var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps --target i686-unknown-linux-gnu -L dependency=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps -L dependency=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/release/deps --extern alloc=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/liballoc-5da6afa6dd8eaf96.rlib --extern backtrace_sys=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libbacktrace_sys-5225fbc5f89d907b.rlib --extern compiler_builtins=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcompiler_builtins-3a1b71d317791177.rlib --extern core=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcore-de33394763492b91.rlib --extern hashbrown=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libhashbrown-dbfdd6753177204f.rlib --extern libc=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/liblibc-6519fc4677838b44.rlib --extern panic_abort=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libpanic_abort-fb64ac619eb10a51.rlib --extern panic_unwind=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libpanic_unwind-4fdc5255f966c509.rlib --extern rustc_demangle=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/librustc_demangle-bb7fa3939bbd49ea.rlib --extern unwind=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libunwind-a5998341b20c9128.rlib -C target-cpu=native -C opt-level=3 -l dl -l rt -l pthread -L native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/compiler_builtins-35831ff26695ec30/out -L native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/backtrace-sys-83738e3a779bc934/out -L native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-2ffdb0b3fe9e67b9/out`
rustc command: "LD_LIBRARY_PATH"="/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2/lib:/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/release/deps:/usr/x86_64-pc-linux-gnu/lib" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--edition=2018" "--crate-name" "std" "src/libstd/lib.rs" "--color" "always" "--crate-type" "dylib" "--crate-type" "rlib" "--emit=dep-info,link" "-C" "prefer-dynamic" "-C" "opt-level=2" "--cfg" "feature=\"alloc\"" "--cfg" "feature=\"backtrace\"" "--cfg" "feature=\"backtrace-sys\"" "--cfg" "feature=\"compiler_builtins_c\"" "--cfg" "feature=\"default\"" "--cfg" "feature=\"llvm-libunwind\"" "--cfg" "feature=\"panic-unwind\"" "--cfg" "feature=\"panic_unwind\"" "--cfg" "feature=\"std_detect_dlsym_getauxval\"" "--cfg" "feature=\"std_detect_file_io\"" "--cfg" "feature=\"unwind\"" "-C" "metadata=905d9a5343fb7f0b-rustc" "-C" "extra-filename=-905d9a5343fb7f0b" "--out-dir" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps" "--target" "i686-unknown-linux-gnu" "-L" "dependency=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps" "-L" "dependency=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/release/deps" "--extern" "alloc=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/liballoc-5da6afa6dd8eaf96.rlib" "--extern" "backtrace_sys=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libbacktrace_sys-5225fbc5f89d907b.rlib" "--extern" "compiler_builtins=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcompiler_builtins-3a1b71d317791177.rlib" "--extern" "core=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcore-de33394763492b91.rlib" "--extern" "hashbrown=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libhashbrown-dbfdd6753177204f.rlib" "--extern" "libc=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/liblibc-6519fc4677838b44.rlib" "--extern" "panic_abort=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libpanic_abort-fb64ac619eb10a51.rlib" "--extern" "panic_unwind=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libpanic_unwind-4fdc5255f966c509.rlib" "--extern" "rustc_demangle=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/librustc_demangle-bb7fa3939bbd49ea.rlib" "--extern" "unwind=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libunwind-a5998341b20c9128.rlib" "-C" "target-cpu=native" "-C" "opt-level=3" "-l" "dl" "-l" "rt" "-l" "pthread" "-L" "native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/compiler_builtins-35831ff26695ec30/out" "-L" "native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/backtrace-sys-83738e3a779bc934/out" "-L" "native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-2ffdb0b3fe9e67b9/out" "--cfg" "stage2" "--sysroot" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2" "-Zexternal-macro-backtrace" "-Cprefer-dynamic" "-Clinker=i686-pc-linux-gnu-cc" "-Cdebuginfo=1" "-C" "debug-assertions=n" "-C" "codegen-units=1" "-Zsave-analysis" "-C" "target-feature=-crt-static" "--remap-path-prefix" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm=/rustc/07a9daea9fc4153366c09e7574c581a60697c388" "-Zunstable-options" "-Z" "force-unstable-if-unmarked"
sysroot: "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2"
libdir: "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2/lib"
    Building [=====================================================>   ] 23/24: std                                                                                                                                                                                                                                                                                                                                                     
Error:
  * In program cave perform install --hooks --managed-output --output-exclusivity with-others =dev-lang/rust-1.36.0-scm:beta::rust --destination installed --replacing =dev-lang/rust-1.36.0-scm:beta::installed --x-of-y 1 of 1 --skip-until-phase compile:
  * When installing 'dev-lang/rust-1.36.0-scm:beta::rust' replacing { 'dev-lang/rust-1.36.0-scm:beta::installed' }:
  * When running an ebuild command on 'dev-lang/rust-1.36.0-scm:beta::rust':
  * Install failed for 'dev-lang/rust-1.36.0-scm:beta::rust' (paludis::ActionFailedError)

error: linking with `i686-pc-linux-gnu-cc` failed: exit code: 1
  |
  = note: "i686-pc-linux-gnu-cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m32" "-L" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/i686-unknown-linux-gnu/lib" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/std-905d9a5343fb7f0b.std.iw7cj428-cgu.0.rcgu.o" "-o" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libstd-905d9a5343fb7f0b.so" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/std-905d9a5343fb7f0b.3jraqvslhe5whofm.rcgu.o" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/std-905d9a5343fb7f0b.9anbgmrmwn4jl9k.rcgu.o" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps" "-L" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/release/deps" "-L" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/compiler_builtins-35831ff26695ec30/out" "-L" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/backtrace-sys-83738e3a779bc934/out" "-L" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-2ffdb0b3fe9e67b9/out" "-L" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/i686-unknown-linux-gnu/lib" "-ldl" "-lrt" "-lpthread" "-Wl,-Bstatic" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/libpanic_unwind-4fdc5255f966c509.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/libbacktrace_sys-5225fbc5f89d907b.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/librustc_demangle-bb7fa3939bbd49ea.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/libhashbrown-dbfdd6753177204f.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/librustc_std_workspace_alloc-ca207876e88c149b.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/libunwind-a5998341b20c9128.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/liblibc-6519fc4677838b44.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/liballoc-5da6afa6dd8eaf96.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/librustc_std_workspace_core-12dd34c0104c7132.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/libcore-de33394763492b91.rlib" "-Wl,--no-whole-archive" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/temp/rustcVDrmPX/libcompiler_builtins-3a1b71d317791177.rlib" "-Wl,-Bdynamic" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil" "-shared"
  = note: i686-pc-linux-gnu-ld: error: dwarf.c:(.debug_info+0x4D06D): has non-ABS relocation R_386_GOTOFF against symbol '.LC28'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `std`.

Caused by:
  process didn't exit successfully: `/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/bootstrap/debug/rustc --edition=2018 --crate-name std src/libstd/lib.rs --color always --error-format json --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 --cfg 'feature="alloc"' --cfg 'feature="backtrace"' --cfg 'feature="backtrace-sys"' --cfg 'feature="compiler_builtins_c"' --cfg 'feature="default"' --cfg 'feature="llvm-libunwind"' --cfg 'feature="panic-unwind"' --cfg 'feature="panic_unwind"' --cfg 'feature="std_detect_dlsym_getauxval"' --cfg 'feature="std_detect_file_io"' --cfg 'feature="unwind"' -C metadata=905d9a5343fb7f0b -C extra-filename=-905d9a5343fb7f0b --out-dir /var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps --target i686-unknown-linux-gnu -L dependency=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps -L dependency=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/release/deps --extern alloc=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/liballoc-5da6afa6dd8eaf96.rlib --extern backtrace_sys=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libbacktrace_sys-5225fbc5f89d907b.rlib --extern compiler_builtins=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcompiler_builtins-3a1b71d317791177.rlib --extern core=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libcore-de33394763492b91.rlib --extern hashbrown=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libhashbrown-dbfdd6753177204f.rlib --extern libc=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/liblibc-6519fc4677838b44.rlib --extern panic_abort=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libpanic_abort-fb64ac619eb10a51.rlib --extern panic_unwind=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libpanic_unwind-4fdc5255f966c509.rlib --extern rustc_demangle=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/librustc_demangle-bb7fa3939bbd49ea.rlib --extern unwind=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/deps/libunwind-a5998341b20c9128.rlib -C target-cpu=native -C opt-level=3 -l dl -l rt -l pthread -L native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/compiler_builtins-35831ff26695ec30/out -L native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/backtrace-sys-83738e3a779bc934/out -L native=/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-2ffdb0b3fe9e67b9/out` (exit code: 1)
command did not execute successfully: "/usr/host/bin/cargo-beta" "build" "--target" "i686-unknown-linux-gnu" "-j" "8" "-v" "--release" "--locked" "--features" "panic-unwind llvm-libunwind backtrace" "--manifest-path" "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/src/libstd/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101
Traceback (most recent call last):
  File "./x.py", line 11, in <module>
    bootstrap.main()
  File "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/src/bootstrap/bootstrap.py", line 847, in main
    bootstrap(help_triggered)
  File "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/src/bootstrap/bootstrap.py", line 833, in bootstrap
    run(args, env=env, verbose=build.verbose)
  File "/var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/src/bootstrap/bootstrap.py", line 141, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /var/tmp/paludis/build/dev-lang-rust-1.36.0-scm/work/rust-1.36.0-scm/build/bootstrap/debug/bootstrap dist

Relevant env set by the package manager:

AR=x86_64-pc-linux-gnu-ar
AS=x86_64-pc-linux-gnu-as
CC=x86_64-pc-linux-gnu-cc
CFLAGS='-march=native -pipe -O2'
CHOST=x86_64-pc-linux-gnu
CPP=x86_64-pc-linux-gnu-cpp
CPPFLAGS='-march=native -pipe -O2'
CXX=x86_64-pc-linux-gnu-c++
CXXCPPFLAGS='-march=native -pipe -O2'
CXXFLAGS='-march=native -pipe -O2'
FORTRAN=x86_64-pc-linux-gnu-gfortran
LC_ALL=C
LD=x86_64-pc-linux-gnu-ld
LDFLAGS='-Wl,-O1 -Wl,--as-needed'
OBJCOPY=x86_64-pc-linux-gnu-objcopy
OBJDUMP=x86_64-pc-linux-gnu-objdump
PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config
RANLIB=x86_64-pc-linux-gnu-ranlib
READELF=x86_64-pc-linux-gnu-readelf
RUSTFLAGS='-C target-cpu=native -C opt-level=3'
RUST_HOST=x86_64-unknown-linux-gnu
TARGETS='i686-pc-linux-gnu x86_64-pc-linux-gnu'
i686_pc_linux_gnu_CFLAGS='-march=native -pipe -O2'
i686_pc_linux_gnu_CXXFLAGS='-march=native -pipe -O2'
i686_pc_linux_gnu_LDFLAGS='-Wl,-O1 -Wl,--as-needed'
x86_64_pc_linux_gnu_CFLAGS='-march=native -pipe -O2'
x86_64_pc_linux_gnu_CXXFLAGS='-march=native -pipe -O2'
x86_64_pc_linux_gnu_LDFLAGS='-Wl,-O1 -Wl,--as-needed'

@alexcrichton
Copy link
Member

It looks like this is doing something that basically isn't well supported now which is to enable the compilation of libunwind. That requires a C++ compiler but the C++ compiler isn't properly configured in rustbuild for libstd, just for the rustc build and beyond (because historically only LLVM needed a C++ compiler).

The fix for this is to handle that somehow, not by introducing yet-another-new-env-var to convey compiler information.

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 11, 2019

Last failure was actually caused by lld, works fine with gold.

I'll see how these are set for the rustc build and try to move those definitions around so that libstd can use them too

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 12, 2019

Ok, now I'm really puzzled.
Looking at the rustbuild code, it seems that the appropriate env vars are actually always set.
At the very beginning of the compile method from libunwind's build.rs, I added some basic command execution to output the env into a file, then grepped the file for 'unknown-linux-gnu' and got this:

AR_i686-unknown-linux-gnu=i686-pc-linux-gnu-ar
CFLAGS_i686-unknown-linux-gnu=-ffunction-sections -fdata-sections -fPIC -m32 -march=i686
RANLIB_i686-unknown-linux-gnu=i686-pc-linux-gnu-ar s
CC_i686-unknown-linux-gnu=i686-pc-linux-gnu-cc
RUSTC_LIBDIR=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2/lib
CARGO_TARGET_DIR=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std
LLVM_CONFIG=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-config
CFG_COMPILER_HOST_TRIPLE=i686-unknown-linux-gnu
RUSTC_SYSROOT=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2
RUSTC_REAL=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc
HOST=x86_64-unknown-linux-gnu
OUT_DIR=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/i686-unknown-linux-gnu/release/build/unwind-a9307dd74d26a2b6/out
LD_LIBRARY_PATH=/home/keruspe/Sources/rust/build/x86_64-unknown-linux-gnu/stage2-std/release/deps:/usr/x86_64-pc-linux-gnu/lib
RUSTBUILD_NATIVE_DIR=/home/keruspe/Sources/rust/build/i686-unknown-linux-gnu/native
BUILD=x86_64-unknown-linux-gnu
TARGET=i686-unknown-linux-gnu

It seems that the env is actually here, as expected, so why isn't it used by cc?

@Keruspe
Copy link
Contributor Author

Keruspe commented Jun 12, 2019

Oh, CC, AR, CFLAGS are there but CXX isn't

Keruspe added a commit to Keruspe/rust that referenced this pull request Jun 12, 2019
Replaces rust-lang#61544
Fixes rust-lang#59917

We need CXX to build llvm-libunwind which can be enabled for all
targets.
As we needed it for all hosts anyways, just move the detection so that
it is ran for all targets (which contains all hosts) instead.

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
@Keruspe Keruspe closed this Jun 12, 2019
bors added a commit that referenced this pull request Jun 25, 2019
rustbuild: detect cxx for all targets

Replaces #61544
Fixes #59917

We need CXX to build llvm-libunwind which can be enabled for alltargets.
As we needed it for all hosts anyways, just move the detection so that it is ran for all targets (which contains all hosts) instead.
Centril added a commit to Centril/rust that referenced this pull request Aug 7, 2019
…hton

Use libunwind from llvm-project submodule for musl targets

This avoid downloading libunwind by using the scheme introduced in rust-lang#61544
bors added a commit that referenced this pull request Aug 15, 2019
Use libunwind from llvm-project submodule for musl targets

This avoid downloading libunwind by using the scheme introduced in #61544
Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019
…hton

Use libunwind from llvm-project submodule for musl targets

This avoid downloading libunwind by using the scheme introduced in rust-lang#61544
Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019
…hton

Use libunwind from llvm-project submodule for musl targets

This avoid downloading libunwind by using the scheme introduced in rust-lang#61544
Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019
…hton

Use libunwind from llvm-project submodule for musl targets

This avoid downloading libunwind by using the scheme introduced in rust-lang#61544
Centril added a commit to Centril/rust that referenced this pull request Aug 16, 2019
…hton

Use libunwind from llvm-project submodule for musl targets

This avoid downloading libunwind by using the scheme introduced in rust-lang#61544
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

llvm-libunwind doesn't use the right compiler for cross targets
5 participants