coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Build fails when I try to compile with crosslto using the profile generated from build-pgo.sh

Open elseawhy opened this issue 2 months ago • 1 comments

Steps to reproduce:

  1. Generate a profile uising build-pgo.sh
  2. Feed the profile into rustflags along with all these flags
export LDFLAGS="-march=native -fuse-ld=lld -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,pack-relative-relocs,-plugin-opt=O3,-plugin-opt=mcpu=native -flto=full"
readonly CFLAGS="--target=$(clang -print-target-triple) -ffat-lto-objects -march=native -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fstack-protector-strong -fcf-protection -flto=full"
readonly RUSTFLAGS="-C target-cpu=native -C opt-level=3 -Zmir-opt-level=4 -C codegen-units=1 -C linker=clang -C linker-plugin-lto -Z unstable-options -C panic=immediate-abort${LDFLAGS:+ -Clink-arg=${LDFLAGS// / -Clink-arg=}}"

I tried feeding the profile into CFLAGS but that didnt help, the -fprofile-use is missing from it...

error: linking with `clang` failed: exit status: 1
  |
  = note:  "clang" "-m64" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/rustcggpuKJ/{libopenssl_sys-3da9ac226ccc8e97,libblake3-d3d95447de71cfd3}.rlib" "/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-387f503cf25fbdf5.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/rustcggpuKJ/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-Wl,-plugin-opt=O3,-plugin-opt=mcpu=znver3" "-L" "/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/build/blake3-817b5a990e59927e/out" "-L" "/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/build/openssl-sys-cb71aae7662027e1/out/openssl-build/install/lib" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/coreutils-4b4898e30056388d" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-march=native" "-fuse-ld=lld" "-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,pack-relative-relocs,-plugin-opt=O3,-plugin-opt=mcpu=native" "-flto=full"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: module flag identifiers must be unique (or of 'require' type)
          !"CG Profile"
          LLVM ERROR: Broken module found, compilation aborted!
          PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
          Stack dump:
          0.	Program arguments: /usr/bin/ld.lld --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/coreutils-4b4898e30056388d /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/../../../../lib64/Scrt1.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/crtbeginS.o -L/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/rustcggpuKJ/raw-dylibs -L/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/build/blake3-817b5a990e59927e/out -L/home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/build/openssl-sys-cb71aae7662027e1/out/openssl-build/install/lib -L/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/../../../../lib64 -L/lib/../lib64 -L/usr/lib64 -L/lib -L/usr/lib -plugin-opt=mcpu=znver3 /home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/coreutils-4b4898e30056388d.coreutils.4ad3bb404fd9da9c-cgu.0.rcgu.o --as-needed -Bstatic /home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/rustcggpuKJ/libopenssl_sys-3da9ac226ccc8e97.rlib /home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/rustcggpuKJ/libblake3-d3d95447de71cfd3.rlib /home/elseawhy/Git/coreutils/target/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-387f503cf25fbdf5.rlib -Bdynamic -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc --eh-frame-hdr -z noexecstack -plugin-opt=O3 -plugin-opt=mcpu=znver3 --gc-sections -z relro -z now -O1 --strip-debug -O1 --sort-common --as-needed -z relro -z now -z pack-relative-relocs -plugin-opt=O3 -plugin-opt=mcpu=native /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/crtendS.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/../../../../lib64/crtn.o
          1.	Running pass "verify" on module "ld-temp.o"
           #0 0x00007f6358f9143a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/Support/Unix/Signals.inc:846:8
           #1 0x00007f6358ef6b7c RunSignalHandlers /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/Support/Signals.cpp:109:18
           #2 0x00007f6358ef6b7c SignalHandler /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/Support/Unix/Signals.inc:412:3
           #3 0x00007f6350444e70 (/usr/lib/libc.so.6+0x44e70)
           #4 0x00007f63504aeceb __pthread_kill_implementation /usr/src/debug/glibc/glibc/nptl/pthread_kill.c:44:76
           #5 0x00007f63504aeceb __pthread_kill_internal /usr/src/debug/glibc/glibc/nptl/pthread_kill.c:89:10
           #6 0x00007f63504aeceb pthread_kill /usr/src/debug/glibc/glibc/nptl/pthread_kill.c:100:10
           #7 0x00007f6350444d48 raise /usr/src/debug/glibc/glibc/signal/../sysdeps/posix/raise.c:27:6
           #8 0x00007f63504257c1 internal_signal_block_all /usr/src/debug/glibc/glibc/stdlib/../sysdeps/unix/sysv/linux/internal-signals.h:81:3
           #9 0x00007f63504257c1 __abort_lock_wrlock /usr/src/debug/glibc/glibc/stdlib/abort.c:62:3
          #10 0x00007f63504257c1 abort /usr/src/debug/glibc/glibc/stdlib/abort.c:85:3
          #11 0x00007f635599ae32 (/usr/lib/libLLVM.so.22.1+0x4d9ae32)
          #12 0x00007f63552b0887 llvm::report_fatal_error(char const*, bool) /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/Support/ErrorHandling.cpp:0:3
          #13 0x00007f6355e8dd1e (/usr/lib/libLLVM.so.22.1+0x528dd1e)
          #14 0x00007f6355e8aa22 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/include/llvm/IR/PassManagerImpl.h:80:8
          #15 0x00007f635760c338 ~SmallPtrSetImplBase /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/include/llvm/ADT/SmallPtrSet.h:89:9
          #16 0x00007f635760c338 ~PreservedAnalyses /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/include/llvm/IR/Analysis.h:112:7
          #17 0x00007f635760c338 runNewPMPasses /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/LTO/LTOBackend.cpp:354:3
          #18 0x00007f635760c338 llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char>> const&) /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/LTO/LTOBackend.cpp:394:5
          #19 0x00007f63571e979d llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/LTO/LTOBackend.cpp:571:10
          #20 0x00007f63571e7621 ~_Function_base /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/../../../../include/c++/16/bits/std_function.h:248:11
          #21 0x00007f63571e7621 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/LTO/LTO.cpp:1408:13
          #22 0x00007f635698e82f ~_Function_base /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/16/../../../../include/c++/16/bits/std_function.h:248:11
          #23 0x00007f635698e82f llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::FileCache) /usr/src/debug/llvm/llvm-project-22.1.8.src/llvm/lib/LTO/LTO.cpp:1270:18
          #24 0x00007f6359f7b64f lld::elf::BitcodeCompiler::compile() (/usr/lib/liblldELF.so.22.1+0x17b64f)
          #25 0x00007f6359ee7563 (/usr/lib/liblldELF.so.22.1+0xe7563)
          #26 0x00007f6359ec37a1 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/usr/lib/liblldELF.so.22.1+0xc37a1)
          #27 0x00007f6359ebcf38 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/lib/liblldELF.so.22.1+0xbcf38)
          #28 0x00007f635a194bc5 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/usr/lib/liblldCommon.so.22.1+0xcbc5)
          #29 0x000055bdd948aa04 lld_main(int, char**, llvm::ToolContext const&) (/usr/bin/ld.lld+0x2a04)
          #30 0x000055bdd948a2b5 main (/usr/bin/ld.lld+0x22b5)
          #31 0x00007f6350427d0e __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:83:3
          #32 0x00007f6350427e4b call_init /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:127:20
          #33 0x00007f6350427e4b __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:359:5
          #34 0x000055bdd948a315 _start (/usr/bin/ld.lld+0x2315)
          clang: error: unable to execute command: Aborted (core dumped)
          clang: error: linker command failed due to signal (use -v to see invocation)
          

error: could not compile `coreutils` (bin "coreutils") due to 1 previous error

elseawhy avatar Sep 14 '26 10:09 elseawhy

https://github.com/rust-lang/rust/issues/162795

elseawhy avatar Sep 15 '26 06:09 elseawhy