Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisMacNaughton/a81233e05995013ebb9a0c333c157b76 to your computer and use it in GitHub Desktop.
Save ChrisMacNaughton/a81233e05995013ebb9a0c333c157b76 to your computer and use it in GitHub Desktop.
$ echo $LDFLAGS
-Wl,--dynamic-linker=/snap/core/current/lib/x86_64-linux-gnu/ld-2.23.so -Wl,-rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64-linux-gnu:/snap/scratch/current/usr/lib/x86_64-linux-gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64-linux-gnu:/snap/core/current/usr/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/snap/core/current/lib/x86_64-linux-gnu/ld-2.23.so -Wl,-rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64-linux-gnu:/snap/scratch/current/usr/lib/x86_64-linux-gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64-linux-gnu:/snap/core/current/usr/lib/x86_64-linux-gnu
$ echo $RUSTFLAGS
-C link-args="$(LDFLAGS)"
$ cargo build
Compiling scratch v0.1.0 (file:///mnt/media/projects/scratch/rust)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/mnt/media/projects/scratch/rust/target/debug/deps/scratch-85ab77155f4a4a57.0.o" "-o" "/mnt/media/projects/scratch/rust/target/debug/deps/scratch-85ab77155f4a4a57" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/mnt/media/projects/scratch/rust/target/debug/deps" "-L" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-13f36e2630c2d79b.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-a2ef7979b4b3e1d5.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-d22754c8c52de3a1.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-1cc5fcd37568ebc4.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-3b9d178f1de89528.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-93bb403c9fc56f72.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-c53f99154bf815c4.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-f1bb04f5989dcb98.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-739908a2e215dd88.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-3f4289353c600297.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-07bfb3bcb2a51da0.rlib" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "\"$(LDFLAGS)\""
= note: cc: error: "$(LDFLAGS)": No such file or directory
error: aborting due to previous error
error: Could not compile `scratch`.
To learn more, run the command again with --verbose.
$ # If we test the cc command with $LDFLAGS bare instead though, it works::
$ cc -Wl,--as-needed -Wl,-z,noexecstack -m64 -L /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib /mnt/media/projects/scratch/rust/target/debug/deps/scratch-85ab77155f4a4a57.0.o -o /mnt/media/projects/scratch/rust/target/debug/deps/scratch-85ab77155f4a4a57 -Wl,--gc-sections -pie -nodefaultlibs -L /mnt/media/projects/scratch/rust/target/debug/deps -L /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib -Wl,-Bstatic -Wl,-Bdynamic /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-13f36e2630c2d79b.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-a2ef7979b4b3e1d5.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-d22754c8c52de3a1.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-1cc5fcd37568ebc4.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-3b9d178f1de89528.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-93bb403c9fc56f72.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-c53f99154bf815c4.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-f1bb04f5989dcb98.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-739908a2e215dd88.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-3f4289353c600297.rlib /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-07bfb3bcb2a51da0.rlib -l dl -l rt -l pthread -l gcc_s -l pthread -l c -l m -l rt -l util $LDFLAGS
$ echo $?
0
$ # but fails when we set it bars with RUSTFLAGS:
$ echo $RUSTFLAGS
-C link-args=$LDFLAGS
$ cargo run
Compiling scratch v0.1.0 (file:///mnt/media/projects/scratch/rust)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/mnt/media/projects/scratch/rust/target/debug/deps/scratch-85ab77155f4a4a57.0.o" "-o" "/mnt/media/projects/scratch/rust/target/debug/deps/scratch-85ab77155f4a4a57" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/mnt/media/projects/scratch/rust/target/debug/deps" "-L" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-13f36e2630c2d79b.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-a2ef7979b4b3e1d5.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-d22754c8c52de3a1.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-1cc5fcd37568ebc4.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-3b9d178f1de89528.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-93bb403c9fc56f72.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-c53f99154bf815c4.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-f1bb04f5989dcb98.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-739908a2e215dd88.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-3f4289353c600297.rlib" "/home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-07bfb3bcb2a51da0.rlib" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "$LDFLAGS"
= note: cc: error: $LDFLAGS: No such file or directory
error: aborting due to previous error
error: Could not compile `scratch`.
To learn more, run the command again with --verbose.
@ChrisMacNaughton
Copy link
Author

$ echo $RUSTFLAGS
-C link-args= -Wl,--dynamic-linker=/snap/core/current/lib/x86_64-linux-gnu/ld-2.23.so -Wl,-rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64-linux-gnu:/snap/scratch/current/usr/lib/x86_64-linux-gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64-linux-gnu:/snap/core/current/usr/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/snap/core/current/lib/x86_64-linux-gnu/ld-2.23.so -Wl,-rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64-linux-gnu:/snap/scratch/current/usr/lib/x86_64-linux-gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64-linux-gnu:/snap/core/current/usr/lib/x86_64-linux-gnu

$ cargo build
Compiling scratch v0.1.0 (file:///mnt/media/projects/scratch/rust)
error: unknown lint: l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so
|
= note: requested on the command line with -W l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so

error: unknown lint: l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu
|
= note: requested on the command line with -W l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu

error: unknown lint: l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so
|
= note: requested on the command line with -W l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so

error: unknown lint: l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu
|
= note: requested on the command line with -W l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu

error: aborting due to 4 previous errors

error: Could not compile scratch.

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

@ChrisMacNaughton
Copy link
Author

With quotes on link-args:

$ echo $RUSTFLAGS
-C link-args=' -Wl,--dynamic-linker=/snap/core/current/lib/x86_64-linux-gnu/ld-2.23.so -Wl,-rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64-linux-gnu:/snap/scratch/current/usr/lib/x86_64-linux-gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64-linux-gnu:/snap/core/current/usr/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/snap/core/current/lib/x86_64-linux-gnu/ld-2.23.so -Wl,-rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64-linux-gnu:/snap/scratch/current/usr/lib/x86_64-linux-gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64-linux-gnu:/snap/core/current/usr/lib/x86_64-linux-gnu'

$ cargo build
Compiling scratch v0.1.0 (file:///mnt/media/projects/scratch/rust)
error: unknown lint: l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so
|
= note: requested on the command line with -W l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so

error: unknown lint: l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu
|
= note: requested on the command line with -W l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu

error: unknown lint: l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so
|
= note: requested on the command line with -W l,__dynamic_linker=/snap/core/current/lib/x86_64_linux_gnu/ld_2.23.so

error: unknown lint: l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu'
|
= note: requested on the command line with -W l,_rpath,/snap/scratch/current/lib:/snap/scratch/current/usr/lib:/snap/scratch/current/lib/x86_64_linux_gnu:/snap/scratch/current/usr/lib/x86_64_linux_gnu:/snap/core/current/lib:/snap/core/current/usr/lib:/snap/core/current/lib/x86_64_linux_gnu:/snap/core/current/usr/lib/x86_64_linux_gnu'

error: aborting due to 4 previous errors

error: Could not compile scratch.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment