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

run-make/relocation-model: "final link failed: Nonrepresentable section on output" #47037

Closed
SimonSapin opened this issue Dec 27, 2017 · 9 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug.

Comments

@SimonSapin
Copy link
Contributor

SimonSapin commented Dec 27, 2017

Running ./x.py test on unmodified master bfbb1f5 fails on Ubuntu 17.10. The output ends like this:

failures:

---- [run-make] run-make/relocation-model stdout ----
	
error: make failed
status: exit code: 2
command: "make"
stdout:
------------------------------------------
LD_LIBRARY_PATH="/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu:/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib:/home/simon/rust/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps:/home/simon/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib:" '/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu -L /home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu  -C relocation-model=static foo.rs
Makefile:17: recipe for target 'others' failed

------------------------------------------
stderr:
------------------------------------------
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu/foo.foo0.rcgu.o" "/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu/foo.foo1.rcgu.o" "/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu/foo.foo2.rcgu.o" "-o" "/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu/foo" "/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu/foo.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu" "-L" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-0baa2c971f4ccb5c.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-276e820bb149c519.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-d795c34fd7eb72c9.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-0f4b95d88e53e455.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-6d9370e956155877.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-f874e85b0fc1f5b8.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-c7758873e5bedec1.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-c9b8ae6d904bd621.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-c80c8268f013635d.rlib" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-6389cf691b0a8db6.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"
  = note: /usr/bin/ld: /home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make/relocation-model.stage2-x86_64-unknown-linux-gnu/foo.foo0.rcgu.o: relocation R_X86_64_32 against symbol `rust_eh_personality' can not be used when making a shared object; recompile with -fPIC
          /usr/bin/ld: final link failed: Nonrepresentable section on output
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

make: *** [others] Error 101

------------------------------------------

thread '[run-make] run-make/relocation-model' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:2776:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    [run-make] run-make/relocation-model

test result: FAILED. 168 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:476:21


command did not execute successfully: "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--rustdoc-path" "/home/simon/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "--src-base" "/home/simon/rust/src/test/run-make" "--build-base" "/home/simon/rust/build/x86_64-unknown-linux-gnu/test/run-make" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-make" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/home/simon/rust/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Zmiri -Zunstable-options" "--target-rustcflags" "-Crpath -O -Zmiri -Zunstable-options -Lnative=/home/simon/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python" "--lldb-python" "/usr/bin/python" "--gdb" "/usr/bin/gdb" "--llvm-version" "4.0.1\n" "--cc" "cc" "--cxx" "c++" "--cflags" "-ffunction-sections -fdata-sections -fPIC -m64" "--llvm-components" "aarch64 aarch64asmparser aarch64asmprinter aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils all all-targets analysis arm armasmparser armasmprinter armcodegen armdesc armdisassembler arminfo asmparser asmprinter bitreader bitwriter codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb demangle engine executionengine globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader jsbackend jsbackendcodegen jsbackenddesc jsbackendinfo libdriver lineeditor linker lto mc mcdisassembler mcjit mcparser mips mipsasmparser mipsasmprinter mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmprinter msp430codegen msp430desc msp430info native nativecodegen nvptx nvptxasmprinter nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit passes pnacltransforms powerpc powerpcasmparser powerpcasmprinter powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata runtimedyld scalaropts selectiondag sparc sparcasmparser sparcasmprinter sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzasmprinter systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target transformutils vectorize x86 x86asmparser x86asmprinter x86codegen x86desc x86disassembler x86info x86utils" "--llvm-cxxflags" "-I/home/simon/rust/build/x86_64-unknown-linux-gnu/llvm/include -ffunction-sections -fdata-sections -fPIC -m64 -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -O3 -DNDEBUG  -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" "--ar" "ar" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" ""
expected success, got: exit code: 101
@pftbest
Copy link
Contributor

pftbest commented Jan 15, 2018

Please run gcc -v and check if you have --enable-default-pie config option. I think it is the one causing this problem.

@SimonSapin
Copy link
Contributor Author

Yes, the "Configured with" line of gcc -v on Ubuntu contains --enable-default-pie. However I’ll more likely submit PRs with failing tests and deal with it when Travis-CI reports back than recompile GCC.

@pftbest
Copy link
Contributor

pftbest commented Jan 15, 2018

@SimonSapin yes, of course, I didn't mean that you should recompile your gcc, I was just pointing out the root cause for this issue.

This patch fixed the error on my machine:

diff --git a/src/test/run-make/relocation-model/Makefile b/src/test/run-make/relocation-model/Makefile
index 485ecbb4b5..f9213f0af0 100644
--- a/src/test/run-make/relocation-model/Makefile
+++ b/src/test/run-make/relocation-model/Makefile
@@ -4,7 +4,7 @@ all: others
        $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs
        $(call RUN,foo)
 
-       $(RUSTC) -C relocation-model=default foo.rs
+       $(RUSTC) -C relocation-model=default -C link-arg=-no-pie foo.rs
        $(call RUN,foo)
 
        $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj
@@ -14,6 +14,6 @@ ifdef IS_MSVC
 others:
 else
 others:
-       $(RUSTC) -C relocation-model=static foo.rs
+       $(RUSTC) -C relocation-model=static -C link-arg=-no-pie foo.rs
        $(call RUN,foo)
 endif

But such change will not work on macOS and windows so it has to be fixed in some other way.

@SimonSapin
Copy link
Contributor Author

Would it make sense for the makefile to have a RUSTFLAGS variable that’s set conditionally based on the platform?

@pftbest
Copy link
Contributor

pftbest commented Jan 15, 2018

Well, maybe, but I'm not sure how to easily determine if gcc has --enable-default-pie option enabled.

@SimonSapin
Copy link
Contributor Author

Isn’t -no-pie a no-op when PIE is not the default?

@pftbest
Copy link
Contributor

pftbest commented Jan 16, 2018

@SimonSapin I think this option does not exist on gcc versions less than 5.4

@pietroalbini pietroalbini added A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. labels Jan 30, 2018
@SimonSapin
Copy link
Contributor Author

I’ve just discovered that ./x.py test accepts a --no-fail-fast parameter that makes this bug much less of a problem to run the full test suite on Ubuntu.

@SimonSapin
Copy link
Contributor Author

This seems to be fixed now, presumably by #48076. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants