-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
Description
Rust compiler passes -pie flag to linker:
However, once one uses flang as linker (for example, Rust + Fortran application with Fortran runtime usage), the error occurs since flang does not accept -pie:
$ rustc -L. -lDFT -Copt-level=3 -Clinker=flang -Clink-arg=-fuse-ld=lld ./main.rs
error: linking with `flang` failed: exit status: 1
|
= note: "flang" "-m64" "/tmp/rustcZsD2qi/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bdynamic" "-lDFT" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcZsD2qi/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "." "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-fuse-ld=lld"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: flang-21: error: unknown argument '-pie'; did you mean '-fpie'?
Tested with:
Fortran compiler
$ flang --version
flang version 21.1.1 (https://github.com/llvm/llvm-project.git 5a86dc996c26299de63effc927075dcbfb924167)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Rust compiler
$ rustc -vV
rustc 1.92.0-nightly (dd7fda570 2025-09-20)
binary: rustc
commit-hash: dd7fda570040e8a736f7d8bc28ddd1b444aabc82
commit-date: 2025-09-20
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1