Open Porkepix opened 7 months ago
I've also had this issue. I believe the issue is the that the library built (onig, using onig-sys, using rust-bindgen) doesn't emit lto-valid code. It needs to be built with LLVM LTO format (since that's the rustc LTO output) by setting the C compiler to clang and manually specifying some linker configuration. It builds properly on my system when I do that.
So use RUSTFLAGS="-C linker-plugin-lto -C linker=clang -C link-arg=-fuse-ld=lld" CC=clang cargo ...
. For the Arch Linux PKGBUILD, put this ahead of the build and test cargo invocations.
Here's a source for the rustflags combo: https://github.com/rust-lang/rust-bindgen/discussions/2405
I've also had this issue. I believe the issue is the that the library built (onig, using onig-sys, using rust-bindgen) doesn't emit lto-valid code. It needs to be built with LLVM LTO format (since that's the rustc LTO output) by setting the C compiler to clang and manually specifying some linker configuration. It builds properly on my system when I do that.
So use
RUSTFLAGS="-C linker-plugin-lto -C linker=clang -C link-arg=-fuse-ld=lld" CC=clang cargo ...
. For the Arch Linux PKGBUILD, put this ahead of the build and test cargo invocations.Here's a source for the rustflags combo: rust-lang/rust-bindgen#2405
I completely missed your answer. When trying to add those flags, it fails very early this way:
error: linking with `clang` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "clang" "-m64" "/tmp/rustcvdD3Kt/symbols.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/proc-macro2-353085366260a5a9/build_script_build-353085366260a5a9.build_script_build.20739e304462bbaa-cgu.0.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/proc-macro2-353085366260a5a9/build_script_build-353085366260a5a9.59yy69sqm7ub6lw0krlky02rx.rcgu.o" "-Wl,--as-needed" "-L" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/deps" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd-975ad26df43f3092.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-854d359d815154a1.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1adba7de6291c957.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-2f003cc5096f2a41.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-1940fdd05db36b65.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-6affaed698e37946.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-59090bd5092c735e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-95e6adcbe5e3e3b6.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-0b7c2ec24db7ead0.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-f07917aaf98e9537.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-3d4fee16d8573795.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libadler-31d2edee42aa9f31.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-09f6820ab6e8fa52.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-67b9ce86c9dd6f1e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-e318bc901c18d569.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fa5228cf59161233.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-2356df8ff6149061.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcore-972c7c6eb3eb878d.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-288663704b9edb44.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-Wl,-plugin-opt=O0,-plugin-opt=mcpu=x86-64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/proc-macro2-353085366260a5a9/build_script_build-353085366260a5a9" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs" "-fuse-ld=lld"
= note: clang: error: invalid linker name in argument '-fuse-ld=lld'
error: could not compile `proc-macro2` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: linking with `clang` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "clang" "-m64" "/tmp/rustcmKu0HE/symbols.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/serde-10c90918a54ac077/build_script_build-10c90918a54ac077.build_script_build.81d712daa15f93e4-cgu.0.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/serde-10c90918a54ac077/build_script_build-10c90918a54ac077.6m4k9ml42to73yzex2rhffbjk.rcgu.o" "-Wl,--as-needed" "-L" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/deps" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd-975ad26df43f3092.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-854d359d815154a1.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1adba7de6291c957.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-2f003cc5096f2a41.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-1940fdd05db36b65.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-6affaed698e37946.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-59090bd5092c735e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-95e6adcbe5e3e3b6.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-0b7c2ec24db7ead0.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-f07917aaf98e9537.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-3d4fee16d8573795.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libadler-31d2edee42aa9f31.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-09f6820ab6e8fa52.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-67b9ce86c9dd6f1e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-e318bc901c18d569.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fa5228cf59161233.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-2356df8ff6149061.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcore-972c7c6eb3eb878d.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-288663704b9edb44.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-Wl,-plugin-opt=O0,-plugin-opt=mcpu=x86-64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/serde-10c90918a54ac077/build_script_build-10c90918a54ac077" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs" "-fuse-ld=lld"
= note: clang: error: invalid linker name in argument '-fuse-ld=lld'
error: could not compile `serde` (build script) due to 1 previous error
error: linking with `clang` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "clang" "-m64" "/tmp/rustck7RjTm/symbols.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/libc-a25c1b35ac330fab/build_script_build-a25c1b35ac330fab.build_script_build.aa3d912dfb08114a-cgu.0.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/libc-a25c1b35ac330fab/build_script_build-a25c1b35ac330fab.build_script_build.aa3d912dfb08114a-cgu.1.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/libc-a25c1b35ac330fab/build_script_build-a25c1b35ac330fab.build_script_build.aa3d912dfb08114a-cgu.2.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/libc-a25c1b35ac330fab/build_script_build-a25c1b35ac330fab.build_script_build.aa3d912dfb08114a-cgu.3.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/libc-a25c1b35ac330fab/build_script_build-a25c1b35ac330fab.ckdk0zbfvj87egtlv8eg7ivz0.rcgu.o" "-Wl,--as-needed" "-L" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/deps" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd-975ad26df43f3092.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-854d359d815154a1.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1adba7de6291c957.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-2f003cc5096f2a41.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-1940fdd05db36b65.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-6affaed698e37946.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-59090bd5092c735e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-95e6adcbe5e3e3b6.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-0b7c2ec24db7ead0.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-f07917aaf98e9537.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-3d4fee16d8573795.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libadler-31d2edee42aa9f31.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-09f6820ab6e8fa52.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-67b9ce86c9dd6f1e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-e318bc901c18d569.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fa5228cf59161233.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-2356df8ff6149061.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcore-972c7c6eb3eb878d.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-288663704b9edb44.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-Wl,-plugin-opt=O0,-plugin-opt=mcpu=x86-64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/libc-a25c1b35ac330fab/build_script_build-a25c1b35ac330fab" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs" "-fuse-ld=lld"
= note: clang: error: invalid linker name in argument '-fuse-ld=lld'
error: could not compile `libc` (build script) due to 1 previous error
error: linking with `clang` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/lib64/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "clang" "-m64" "/tmp/rustcTb9UQ1/symbols.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/rustix-f8f184104ab5ca79/build_script_build-f8f184104ab5ca79.build_script_build.c637cab1cc22d5ff-cgu.0.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/rustix-f8f184104ab5ca79/build_script_build-f8f184104ab5ca79.build_script_build.c637cab1cc22d5ff-cgu.1.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/rustix-f8f184104ab5ca79/build_script_build-f8f184104ab5ca79.build_script_build.c637cab1cc22d5ff-cgu.2.rcgu.o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/rustix-f8f184104ab5ca79/build_script_build-f8f184104ab5ca79.20wbd5g9rn3hs4hfpplnxanu5.rcgu.o" "-Wl,--as-needed" "-L" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/deps" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd-975ad26df43f3092.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-854d359d815154a1.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1adba7de6291c957.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-2f003cc5096f2a41.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-1940fdd05db36b65.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-6affaed698e37946.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-59090bd5092c735e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-95e6adcbe5e3e3b6.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-0b7c2ec24db7ead0.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-f07917aaf98e9537.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-3d4fee16d8573795.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libadler-31d2edee42aa9f31.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-09f6820ab6e8fa52.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-67b9ce86c9dd6f1e.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-e318bc901c18d569.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fa5228cf59161233.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-2356df8ff6149061.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcore-972c7c6eb3eb878d.rlib" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-288663704b9edb44.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-Wl,-plugin-opt=O0,-plugin-opt=mcpu=x86-64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/clement/.cache/paru/clone/git-delta-git/src/delta/target/release/build/rustix-f8f184104ab5ca79/build_script_build-f8f184104ab5ca79" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs" "-fuse-ld=lld"
= note: clang: error: invalid linker name in argument '-fuse-ld=lld'
error: could not compile `rustix` (build script) due to 1 previous error
==> ERROR: A failure occurred in build().
Aborting...
error: failed to build 'git-delta-git-r.319.f89300a-1':
error: packages failed to build: git-delta-git-r.319.f89300a-1
But I don't know why it would fail in my case, if it works for yours?
On the other hand, taken from non-AUR -git
release, I tried adding CFLAGS+=' -ffat-lto-objects'
(https://gitlab.archlinux.org/archlinux/packaging/packages/git-delta/-/blob/main/PKGBUILD?ref_type=heads#L38) and in that case it builds, but I can't explain why would this be needed.
There are quite some differences between the two build files and I don't find build docs around, so in case you would know if/why is https://gitlab.archlinux.org/archlinux/packaging/packages/git-delta/-/blob/main/PKGBUILD?ref_type=heads#L40 needed and the recommendations between cargo locked and frozen (see https://gitlab.archlinux.org/archlinux/packaging/packages/git-delta/-/blob/main/PKGBUILD?ref_type=heads#L43).
I used to update
git-delta
to latest commit for quite some time, through ArchLinux's AUR, from https://aur.archlinux.org/packages/git-delta-git Recently, Arch changed building defaults to enablelto
by default for everything.It caused some of these packages to fail to build under
lto
option, anddelta
is one of them.I didn't see any report of the failing build with
lto
so it felt like it's always worth a report, even if it's to explain that it's intended.The build/link errors are the following ones:
I'm not much knowledgeable of the matter, but I'm guessing issue would come from
onig
crate, coming from there: