llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.7k stars 11.87k forks source link

[flang] FLANG_DEFAULT_LINKER=lld does not use ld.lld as the linker #73153

Open kkwli opened 11 months ago

kkwli commented 11 months ago

If I build flang with -DFLANG_DEFAULT_LINKER=lld, the system ld is used.

$ bin/flang-new -### t0.f90
flang-new version 18.0.0 (git@github.com:kkwli/llvm-project.git d2d29288bd4f64e0966db42b821d84587501669b)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /scratch/kli/wrk/f/build-temp/bin
 "/scratch/kli/wrk/f/build-temp/bin/flang-new" "-fc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "ppc64le" "-o" "/tmp/t0-7dd6ee.o" "-x" "f95-cpp-input" "t0.f90"
 "/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../bin/ld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc" "-pie" "-dynamic-linker" "/lib64/ld64.so.2" "-o" "a.out" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtbeginS.o" "-L/usr/lib/gcc/ppc64le-redhat-linux/12" "-L/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/tmp/t0-7dd6ee.o" "-L/scratch/kli/wrk/f/build-temp/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtendS.o" "/lib/../lib64/crtn.o"

However, if I use -DCLANG_DEFAULT_LINKER=lld, ld.lld is used.

$ bin/flang-new -### t0.f90
flang-new version 18.0.0 (git@github.com:kkwli/llvm-project.git d2d29288bd4f64e0966db42b821d84587501669b)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /scratch/kli/wrk/f/build-temp/bin
 "/scratch/kli/wrk/f/build-temp/bin/flang-new" "-fc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "ppc64le" "-o" "/tmp/end-434412.o" "-x" "f95-cpp-input" "t0.f90"
 "/scratch/kli/wrk/f/build-temp/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc" "-pie" "-dynamic-linker" "/lib64/ld64.so.2" "-o" "a.out" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtbeginS.o" "-L/usr/lib/gcc/ppc64le-redhat-linux/12" "-L/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/tmp/end-434412.o" "-L/scratch/kli/wrk/f/build-temp/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtendS.o" "/lib/../lib64/crtn.o"
llvmbot commented 11 months ago

@llvm/issue-subscribers-flang-driver

Author: None (kkwli)

If I build flang with `-DFLANG_DEFAULT_LINKER=lld`, the system `ld` is used. ``` $ bin/flang-new -### t0.f90 flang-new version 18.0.0 (git@github.com:kkwli/llvm-project.git d2d29288bd4f64e0966db42b821d84587501669b) Target: powerpc64le-unknown-linux-gnu Thread model: posix InstalledDir: /scratch/kli/wrk/f/build-temp/bin "/scratch/kli/wrk/f/build-temp/bin/flang-new" "-fc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "ppc64le" "-o" "/tmp/t0-7dd6ee.o" "-x" "f95-cpp-input" "t0.f90" "/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../bin/ld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc" "-pie" "-dynamic-linker" "/lib64/ld64.so.2" "-o" "a.out" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtbeginS.o" "-L/usr/lib/gcc/ppc64le-redhat-linux/12" "-L/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/tmp/t0-7dd6ee.o" "-L/scratch/kli/wrk/f/build-temp/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtendS.o" "/lib/../lib64/crtn.o" ``` However, if I use `-DCLANG_DEFAULT_LINKER=lld`, `ld.lld` is used. ``` $ bin/flang-new -### t0.f90 flang-new version 18.0.0 (git@github.com:kkwli/llvm-project.git d2d29288bd4f64e0966db42b821d84587501669b) Target: powerpc64le-unknown-linux-gnu Thread model: posix InstalledDir: /scratch/kli/wrk/f/build-temp/bin "/scratch/kli/wrk/f/build-temp/bin/flang-new" "-fc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "ppc64le" "-o" "/tmp/end-434412.o" "-x" "f95-cpp-input" "t0.f90" "/scratch/kli/wrk/f/build-temp/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc" "-pie" "-dynamic-linker" "/lib64/ld64.so.2" "-o" "a.out" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtbeginS.o" "-L/usr/lib/gcc/ppc64le-redhat-linux/12" "-L/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/tmp/end-434412.o" "-L/scratch/kli/wrk/f/build-temp/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtendS.o" "/lib/../lib64/crtn.o" ```
llvmbot commented 11 months ago

@llvm/issue-subscribers-flang-build

Author: None (kkwli)

If I build flang with `-DFLANG_DEFAULT_LINKER=lld`, the system `ld` is used. ``` $ bin/flang-new -### t0.f90 flang-new version 18.0.0 (git@github.com:kkwli/llvm-project.git d2d29288bd4f64e0966db42b821d84587501669b) Target: powerpc64le-unknown-linux-gnu Thread model: posix InstalledDir: /scratch/kli/wrk/f/build-temp/bin "/scratch/kli/wrk/f/build-temp/bin/flang-new" "-fc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "ppc64le" "-o" "/tmp/t0-7dd6ee.o" "-x" "f95-cpp-input" "t0.f90" "/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../bin/ld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc" "-pie" "-dynamic-linker" "/lib64/ld64.so.2" "-o" "a.out" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtbeginS.o" "-L/usr/lib/gcc/ppc64le-redhat-linux/12" "-L/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/tmp/t0-7dd6ee.o" "-L/scratch/kli/wrk/f/build-temp/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtendS.o" "/lib/../lib64/crtn.o" ``` However, if I use `-DCLANG_DEFAULT_LINKER=lld`, `ld.lld` is used. ``` $ bin/flang-new -### t0.f90 flang-new version 18.0.0 (git@github.com:kkwli/llvm-project.git d2d29288bd4f64e0966db42b821d84587501669b) Target: powerpc64le-unknown-linux-gnu Thread model: posix InstalledDir: /scratch/kli/wrk/f/build-temp/bin "/scratch/kli/wrk/f/build-temp/bin/flang-new" "-fc1" "-triple" "powerpc64le-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "ppc64le" "-o" "/tmp/end-434412.o" "-x" "f95-cpp-input" "t0.f90" "/scratch/kli/wrk/f/build-temp/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc" "-pie" "-dynamic-linker" "/lib64/ld64.so.2" "-o" "a.out" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtbeginS.o" "-L/usr/lib/gcc/ppc64le-redhat-linux/12" "-L/usr/lib/gcc/ppc64le-redhat-linux/12/../../../../lib64" "-L/lib/../lib64" "-L/usr/lib/../lib64" "-L/lib" "-L/usr/lib" "/tmp/end-434412.o" "-L/scratch/kli/wrk/f/build-temp/lib" "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/gcc/ppc64le-redhat-linux/12/crtendS.o" "/lib/../lib64/crtn.o" ```