Closed Bug 1418598 Opened 2 years ago Closed 2 years ago

linking with `.../cargo-linker` failed: exit code 1

Categories

(Firefox Build System :: General, defect)

defect
Not set

Tracking

(firefox59 fixed)

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: glandium, Assigned: glandium)

References

Details

Attachments

(1 file)

error: linking with `/<<PKGBUILDDIR>>/build/cargo-linker` failed: exit code: 1
  |
  = note: "/<<PKGBUILDDIR>>/build/cargo-linker" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/<<PKGBUILDDIR>>/build-browser/toolkit/library/release/build/libloading-4e3fd6847ce5ece7/build_script_build-4e3fd6847ce5ece7.0.o" "-o" "/<<PKGBUILDDIR>>/build-browser/toolkit/library/release/build/libloading-4e3fd6847ce5ece7/build_script_build-4e3fd6847ce5ece7" "/<<PKGBUILDDIR>>/build-browser/toolkit/library/release/build/libloading-4e3fd6847ce5ece7/build_script_build-4e3fd6847ce5ece7.crate.allocator.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-L" "/<<PKGBUILDDIR>>/build-browser/toolkit/library/release/deps" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-93d5378bceaf3688.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-5c3db1423b91616a.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-c81546f616bee1cb.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-5b1e62694efc0852.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8fd871d342558b7c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-24d077784ff294bb.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-99d160586f71fd24.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-01818c88b0095d9d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-a607da81e1566936.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-48849975bde268ae.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util"
  = note: gcc: error: '-Wl,-rpath-link,/<<PKGBUILDDIR>>/build-browser/dist/bin': No such file or directory
          

error: aborting due to previous error

where <<PKGBUILDDIR>> is /build/firefox-58.0~b4.

This is kind of related to bug 1418596, because of the ~ being badly handled, but if there was an actual need to quoting in one of the LDFLAGS, a failure would happen similarly.

The problem is that cargo is called as follows:

env   RUSTFLAGS='-C opt-level=2 -C debuginfo=2 '  CARGO_TARGET_DIR=/<<PKGBUILDDIR>>/build-browser/toolki
t/library RUSTC=/usr/bin/rustc MOZ_SRC=/<<PKGBUILDDIR>> MOZ_DIST=/<<PKGBUILDDIR>>/build-browser/dist LIB
CLANG_PATH="/usr/lib/llvm-4.0/lib" CLANG_PATH="/usr/lib/llvm-4.0/bin/clang" PKG_CONFIG_ALLOW_CROSS=1 RUS
T_BACKTRACE=full MOZ_TOPOBJDIR=/<<PKGBUILDDIR>>/build-browser MOZ_CARGO_WRAP_LDFLAGS="-lpthread -Wl,--as
-needed -Wl,--reduce-memory-overheads -Wl,--no-keep-memory -Wl,--stats -Wl,-z,noexecstack -Wl,-z,text -W
l,-z,relro -Wl,--build-id '-Wl,-rpath-link,/<<PKGBUILDDIR>>/build-browser/dist/bin' -Wl,-rpath-link,/usr
/lib" MOZ_CARGO_WRAP_LD=" /usr/bin/gcc -std=gnu99" CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/<<PKGBU
ILDDIR>>/build/cargo-linker /usr/bin/cargo rustc  --release --frozen --manifest-path /<<PKGBUILDDIR>>/to
olkit/library/rust/Cargo.toml --lib --target=x86_64-unknown-linux-gnu --features "servo bindgen cubeb_pu
lse_rust cubeb-remoting no-static-ideograph-encoder-tables" --  -C lto

Note how one of the strings in MOZ_CARGO_WRAP_LDFLAGS is single quoted inside the double quotes. This is because something is being shellutil.quote'd at some point, which is about right, but the problem is that cargo-linker can't deal with that. Or worse, maybe cargo is further quoting it or something. I'm not sure.
A small testcase is:

MOZ_CARGO_WRAP_LD=touch MOZ_CARGO_WRAP_LDFLAGS="'foo bar' baz" ./build/cargo-linker 'qux hoge' fuga

This should create the files "foo bar", "baz", "qux hoge" and "fuga", but it creates "'foo", "bar'", "baz", "qux hoge" and "fuga".
Assignee: nobody → mh+mozilla
Comment on attachment 8929712 [details]
Bug 1418598 - Make cargo-linker properly handle quoted strings in MOZ_CARGO_WRAP_LD and MOZ_CARGO_WRAP_LDFLAGS.

https://reviewboard.mozilla.org/r/200996/#review206412

I sure do love shell scripts!
Attachment #8929712 - Flags: review+
Attachment #8929712 - Flags: review?(core-build-config-reviews)
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/69465fa861e1
Make cargo-linker properly handle quoted strings in MOZ_CARGO_WRAP_LD and MOZ_CARGO_WRAP_LDFLAGS. r=ted
https://hg.mozilla.org/mozilla-central/rev/69465fa861e1
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.