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

Fix #[linkage] propagation though generic functions #52635

Merged
merged 5 commits into from
Jul 26, 2018

Conversation

yodaldevoid
Copy link
Contributor

Fixes #18804

In the non-local branch of get_static (where the fix was implemented) span_fatal had to be replaced with bug! as we have no span in that case.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2018

let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(def_id);
let llty = cx.layout_of(ty).llvm_type(cx);
let g = if let Some(linkage) = codegen_fn_attrs.linkage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pull this code out into a function so it isn't duplicated?

@oli-obk
Copy link
Contributor

oli-obk commented Jul 23, 2018

@bors r+

thanks!

@bors
Copy link
Contributor

bors commented Jul 23, 2018

📌 Commit 7e6f2f660edf9d3abade64e0b76904ff77d5952c has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2018
@bors
Copy link
Contributor

bors commented Jul 24, 2018

⌛ Testing commit 7e6f2f660edf9d3abade64e0b76904ff77d5952c with merge 9134499fb5d75da87f2c76cb7ab3d7d32089791f...

@bors
Copy link
Contributor

bors commented Jul 24, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 24, 2018
@rust-highfive
Copy link
Collaborator

The job asmjs of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:34:52] ---- [run-pass] run-pass/issue-18804/main.rs stdout ----
[01:34:52] 
[01:34:52] error: compilation failed!
[01:34:52] status: exit code: 1
[01:34:52] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/issue-18804/main.rs" "--target=asmjs-unknown-emscripten" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.js" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/asmjs-unknown-emscripten/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/auxiliary"
[01:34:52] ------------------------------------------
[01:34:52] 
[01:34:52] ------------------------------------------
[01:34:52] stderr:
[01:34:52] stderr:
[01:34:52] ------------------------------------------
[01:34:52] error: linking with `emcc` failed: exit code: 1
[01:34:52]   |
[01:34:52]   = note: "emcc" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.main0.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.main1.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.main2.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.main3.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.main4.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.main5.rcgu.o" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.js" "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"_rust_eh_personality\"]" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/a.crate.allocator.rcgu.o" "-O0" "--memory-init-file" "0" "-g0" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "/checkout/obj/build/asmjs-unknown-emscripten/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/auxiliary" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-18804/main/auxiliary/liblib.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libstd-4fddd6730dd7c9d0.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libpanic_unwind-9fa99c4cae3524ff.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libunwind-1bb7fbecd91a9b8e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc_system-b1a900f34d61265a.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liblibc-550b52f6b124054b.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/liballoc-6637a78bd3b23d81.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcore-0aa862bb1e920029.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib/libcompiler_builtins-57285b4d1f8ecbdf.rlib" "-l" "c" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1" "-s" "ABORTING_MALLOC=0" "-s" "WASM=0"
[01:34:52]   = note: error: unresolved symbol: FOO
[01:34:52]           Aborting compilation due to previous errors | undefined
[01:34:52]           Traceback (most recent call last):
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13//emcc", line 13, in <module>
[01:34:52]               emcc.run()
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/emcc.py", line 1526, in run
[01:34:52]               final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/tools/shared.py", line 1963, in emscripten
[01:34:52]               call_emscripten(cmdline)
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/emscripten.py", line 2190, in _main
[01:34:52]               temp_files.run_and_clean(lambda: main(
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/tools/tempfiles.py", line 78, in run_and_clean
[01:34:52]               return func()
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/emscripten.py", line 2195, in <lambda>
[01:34:52]               DEBUG=DEBUG,
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/emscripten.py", line 2095, in main
[01:34:52]               temp_files=temp_files, DEBUG=DEBUG)
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/emscripten.py", line 98, in emscript
[01:34:52]               glue, forwarded_data = compiler_glue(metadata, settings, libraries, compiler_engine, temp_files, DEBUG)
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/emscripten.py", line 219, in compiler_glue
[01:34:52]               glue, forwarded_data = compile_settings(compiler_engine, settings, libraries, temp_files)
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/emscripten.py", line 531, in compile_settings
[01:34:52]               cwd=path_from_root('src'), error_limit=300)
[01:34:52]             File "/emsdk-portable/emscripten/1.37.13/tools/jsrun.py", line 128, in run_js
[01:34:52]               raise Exception('Expected the command ' + str(command) + ' to finish with return code ' + str(assert_returncode) + ', but it returned with code ' + str(proc.returncode) + ' instead! Output: ' + str(ret)[:error_limit])
[01:34:52]           Exception: Expected the command ['/emsdk-portable/node/4.1.1_64bit/bin/node', '/emsdk-portable/emscripten/1.37.13/src/compiler.js', '/tmp/tmpADDGoj.txt', '/emsdk-portable/emscripten/1.37.13/src/library_pthread_stub.js'] to finish with return code 0, but it returned with code 1 instead! Output: // The Module object: Our interface to the outside world. We import
[01:34:52]           // and export values on it, and do the work to get that through
[01:34:52]           // closure compiler if necessary. There are various ways Module can be used:
[01:34:52]           // 1. Not defined. We create it here
[01:34:52]           // 2. A function parameter, function(Module) { ..gener
[01:34:52] 
[01:34:52] error: aborting due to previous error
[01:34:52] 
[01:34:52] 
---
[01:34:52] 
[01:34:52] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[01:34:52] 
[01:34:52] 
[01:34:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/asmjs-unknown-emscripten/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-asmjs-unknown-emscripten" "--mode" "run-pass" "--target" "asmjs-unknown-emscripten" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--nodejs" "/emsdk-portable/node/4.1.1_64bit/bin/node" "--host-rustcflags" "-Crpath -Zunstable-options " "--target-rustcflags" "-Crpath -Zunstable-options  -Lnative=/checkout/obj/build/asmjs-unknown-emscripten/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "7.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:34:52] 
[01:34:52] 
[01:34:52] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target asmjs-unknown-emscripten src/test/run-pass src/test/run-fail src/libstd src/liballoc src/libcore
[01:34:52] Build completed unsuccessfully in 1:30:39
---
travis_time:end:14b721a9:start=1532420570007858860,finish=1532420570014857062,duration=6998202
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0d094c24
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1b89101e
travis_time:start:1b89101e
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:10f828b0
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@yodaldevoid
Copy link
Contributor Author

yodaldevoid commented Jul 24, 2018

After doing some digging, it looks like Emscripten doesn't "currently support nuances like weak symbols". reference

Should I simply disable this test for Emscripten?

@oli-obk

@kennytm kennytm added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 24, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Jul 24, 2018

Should I simply disable this test for Emscripten?

yes. Maybe also disable for wasm? Not sure if that can cope with it?

@yodaldevoid
Copy link
Contributor Author

Maybe also disable for wasm?

Looking at the homu log it seems wasm succeeded which I was not expecting when seeing this failure. Looking at it closer it seems that might be because it is building with wasm-unknown-unknown rather than wasm-unknown-emscripten.

Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
Fixes issue rust-lang#18804

Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
…smjs

The Emscripten compiler does not support weak symbols at the moment.

Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
@yodaldevoid
Copy link
Contributor Author

@oli-obk Everything is rebased to be able to merge and should be ready to go.

// Test for issue #18804, #[linkage] does not propagate thorugh generic
// functions. Failure results in a linker error.

// aux-build:lib.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this file also need the //ignore-* comments? Or is compiletest smart enough to figure out that if an aux-build isn't built we also shouldn't run the test depending on it?

r=me with that question resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. I put the comments in the wrong file while not thinking. The main test file needs the comments while the auxiliary file does not.

Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
@oli-obk
Copy link
Contributor

oli-obk commented Jul 25, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Jul 25, 2018

📌 Commit be5b668 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Jul 25, 2018

Thanks! I didn't know the aux files don't need the comments, but it kinda makes sense. They are only compiled if a file referencing them is compiled.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jul 26, 2018
Fix #[linkage] propagation though generic functions

Fixes rust-lang#18804

In the non-local branch of `get_static` (where the fix was implemented) `span_fatal` had to be replaced with `bug!` as we have no span in that case.
bors added a commit that referenced this pull request Jul 26, 2018
Rollup of 16 pull requests

Successful merges:

 - #52558 (Add tests for ICEs which no longer repro)
 - #52610 (Clarify what a task is)
 - #52617 (Don't match on region kinds when reporting NLL errors)
 - #52635 (Fix #[linkage] propagation though generic functions)
 - #52647 (Suggest to take and ignore args while closure args count mismatching)
 - #52649 (Point spans to inner elements of format strings)
 - #52654 (Format linker args in a way that works for gcc and ld)
 - #52667 (update the stdsimd submodule)
 - #52674 (Impl Executor for Box<E: Executor>)
 - #52690 (ARM: expose `rclass` and `dsp` target features)
 - #52692 (Improve readability in a few sorts)
 - #52695 (Hide some lints which are not quite right the way they are reported to the user)
 - #52718 (State default capacity for BufReader/BufWriter)
 - #52721 (std::ops::Try impl for std::task::Poll)
 - #52723 (rustc: Register crates under their real names)
 - #52734 (sparc ABI issue - structure returning from function is returned in 64bit registers (with tests))

Failed merges:

 - #52678 ([NLL] Use better spans in some errors)

r? @ghost
@bors bors merged commit be5b668 into rust-lang:master Jul 26, 2018
@yodaldevoid yodaldevoid deleted the issue_18804 branch August 22, 2018 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[linkage] does not propagate through generic functions
6 participants