================ @@ -599,11 +599,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, const Driver &D = getToolChain().getDriver(); const llvm::Triple::ArchType Arch = TC.getArch(); const llvm::Triple &Triple = getToolChain().getEffectiveTriple(); + const bool IsStaticPIE = getStaticPIE(Args, TC); if (!D.SysRoot.empty()) CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); CmdArgs.push_back("-Bstatic"); + if (IsStaticPIE) { + CmdArgs.push_back("-pie"); + CmdArgs.push_back("--no-dynamic-linker"); ---------------- quic-garvgupt wrote:
This change is needed for both LLD and GNU LD. I dont see `static -pie` flags being passed by default for LLD if `-static-pie` is passed to clang driver. Moreover, without this change we get a unused argument warning as well. Pls see below for verbose logs. `clang --target=aarch64-none-elf -fuse-ld=lld -static-pie empty.c -###` `clang: warning: argument unused during compilation: '-static-pie' [-Wunused-command-line-argument]` `...............................` `ld.lld" "-Bstatic" "-m" "aarch64linux" "-EL" "crt0.o" "-L/prj/llvm-arm/hexbuild_home/nightly/install/community-mainline/cross/2025-07-09/bin/../lib/clang-runtimes/aarch64-none-elf/lib" "-L/prj/llvm-arm/hexbuild_home/nightly/install/community-mainline/cross/2025-07-09/lib/clang/21/lib/aarch64-unknown-none-elf" "-L/prj/llvm-arm/hexbuild_home/nightly/install/community-mainline/cross/2025-07-09/bin/../lib/clang-runtimes/aarch64-none-elf/lib" "/tmp/empty-09660d.o" "--start-group" "/prj/llvm-arm/hexbuild_home/nightly/install/community-mainline/cross/2025-07-09/lib/clang/21/lib/aarch64-unknown-none-elf/libclang_rt.builtins.a" "-lc" "--end-group" "-o" "a.out"` Pls let me know if I missed something in your comment or interpreted it differently. https://github.com/llvm/llvm-project/pull/147589 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits