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

Bootstrapping rustc for sparc64-unknown-linux-gnu fails with linker errors #45456

Closed
glaubitz opened this issue Oct 22, 2017 · 5 comments
Closed
Labels
C-bug Category: This is a bug. O-SPARC Target: SPARC processors

Comments

@glaubitz
Copy link
Contributor

glaubitz commented Oct 22, 2017

I have tried to bootstrap rustc for sparc64-unknown-linux-gnu with:

$ ./configure --host=sparc64-unknown-linux-gnu && make

which fails with:

Building stage1 test artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.0 secs
Copying stage1 test from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.0 secs
Copying stage1 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Assembling stage2 compiler (x86_64-unknown-linux-gnu)
Uplifting stage1 std (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Copying stage2 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> sparc64-unknown-linux-gnu)
   Compiling std v0.0.0 (file:///home/glaubitz/rust/rust/src/libstd)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/sparc64-unknown-linux-gnu/lib" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/de\
ps/std-5e8ebc384e5dfd82.std0.rust-cgu.o" "-o" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/libstd-5e8ebc384e5dfd82.so" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux\
-gnu/release/deps/std-5e8ebc384e5dfd82.crate.metadata.rust-cgu.o" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/std-5e8ebc384e5dfd82.crate.allocator.rust-cgu.o" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"\
 "-L" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps" "-L" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/deps" "-L" "/home/glaubitz/rust/rust/build/sparc64-unknown-linux-gnu/native\
/libbacktrace/.libs" "-L" "/home/glaubitz/rust/rust/build/sparc64-unknown-linux-gnu/native/jemalloc/lib" "-L" "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/build/compiler_builtins-a1f49ad8dde16ae2/out" "-L" "/home/\
glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/sparc64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "backtrace" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-Wl,-Bstatic" "-Wl,--whole-archive" "/t\
mp/rustc.4vz7yahAsBSv/libpanic_unwind-368647e9b9ca3b39.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.4vz7yahAsBSv/libunwind-eda6aedbad712bc0.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.4vz7yahAsBSv/librand-efc56d5e4c2b1ee8.rlib" "\
-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.4vz7yahAsBSv/liballoc_system-67992b04c9027e70.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.4vz7yahAsBSv/liblibc-bdd38e4620ffab1c.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rust\
c.4vz7yahAsBSv/liballoc-c15d9e20191e711b.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.4vz7yahAsBSv/libstd_unicode-b3230a4723442795.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.4vz7yahAsBSv/libcore-3181dd9e46400ebd.rlib" "-Wl,--no-\
whole-archive" "/tmp/rustc.4vz7yahAsBSv/libcompiler_builtins-fa8533728d55e42b.rlib" "-Wl,-Bdynamic" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /usr/bin/ld: /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/std-5e8ebc384e5dfd82.std0.rust-cgu.o: Relocations in generic ELF (EM: 43)
(...)
          /usr/bin/ld: /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/std-5e8ebc384e5dfd82.std0.rust-cgu.o: Relocations in generic ELF (EM: 43)
          /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/std-5e8ebc384e5dfd82.std0.rust-cgu.o: error adding symbols: File in wrong format
          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: `/home/glaubitz/rust/rust/build/bootstrap/debug/rustc --crate-name std src/libstd/lib.rs --error-format json --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 --cfg feature="alloc_jemalloc" --c\
fg feature="backtrace" --cfg feature="jemalloc" --cfg feature="panic-unwind" --cfg feature="panic_unwind" -C metadata=5e8ebc384e5dfd82 -C extra-filename=-5e8ebc384e5dfd82 --out-dir /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-\
gnu/release/deps --target sparc64-unknown-linux-gnu -L dependency=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps -L dependency=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/deps --ex\
tern alloc_system=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/liballoc_system-67992b04c9027e70.rlib --extern compiler_builtins=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknow\
n-linux-gnu/release/deps/libcompiler_builtins-fa8533728d55e42b.rlib --extern unwind=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/libunwind-eda6aedbad712bc0.rlib --extern std_unicode=/home/glaubitz/rust/rust/bu\
ild/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/libstd_unicode-b3230a4723442795.rlib --extern alloc=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/liballoc-c15d9e20191e711b.rlib --\
extern panic_unwind=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/libpanic_unwind-368647e9b9ca3b39.rlib --extern core=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu\
/release/deps/libcore-3181dd9e46400ebd.rlib --extern libc=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/liblibc-bdd38e4620ffab1c.rlib --extern collections=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu\
/stage1-std/sparc64-unknown-linux-gnu/release/deps/libcollections-17d6af9abb88abd5.rlib --extern rand=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/librand-efc56d5e4c2b1ee8.rlib --extern panic_abort=/home/glaub\
itz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/libpanic_abort-3500a7ebf8df4faa.rlib --extern alloc_jemalloc=/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/liballoc\
_jemalloc-5c483b777c53a191.rlib -L native=/home/glaubitz/rust/rust/build/sparc64-unknown-linux-gnu/native/libbacktrace/.libs -l static=backtrace -l dl -l rt -l pthread -L native=/home/glaubitz/rust/rust/build/sparc64-unknown-linux-gnu/native/jemalloc/lib -L native=/home\
/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/build/compiler_builtins-a1f49ad8dde16ae2/out` (exit code: 101)
thread 'main' panicked at 'command did not execute successfully: "/home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "sparc64-unknown-linux-gnu" "--release" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/home\
/glaubitz/rust/rust/src/libstd/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101', src/bootstrap/compile.rs:873:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failed to run: /home/glaubitz/rust/rust/build/bootstrap/debug/bootstrap build
Build completed unsuccessfully in 0:00:20
Makefile:22: recipe for target 'all' failed
make: *** [all] Error 1

The message /usr/bin/ld: /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/std-5e8ebc384e5dfd82.std0.rust-cgu.o: Relocations in generic ELF (EM: 43) is repeated several hundred times which is why I cut the all but two instances of that message out.

From the error messages above, it seems that the build process is invoking the wrong linker binary:

/usr/bin/ld: /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/std-5e8ebc384e5dfd82.std0.rust-cgu.o: Relocations in generic ELF (EM: 43)
          /home/glaubitz/rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/sparc64-unknown-linux-gnu/release/deps/std-5e8ebc384e5dfd82.std0.rust-cgu.o: error adding symbols: File in wrong format
          collect2: error: ld returned 1 exit status

It's invoking /usr/bin/ld, but it should actually invoke /usr/bin/sparc64-linux-gnu-ld.

I haven't looked at the code yet, but I would suggest that the build process should always call external compilers and binutils using the GNU triplet prefix.

PS: I am one of Debian's sparc64 porters and I will be happy to provide to a fast SPARC-T5 porterbox to anyone who is interested in working on Rust on Linux/SPARC.

@Mark-Simulacrum
Copy link
Member

I think this is likely to be more of cc crates' fault, but @alexcrichton probably knows more than I do about how we select linkers.

@jrtc27
Copy link

jrtc27 commented Oct 22, 2017

Indeed, https://github.com/alexcrichton/cc-rs/blob/9839b14742b8721d69b0f8df3d925107b477476a/src/lib.rs#L1411-L1446 looks like a likely culprit. Looks like

let os = match &*target {
"aarch64-linux-android" => "linux-aarch64",
"aarch64-unknown-linux-gnu" => "linux-aarch64",
"aarch64-unknown-linux-musl" => "linux-aarch64",
"arm-linux-androideabi" => "android",
"arm-unknown-linux-gnueabi" => "linux-armv4",
"arm-unknown-linux-gnueabihf" => "linux-armv4",
"armv7-linux-androideabi" => "android-armv7",
"armv7-unknown-linux-gnueabihf" => "linux-armv4",
"i686-apple-darwin" => "darwin-i386-cc",
"i686-linux-android" => "android-x86",
"i686-unknown-freebsd" => "BSD-x86-elf",
"i686-unknown-linux-gnu" => "linux-elf",
"i686-unknown-linux-musl" => "linux-elf",
"i686-unknown-netbsd" => "BSD-x86-elf",
"mips-unknown-linux-gnu" => "linux-mips32",
"mips64-unknown-linux-gnuabi64" => "linux64-mips64",
"mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
"mipsel-unknown-linux-gnu" => "linux-mips32",
"powerpc-unknown-linux-gnu" => "linux-ppc",
"powerpc64-unknown-linux-gnu" => "linux-ppc64",
"powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
"s390x-unknown-linux-gnu" => "linux64-s390x",
"sparc64-unknown-netbsd" => "BSD-sparc64",
"x86_64-apple-darwin" => "darwin64-x86_64-cc",
"x86_64-linux-android" => "linux-x86_64",
"x86_64-unknown-freebsd" => "BSD-x86_64",
"x86_64-unknown-linux-gnu" => "linux-x86_64",
"x86_64-unknown-linux-musl" => "linux-x86_64",
"x86_64-unknown-netbsd" => "BSD-x86_64",
_ => panic!("don't know how to configure OpenSSL for {}", target),
};
also needs modifying otherwise there'll be future problems.

@glaubitz
Copy link
Contributor Author

@jrtc27 Thanks, I was looking for exactly that! I already opened a PR for cc-rs.

Will look into the bootstrap code in a second.

@glaubitz
Copy link
Contributor Author

glaubitz commented Oct 23, 2017

@Mark-Simulacrum @jrtc27 The two changes have resolved the problems, but we're still running into this issue:

Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / sparc64-unknown-linux-gnu)
Assembling stage1 compiler (sparc64-unknown-linux-gnu)
Uplifting stage1 std (x86_64-unknown-linux-gnu -> sparc64-unknown-linux-gnu)
Copying stage2 std from stage1 (x86_64-unknown-linux-gnu -> sparc64-unknown-linux-gnu / sparc64-unknown-linux-gnu)
Uplifting stage1 test (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Copying stage2 test from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
thread 'main' panicked at 'File::open(stamp) failed with No such file or directory (os error 2)', src/bootstrap/util.rs:57:7
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:397
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:572
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:522
   7: bootstrap::util::read_stamp_file
   8: bootstrap::compile::add_to_sysroot
   9: <bootstrap::compile::TestLink as bootstrap::builder::Step>::run
  10: bootstrap::builder::Builder::ensure
  11: <bootstrap::compile::Test as bootstrap::builder::Step>::run
  12: bootstrap::builder::Builder::ensure
  13: <bootstrap::compile::Test as bootstrap::builder::Step>::make_run
  14: bootstrap::builder::StepDescription::maybe_run
  15: bootstrap::builder::StepDescription::run
  16: bootstrap::builder::Builder::run
  17: bootstrap::Build::build
  18: bootstrap::main
  19: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:99
  20: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:459
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:61
  21: main
  22: __libc_start_main
  23: _start
failed to run: /local_scratch/glaubitz/rust/rust/build/bootstrap/debug/bootstrap build
Build completed unsuccessfully in 0:23:34
Makefile:22: recipe for target 'all' failed
make: *** [all] Error 1

Any idea?

Edit: Seems like it's a problem that occurs when running multiple jobs in parallel. Without "-j$JOBS", it succeeds.

@TimNN TimNN added C-bug Category: This is a bug. O-SPARC Target: SPARC processors labels Oct 24, 2017
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 25, 2017
bootstrap: Add openssl configuration for sparc64-unknown-linux-gnu

Hi!

This adds the target missing mapping for sparc64-unknown-linux-gnu.

See: rust-lang#45456

Thanks
@glaubitz
Copy link
Contributor Author

Since both rust-lang/cc-rs#262 and #45465 have been merged, I am closing this one now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-SPARC Target: SPARC processors
Projects
None yet
Development

No branches or pull requests

4 participants