xargo icon indicating copy to clipboard operation
xargo copied to clipboard

compiler_builtins & compiler_builtins_shim leading multiple matching crates

Open jparris opened this issue 6 years ago • 21 comments

Hi there,

I'm having problems compiling compiler_builtins under xargo. I'm pretty sure it's because compiler_builtins_shim is being compiled under the name compiler_builtins.

Xargo build

gerd:munin$ rm -rf ~/.xargo/
gerd:munin$ cargo clean
gerd:munin$ RUST_TARGET_PATH=`pwd` xargo build --target=x86_64-uefi
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling cc v1.0.15
   Compiling core v0.0.0 (file:///home/parrisj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling compiler_builtins v0.0.0 (file:///home/parrisj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/rustc/compiler_builtins_shim)
   Compiling alloc v0.0.0 (file:///home/parrisj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc)
    Finished release [optimized] target(s) in 55.91s
    Finished release [optimized] target(s) in 0.01s
   Compiling compiler_builtins v0.1.0 (file:///home/parrisj/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcompiler_builtins)
    Finished release [optimized] target(s) in 3.74s
   Compiling uefi v0.1.0 (file:///home/parrisj/src/munin)
error[E0464]: multiple matching crates for `compiler_builtins`
  |
  = note: candidates:
          crate `compiler_builtins`: /home/parrisj/.xargo/lib/rustlib/x86_64-uefi/lib/libcompiler_builtins-c9c3a92f88e65908.rlib
          crate `compiler_builtins`: /home/parrisj/.xargo/lib/rustlib/x86_64-uefi/lib/libcompiler_builtins-434f0f90969062e4.rlib

error[E0463]: can't find crate for `compiler_builtins`

error: aborting due to 2 previous errors

Some errors occurred: E0463, E0464.
For more information about an error, try `rustc --explain E0463`.
error: Could not compile `uefi`.

To learn more, run the command again with --verbose.

Target

gerd:munin$ cat x86_64-uefi.json 
{
  "llvm-target": "x86_64-pc-windows-msvc",
  "target-endian": "little",
  "target-pointer-width": "64",
  "target-c-int-width": "32",
  "os": "uefi",
  "arch": "x86_64",
  "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
  "linker-flavor": "lld-link",
  "pre-link-args": {
    "lld-link": [
      "/Subsystem:EFI_Application",
      "/Entry:efi_main"
    ]
  },
  "panic-strategy": "abort",
  "default-hidden-visibility": true,
  "executables": true,
  "exe-suffix": ".efi",
  "is-like-windows": true
}

Cargo

gerd:munin$ cat Cargo.toml
[package]
name = "uefi"
version = "0.1.0"
authors = ["jon parris <[email protected]>"]

[lib]
name = "libuefi"
path = "uefi-lib/lib.rs"

[[bin]]
name = "uefi-app"
path = "uefi-test/src/main.rs"

[dependencies]
rlibc = "1.0"

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

Xargo

gerd:munin$ cat Xargo.toml 
[dependencies]
alloc = {}

[dependencies.core]
stage = 0

[dependencies.compiler_builtins]
features = ["mem"]
stage = 1

Version info

gerd:munin$ xargo -V
xargo 0.3.12
cargo 1.27.0-nightly (af3f1cd29 2018-05-03)
gerd:munin$ rustc -V
rustc 1.27.0-nightly (428ea5f6b 2018-05-06)

jparris avatar May 07 '18 17:05 jparris

I had the same problem: https://github.com/japaric/xargo/issues/214. Maybe rust-osdev/cargo-xbuild works for you too?

phil-opp avatar May 07 '18 17:05 phil-opp

Hi Phill,

First off your blog-os posts are what inspired me to get back into hobby os dev :)

Second get a different error now. My guess is this one is lld/rustc.

erd:munin$ cargo xbuild --target=x86_64-uefi.json 
   Compiling uefi v0.1.0 (file:///home/parrisj/src/munin)
error: linking with `lld` failed: exit code: 1
  |
  = note: "lld" "-flavor" "link" "/Subsystem:EFI_Application" "/Entry:efi_main" "/LIBPATH:/home/parrisj/src/munin/target/sysroot/lib/rustlib/x86_64-uefi/lib" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.13tprap6axy2fph1.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.16i0u6jlhoj1fwbo.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.16u6js6g0l3k1ic6.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.181cuta0v63atwcm.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.1dqvxks6k2bzkxe.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.1im38lueib99jsk0.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.1k8yxj9ch5v8ha2r.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.1y16o1qfye96o7m0.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.23tqyymcb18u96mb.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.2670nmqs1be3ww7y.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.2jqywn86b2gsqohu.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.2lyh15q6cjwzy18c.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.2q5257pdh5222n7q.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.3ayaeypdcro9d6yk.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.3wta9ctgdrpkmlpr.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.436dotimmrgzkwfa.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.43v6g0y2xsxoggnt.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.48721dc4k5qxei0u.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.49a7n47po4ttqjl7.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.49lx1q7cxvpykyv0.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.4ezmh1vbs95c5ack.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.4xq48u46a1pwiqn7.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.4yh8x2b62dcih00t.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.4ypvbwho0bu5tnww.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.51s1w397y42gpez1.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.56dly8q07ws8ucdq.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.5by9xggibmun5kn9.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.7p53qlves2rwxx0.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.81jpvh8cn5k8ng8.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.8xzrsc1ux72v29j.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.98g0d9x8aw3akpe.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.9elsx31vb4it187.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.9fcb3syd3ne5k0n.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.c6lbtaiefvx3wya.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.y08g5q2x813c4wx.rcgu.o" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.z9ox7biyn1otfln.rcgu.o" "/OUT:/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.efi" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.crate.allocator.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/LIBPATH:/home/parrisj/src/munin/target/x86_64-uefi/debug/deps" "/LIBPATH:/home/parrisj/src/munin/target/debug/deps" "/LIBPATH:/home/parrisj/src/munin/target/sysroot/lib/rustlib/x86_64-uefi/lib" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/liblibuefi-963672a5d097b683.rlib" "/home/parrisj/src/munin/target/x86_64-uefi/debug/deps/librlibc-dcf3d743c1c29fe7.rlib" "/home/parrisj/src/munin/target/sysroot/lib/rustlib/x86_64-uefi/lib/liballoc-5dc7f5ee1e3ef031.rlib" "/home/parrisj/src/munin/target/sysroot/lib/rustlib/x86_64-uefi/lib/libcore-526ed719c5f70ea6.rlib" "/home/parrisj/src/munin/target/sysroot/lib/rustlib/x86_64-uefi/lib/libcompiler_builtins-1dc6838bee7f1406.rlib"
  = note: lld: error: duplicate symbol: __rustc_debug_gdb_scripts_section__ in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.13tprap6axy2fph1.rcgu.o and in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.16i0u6jlhoj1fwbo.rcgu.o
          lld: error: duplicate symbol: __rustc_debug_gdb_scripts_section__ in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.13tprap6axy2fph1.rcgu.o and in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.16u6js6g0l3k1ic6.rcgu.o
          lld: error: duplicate symbol: __rustc_debug_gdb_scripts_section__ in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.13tprap6axy2fph1.rcgu.o and in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.181cuta0v63atwcm.rcgu.o
          lld: error: duplicate symbol: __rustc_debug_gdb_scripts_section__ in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.13tprap6axy2fph1.rcgu.o and in /home/parrisj/src/munin/target/x86_64-uefi/debug/deps/uefi_app-ddfa3c03e1d705d9.1dqvxks6k2bzkxe.rcgu.o
...

jparris avatar May 07 '18 18:05 jparris

Okay after some googling adding --release the cargo xbuild command gets me over the duplicate symbol issue. Although I'd still like to get to the bottom of it.

jparris avatar May 07 '18 18:05 jparris

Did you try cargo clean with the debug build?

robert-w-gries avatar May 07 '18 18:05 robert-w-gries

Hi @robert-w-gries,

Yes I ran both a cargo clean and a rm -r ~/.xargo before my xargo build.

-Jon

jparris avatar May 07 '18 18:05 jparris

First off your blog-os posts are what inspired me to get back into hobby os dev :)

Great to hear! :)

Hmm, I've never seen this error before. Do you have your code online somewhere so that I can test?

phil-opp avatar May 07 '18 20:05 phil-opp

@phil-opp I've added you to my private gitlab repo.

jparris avatar May 07 '18 20:05 jparris

@jparris Thanks! I cloned your repo and ran make run. It compiles without errors for me on the latest nightly.

phil-opp avatar May 07 '18 20:05 phil-opp

@phil-opp sorry I should have warned you make uses xbuild with the --releases flag. if you want to reproduce the duplicate symbol: __rustc_debug_gdb_scripts_section__ you need to run cargo xbuild --target=x86_64-uefi.json. To reproduce the multiple compiler_builtins issue copy the contents of Xargo section in the initial comment into Xargo.toml and then run RUST_TARGET_PATH=$(pwd) xargo build --target x86_64-uefi

jparris avatar May 07 '18 21:05 jparris

@jparris Ah, makes sense! Without --release I'm getting the same duplicate symbol error. I try to look into it tomorrow.

phil-opp avatar May 07 '18 21:05 phil-opp

@jparris I think this has something to do with uefi or the windows-like build. I tried to compile the uefi-app-x64 project of @toothbrush7777777, which has different code and a different target specification file. It throws the same error when compiling without --release. The error occurs with both xargo and cargo-xbuild and with both nightly-2018-05-07 and the 2 months old nightly-2018-03-07.

@toothbrush7777777 Have you experienced this error too?

phil-opp avatar May 08 '18 11:05 phil-opp

@phil-opp No, but I haven't compiled uefi-app-x64 in debug mode since I pushed it online. I'm pretty sure that the project compiled without --release on the latest nightly Rust compiler at that time on Windows (the second or third nightly after lld was included in the Rust distribution). I didn't try compiling on Ubuntu without --release. I always compile with --release and include the debug information.

I can't compile anything at the moment. Could you post what comes up when running RUST_TARGET_PATH=$PWD xargo rustc --release --target uefi-app-x64 -- -Z print-link-args?

toothbrush7777777 avatar May 08 '18 12:05 toothbrush7777777

@toothbrush7777777 I tried all nightlies between the LLD inclusion and the latest commit to the src folder in your repo:

  • nightly-2018-03-06
  • nightly-2018-03-07
  • nightly-2018-03-15
  • nightly-2018-03-16

They all throw the same error.

phil-opp avatar May 08 '18 12:05 phil-opp

I think we should open an Rust issue about this, since the duplicate symbol seems Rust-related: __rustc_debug_gdb_scripts_section__.

phil-opp avatar May 08 '18 13:05 phil-opp

@phil-opp That sounds like a good idea. It seems like there is a (newish) related setting in target files: emit-debug-gdb-scripts. Would you trying setting it to false and building again? Either way, it does seem to be a bug.

toothbrush7777777 avatar May 08 '18 16:05 toothbrush7777777

@toothbrush7777777 No effect, still the same error.

phil-opp avatar May 08 '18 17:05 phil-opp

I have the same problem, cleaning & rm -rf ~/.xargo doesn't help.

elichai avatar May 29 '18 09:05 elichai

any updates?

dvc94ch avatar Jul 24 '18 15:07 dvc94ch

@dvc94ch I think they stopped maintaining this in light of: https://github.com/rust-lang/cargo/issues/4959

elichai avatar Jul 24 '18 15:07 elichai

does that work already on nightly?

dvc94ch avatar Jul 24 '18 15:07 dvc94ch

@dvc94ch I've opened https://github.com/rust-lang/rust/issues/52909 to get to the bottom of the duplicate gdb symbols.

jparris avatar Jul 31 '18 15:07 jparris