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

linkage weak_extern through generics breaks when -O absent on OS X #54153

Closed
pnkfelix opened this issue Sep 12, 2018 · 5 comments
Closed

linkage weak_extern through generics breaks when -O absent on OS X #54153

pnkfelix opened this issue Sep 12, 2018 · 5 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Sep 12, 2018

I am locally seeing test failures on OS X that seem like #18804 has regressed, or the shuffling of the run-pass to ui/run-pass somehow exposed a new bug there.

---- [ui] ui/run-pass/issues/issue-18804/main.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit code: 1
command: "/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/bin/rustc" "/Users/fklock/Dev/Mozilla/issue53528/rust-53528/src/test/ui/run-pass/issues/issue-18804/main.rs" "--target=x86_64-apple-darwin" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a" "-Crpath" "-Zunstable-options" "-Lnative=/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/auxiliary" "-A" "unused"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
{"message":"linking with `cc` failed: exit code: 1","code":null,"level":"error","spans":[],"children":[{"message":"\"cc\" \"-m64\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.0.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.1.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.2.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.3.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.4.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.5.rcgu.o\" \"-o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a\" \"-Wl,-dead_strip\" \"-nodefaultlibs\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/native/rust-test-helpers\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/auxiliary\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/auxiliary\" \"-llib\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"-lstd-bc4d93c7cd68669e\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-4219949d54044b85.rlib\" \"-lSystem\" \"-lresolv\" \"-lpthread\" \"-lc\" \"-lm\" \"-Wl,-rpath,@loader_path/auxiliary\" \"-Wl,-rpath,@loader_path/../../../../../../stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"-Wl,-rpath,/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/~/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib\"","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"Undefined symbols for architecture x86_64:\n  \"_FOO\", referenced from:\n      __rust_extern_with_linkage_FOO in a.main.7rcbfp3g-cgu.4.rcgu.o\nld: symbol(s) not found for architecture x86_64\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\n","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: linking with `cc` failed: exit code: 1\n   |\n   = note: \"cc\" \"-m64\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.0.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.1.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.2.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.3.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.4.rcgu.o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a.main.7rcbfp3g-cgu.5.rcgu.o\" \"-o\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/a\" \"-Wl,-dead_strip\" \"-nodefaultlibs\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/native/rust-test-helpers\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/auxiliary\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/test/ui/run-pass/issues/issue-18804/main/auxiliary\" \"-llib\" \"-L\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"-lstd-bc4d93c7cd68669e\" \"/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-4219949d54044b85.rlib\" \"-lSystem\" \"-lresolv\" \"-lpthread\" \"-lc\" \"-lm\" \"-Wl,-rpath,@loader_path/auxiliary\" \"-Wl,-rpath,@loader_path/../../../../../../stage1/lib/rustlib/x86_64-apple-darwin/lib\" \"-Wl,-rpath,/Users/fklock/Dev/Mozilla/issue53528/rust-53528/objdir-dbgopt/~/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib\"\n   = note: Undefined symbols for architecture x86_64:\n             \"_FOO\", referenced from:\n                 __rust_extern_with_linkage_FOO in a.main.7rcbfp3g-cgu.4.rcgu.o\n           ld: symbol(s) not found for architecture x86_64\n           clang: error: linker command failed with exit code 1 (use -v to see invocation)\n           \n\n"}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}

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

thread '[ui] ui/run-pass/issues/issue-18804/main.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3196:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    [ui] ui/run-pass/issues/issue-18804/main.rs

I am not certain what is happening yet. After reviewing #18804, I have looked briefly at the generated LLVM IR output for main.rs, and it seems like FOO is being "properly" tagged (see some discussion of the current approach here: #12556):

%"unwind::libunwind::_Unwind_Exception" = type { [0 x i64], i64, [0 x i64], void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [0 x i64], [6 x i64], [0 x i64] }
%"unwind::libunwind::_Unwind_Context" = type { [0 x i8] }

@FOO = extern_weak global {}
@_rust_extern_with_linkage_FOO = internal global {}* @FOO
@pnkfelix
Copy link
Member Author

(Also, it would probably be a good idea to validate the bugs mentioned here #29603 (comment) and here #29603 (comment) and if they are indeed bugs, then we probably should file individual issues for them.)

@pnkfelix pnkfelix added A-linkage Area: linking into static, shared libraries and binaries T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 12, 2018
@pnkfelix
Copy link
Member Author

see also #31508

@pnkfelix
Copy link
Member Author

If I compile the main test with optimization turned on (i.e. rustc -O) the problem goes away

@pnkfelix
Copy link
Member Author

Ah, and the default for optimize-tests is true in the usual config.toml.

So that explains why no one else (namely our continuous integration server) has been running into this on OS X.

@pnkfelix pnkfelix changed the title Issue 18804 (linkage weak_extern through generics) regressing on OS X? Issue 18804 (linkage weak_extern through generics) regressing when -O absent on OS X Sep 14, 2018
@pnkfelix pnkfelix changed the title Issue 18804 (linkage weak_extern through generics) regressing when -O absent on OS X linkage weak_extern through generics breaks when -O absent on OS X Sep 14, 2018
@pnkfelix pnkfelix added C-bug Category: This is a bug. O-macos Operating system: macOS labels Sep 20, 2018
@pnkfelix
Copy link
Member Author

pnkfelix commented Nov 7, 2018

This is an instance of #55757

kennytm added a commit to kennytm/rust that referenced this issue Dec 14, 2018
…mes-requires-optimizations, r=nikic

fix issue 54153 by not testing issue-18804 on Windows nor OS X.

Fix rust-lang#54153
pietroalbini added a commit to pietroalbini/rust that referenced this issue Dec 19, 2018
…mes-requires-optimizations, r=nikic

fix issue 54153 by not testing issue-18804 on Windows nor OS X.

Fix rust-lang#54153
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant