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

Link error in rustc-main: undefined reference to `__floatundisf' #53916

Closed
nnethercote opened this issue Sep 3, 2018 · 9 comments
Closed

Link error in rustc-main: undefined reference to `__floatundisf' #53916

nnethercote opened this issue Sep 3, 2018 · 9 comments

Comments

@nnethercote
Copy link
Contributor

I just updated to 763d91a and when building the compiler I get a link error on rustc-main:

Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling version_check v0.1.4                                               
   Compiling cfg-if v0.1.5
   Compiling nodrop v0.1.12
   Compiling memoffset v0.2.1
   Compiling scopeguard v0.3.3
   Compiling void v1.0.2
   Compiling libc v0.2.43
   Compiling rustc-rayon-core v0.1.1
   Compiling stable_deref_trait v1.1.0
   Compiling byteorder v1.2.3
   Compiling bitflags v1.0.4
   Compiling either v1.5.0
   Compiling unicode-width v0.1.5
   Compiling scoped-tls v0.1.2
   Compiling cc v1.0.22
   Compiling rustc_target v0.0.0 (file:///home/njn/moz/rust1/src/librustc_target)
   Compiling syntax v0.0.0 (file:///home/njn/moz/rust1/src/libsyntax)
   Compiling termcolor v0.3.6
   Compiling rand_core v0.2.1
   Compiling lazy_static v0.2.11
   Compiling rustc-demangle v0.1.9
   Compiling remove_dir_all v0.5.1
   Compiling rustc v0.0.0 (file:///home/njn/moz/rust1/src/librustc)
   Compiling datafrog v0.1.0
   Compiling fmt_macros v0.0.0 (file:///home/njn/moz/rust1/src/libfmt_macros)
   Compiling rustc_fs_util v0.0.0 (file:///home/njn/moz/rust1/src/librustc_fs_util)
   Compiling graphviz v0.0.0 (file:///home/njn/moz/rust1/src/libgraphviz)
   Compiling rustc_metadata v0.0.0 (file:///home/njn/moz/rust1/src/librustc_metadata)
   Compiling rustc_incremental v0.0.0 (file:///home/njn/moz/rust1/src/librustc_incremental)
   Compiling rustc-serialize v0.3.24
   Compiling rustc_platform_intrinsics v0.0.0 (file:///home/njn/moz/rust1/src/librustc_platform_intrinsics)
   Compiling quick-error v1.2.2
   Compiling termcolor v1.0.2
   Compiling rustc_driver v0.0.0 (file:///home/njn/moz/rust1/src/librustc_driver)
   Compiling arrayvec v0.4.7
   Compiling unreachable v1.0.0
   Compiling crossbeam-utils v0.2.2
   Compiling log v0.4.4
   Compiling chalk-macros v0.1.0
   Compiling owning_ref v0.3.3
   Compiling humantime v1.1.1
   Compiling smallvec v0.6.5
   Compiling lazy_static v1.1.0
   Compiling rustc-hash v1.0.1
   Compiling rustc_cratesio_shim v0.0.0 (file:///home/njn/moz/rust1/src/librustc_cratesio_shim)
   Compiling ena v0.9.3
   Compiling serialize v0.0.0 (file:///home/njn/moz/rust1/src/libserialize)
   Compiling polonius-engine v0.5.0
   Compiling rustc_apfloat v0.0.0 (file:///home/njn/moz/rust1/src/librustc_apfloat)
   Compiling chalk-engine v0.7.0
   Compiling num_cpus v1.8.0
   Compiling rand v0.4.3
   Compiling atty v0.2.11
   Compiling rand v0.5.4
   Compiling jobserver v0.1.11
   Compiling crossbeam-epoch v0.3.1
   Compiling log_settings v0.1.2
   Compiling env_logger v0.5.12
   Compiling crossbeam-deque v0.2.0
   Compiling parking_lot_core v0.2.14
   Compiling parking_lot v0.5.5
   Compiling backtrace-sys v0.1.24
   Compiling miniz-sys v0.1.10
   Compiling tempfile v3.0.3
   Compiling rustc-rayon v0.1.1
   Compiling flate2 v1.0.2
   Compiling backtrace v0.3.9
   Compiling rls-span v0.4.0
   Compiling rustc_data_structures v0.0.0 (file:///home/njn/moz/rust1/src/librustc_data_structures)
   Compiling rls-data v0.18.0
   Compiling arena v0.0.0 (file:///home/njn/moz/rust1/src/libarena)
   Compiling syntax_pos v0.0.0 (file:///home/njn/moz/rust1/src/libsyntax_pos)
   Compiling rustc_errors v0.0.0 (file:///home/njn/moz/rust1/src/librustc_errors)
   Compiling proc_macro v0.0.0 (file:///home/njn/moz/rust1/src/libproc_macro)
   Compiling syntax_ext v0.0.0 (file:///home/njn/moz/rust1/src/libsyntax_ext)
   Compiling rustc_metadata_utils v0.0.0 (file:///home/njn/moz/rust1/src/librustc_metadata_utils)
   Compiling rustc_mir v0.0.0 (file:///home/njn/moz/rust1/src/librustc_mir)
   Compiling rustc_typeck v0.0.0 (file:///home/njn/moz/rust1/src/librustc_typeck)
   Compiling rustc_traits v0.0.0 (file:///home/njn/moz/rust1/src/librustc_traits)
   Compiling rustc_allocator v0.0.0 (file:///home/njn/moz/rust1/src/librustc_allocator)
   Compiling rustc_resolve v0.0.0 (file:///home/njn/moz/rust1/src/librustc_resolve)
   Compiling rustc_plugin v0.0.0 (file:///home/njn/moz/rust1/src/librustc_plugin)
   Compiling rustc_privacy v0.0.0 (file:///home/njn/moz/rust1/src/librustc_privacy)
   Compiling rustc_save_analysis v0.0.0 (file:///home/njn/moz/rust1/src/librustc_save_analysis)
   Compiling rustc_lint v0.0.0 (file:///home/njn/moz/rust1/src/librustc_lint)
   Compiling rustc_borrowck v0.0.0 (file:///home/njn/moz/rust1/src/librustc_borrowck)
   Compiling rustc_codegen_utils v0.0.0 (file:///home/njn/moz/rust1/src/librustc_codegen_utils)
   Compiling rustc_passes v0.0.0 (file:///home/njn/moz/rust1/src/librustc_passes)
   Compiling rustc-main v0.0.0 (file:///home/njn/moz/rust1/src/rustc)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_binary-28f89886f0c64dae.rustc_binary0.rcgu.o" "-o" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_binary-28f89886f0c64dae" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_binary-28f89886f0c64dae.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-ee16f6821aef40e9/out" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-52504d5ed57fefc2/out" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_driver-490c048ff54b9a93" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_codegen_utils-3740581f350307fa" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_traits-6465f6e98200a700" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_save_analysis-4d060cea5dcf2998" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_resolve-388483db27fc0cd1" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_incremental-d391c0d774c533b4" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_privacy-76a4ac68dda3f42e" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_typeck-ec65b35f7eb40d9c" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_platform_intrinsics-2e835ba951928190" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_plugin-44c7033156dc49bf" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_metadata-526be4055a895339" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_metadata_utils-c906ffe575b45aa6" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lsyntax_ext-b179f38562a2d398" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_lint-6d56074750519d82" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_passes-a0b8e31400606347" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_borrowck-c2b68476772843c1" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_mir-6b1f07dbc06b744f" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_allocator-51a22fde4b0db5bd" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc-171066954813e178" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-ltest-5ddc8f9584faca79" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lterm-76f8ef2b02a12b3e" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_fs_util-3f97c3ca5071d1e2" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lproc_macro-f7c6fbe761b432aa" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lsyntax-155aeebbdb4c7e8b" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_errors-f882aab6100635ab" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lsyntax_pos-ef45b71e578357b1" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_target-2d6cba9c2df54bd6" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lfmt_macros-2ce739823c85fd99" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lgraphviz-45ae4394366d07fd" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-larena-4ee92b74dcb65ca6" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_data_structures-61336079186baa43" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_cratesio_shim-b41313cb9de684df" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lserialize-8d84add221c0f710" "-Wl,--start-group" "-L" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-bd7ba1c2aaa31ca8" "-Wl,--end-group" "-Wl,-Bstatic" "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-02d8b7c22d5a49ce.rlib" "-Wl,-Bdynamic" "-lutil" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_driver-490c048ff54b9a93.so: undefined reference to `__floatundisf'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `rustc-main`.

Caused by:
  process didn't exit successfully: `/home/njn/moz/rust1/build/bootstrap/debug/rustc --crate-name rustc_binary rustc/rustc.rs --error-format json --crate-type bin --emit=dep-info,link -C opt-level=2 -C metadata=28f89886f0c64dae -C extra-filename=-28f89886f0c64dae --out-dir /home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern rustc_driver=/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_driver-490c048ff54b9a93.so --extern rustc_target=/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-2d6cba9c2df54bd6.so -L native=/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-ee16f6821aef40e9/out -L native=/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-52504d5ed57fefc2/out` (exit code: 1)
command did not execute successfully: "/home/njn/moz/rust1/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "28" "--release" "--features" "" "--manifest-path" "/home/njn/moz/rust1/src/rustc/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101
thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1155:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failed to run: /home/njn/moz/rust1/build/bootstrap/debug/bootstrap build --stage 2 src/rustc
Build completed unsuccessfully in 0:14:33

This is on my Ubuntu 18.04 box, which is pretty ordinary and doesn't have anything special about it.

@nnethercote nnethercote changed the title Link error in rustc-main due to "undefined reference to `__floatundisf'" Link error in rustc-main: undefined reference to `__floatundisf' Sep 3, 2018
@nnethercote
Copy link
Contributor Author

When I compile a fresh clone with this config.toml, it works:

[rust]
codegen-units = 20
debuginfo = true
debuginfo-lines = true

It does an LLVM compile and install while doing this.

When I compile a fresh clone with this config.toml, I get the link error:

[llvm]
optimize = true
release-debuginfo = true
assertions = false
[rust]
optimize = true
codegen-units = 1
debug-assertions = false
debuginfo = true
debuginfo-lines = true
use-jemalloc = false

It doesn't do an LLVM compile and install.

@nnethercote
Copy link
Contributor Author

To clarify, the problem doesn't occur when I do this:

./x.py build --stage 1 src/libtest

But it does happen when I do this:

./x.py build --stage 2 src/rustc

@alexcrichton
Copy link
Member

I think this line may be incorrect. That says that on non-windows x86_64 we should use a C shim but we fail to compile the C shim!

I believe this was a bug introduced in rust-lang/compiler-builtins#252

cc @dingelish

@alexcrichton
Copy link
Member

@nnethercote I think I've fixed this on the master branch of compiler-builtins, can you try updating the src/libcompiler_builtins submodule and see if it fixes the issue for you? If so I can send a PR to update it.

@nnethercote
Copy link
Contributor Author

@alexcrichton: I did the following:

cd src/libcompiler_builtins
git co master
git pull
cd ../..

With this, the submodule is on tip and I have your C shim patch. But then when I build with ./x.py build --stage 2 src/rustc, it starts with this:

Updating only changed submodules
Updating submodule src/libcompiler_builtins
Submodule path 'src/libcompiler_builtins': checked out 'f3a13eb2384c7cbb91b6db5b008377e9710d434c'
Submodules updated in 0.29 seconds

which takes me back to the original libcompiler_builtins revision and the link error (unsurprisingly) still occurs. How can I preserve the libcompiler_builtins revision?

@nnethercote
Copy link
Contributor Author

rkruppe told me on IRC to set submodules = false in config.toml. With that in place, it compiles again!

@oli-obk
Copy link
Contributor

oli-obk commented Sep 5, 2018

I've been bitten by this before when I created a new checkout of rustc. This setting completely overwrites any changes, even uncommited ones.

Maybe we can change the default to false?

@alexcrichton
Copy link
Member

@oli-obk perhaps, but we should discuss that its own issue rather than here most likely

alexcrichton added a commit to alexcrichton/rust that referenced this issue Sep 5, 2018
Fixes a mistake in using C shims to...

Closes rust-lang#53916
@alexcrichton
Copy link
Member

I've opened #53969 to fix this

bors added a commit that referenced this issue Sep 7, 2018
…atsakis

Update the compiler-builtins submodule

Fixes a mistake in using C shims to...

Closes #53916
kennytm added a commit to kennytm/rust that referenced this issue Sep 8, 2018
…komatsakis

Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.

It now does one hash table lookup per basic block, instead of one per
statement. This is worthwhile because this function is hot for NLL
builds of `ucd`.

I haven't measured the effect of this yet because I'm having trouble doing optimized builds of rustc that are suitable for profiling (rust-lang#53916). I will do an online perf run instead.

r? @nikomatsakis
kennytm added a commit to kennytm/rust that referenced this issue Sep 8, 2018
…komatsakis

Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.

It now does one hash table lookup per basic block, instead of one per
statement. This is worthwhile because this function is hot for NLL
builds of `ucd`.

I haven't measured the effect of this yet because I'm having trouble doing optimized builds of rustc that are suitable for profiling (rust-lang#53916). I will do an online perf run instead.

r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants