[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
MaskRay wrote: Perhaps `nostdlib.c` since nostdlib encompasses nodefaultlibs/nostartfiles. However, if we need another test for a `-no*` style option that is less related to `-nostdlib`, reusing `nostdlib.c` maybe slightly strange. https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
banach-space wrote: Yes, the original comment in the file was not accurate - thanks for the updating it! However, as the name of the file suggests, "dynamic-linker.f90" tests for behaviour relevant to the **dynamic** linker/linking. And, IIUC,`-nostdlib`/`-nodefaultlibs`/`-nostartfiles` only affect **static** linking. IMO there should be a dedicated file for these options. Clang seems to have one test file per each of these flags and that's what I suggest. https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
@@ -18,3 +18,38 @@ ! MSVC-LINKER-OPTIONS: "{{.*}}link{{(.exe)?}}" ! MSVC-LINKER-OPTIONS-SAME: "-dll" ! MSVC-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir" + +! Verify that certain linker flags are known to the frontend and are not passed on +! to the linker. brad0 wrote: Well ya, the original wording that I copied was wrong. The tests are testing Driver flags and how the Driver behaves. https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/72601 >From aeb9e987b91ab9ff63ed7bc38f42a59960e0295b Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 15 Nov 2023 14:24:11 -0500 Subject: [PATCH] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib --- clang/include/clang/Driver/Options.td | 9 --- flang/test/Driver/dynamic-linker.f90 | 39 +-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 9689f12fd01417b..7f5d705e74778c6 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5164,7 +5164,8 @@ def : Flag<["-"], "nocudalib">, Alias; def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option]>, HelpText<"Link the LLVM C Library for GPUs">; def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option]>; -def nodefaultlibs : Flag<["-"], "nodefaultlibs">; +def nodefaultlibs : Flag<["-"], "nodefaultlibs">, + Visibility<[ClangOption, FlangOption]>; def nodriverkitlib : Flag<["-"], "nodriverkitlib">; def nofixprebinding : Flag<["-"], "nofixprebinding">; def nolibc : Flag<["-"], "nolibc">; @@ -5174,7 +5175,8 @@ def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>; def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; -def nostartfiles : Flag<["-"], "nostartfiles">, Group; +def nostartfiles : Flag<["-"], "nostartfiles">, Group, + Visibility<[ClangOption, FlangOption]>; def nostdinc : Flag<["-"], "nostdinc">, Visibility<[ClangOption, CLOption, DXCOption]>, Group; def nostdlibinc : Flag<["-"], "nostdlibinc">, Group; @@ -5182,7 +5184,8 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, CC1Option]> Group, HelpText<"Disable standard #include directories for the C++ standard library">, MarshallingInfoNegativeFlag>; -def nostdlib : Flag<["-"], "nostdlib">, Group; +def nostdlib : Flag<["-"], "nostdlib">, Group, + Visibility<[ClangOption, FlangOption]>; def nostdlibxx : Flag<["-"], "nostdlib++">; def object : Flag<["-"], "object">; def o : JoinedOrSeparate<["-"], "o">, diff --git a/flang/test/Driver/dynamic-linker.f90 b/flang/test/Driver/dynamic-linker.f90 index df119c22a2ea516..f0f6232ed5d9a3d 100644 --- a/flang/test/Driver/dynamic-linker.f90 +++ b/flang/test/Driver/dynamic-linker.f90 @@ -1,5 +1,5 @@ -! Verify that certain linker flags are known to the frontend and are passed on -! to the linker. +! Verify that Driver flags are known to the frontend and appropriate linker +! flags are passed to the linker. ! RUN: %flang -### --target=x86_64-linux-gnu -rpath /path/to/dir -shared \ ! RUN: -static %s 2>&1 | FileCheck \ @@ -18,3 +18,38 @@ ! MSVC-LINKER-OPTIONS: "{{.*}}link{{(.exe)?}}" ! MSVC-LINKER-OPTIONS-SAME: "-dll" ! MSVC-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir" + +! Verify that Driver flags are known to the frontend and appropriate linker +! flags are not passed to the linker. + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s + +! NOSTDLIB: "{{.*}}ld{{(.exe)?}}" +! NOSTDLIB-NOT: crt{{[^.]+}}.o +! NOSTDLIB-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s + +! NODEFAULTLIBS: "{{.*}}ld{{(.exe)?}}" +! NODEFAULTLIBS-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s + +! NOSTARTFILES: "{{.*}}ld{{(.exe)?}}" +! NOSTARTFILES-NOT: crt{{[^.]+}}.o +! NOSTARTFILES: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
brad0 wrote: @MaskRay Still could use some input about the ```CLOption, DXCOption``` part. Same with 34e4e5eb70818fca90574beb8f5617e27bfac138. https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
brad0 wrote: > It would be helpful if you could clearly distinguish between the two opposite > cases that are currently being tested in "dynamic-linker.f90". Ok, done. https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/72601 >From da17459071b039e9da0f53ae5e68ab1c3aaa13e4 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 15 Nov 2023 14:24:11 -0500 Subject: [PATCH] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib --- clang/include/clang/Driver/Options.td | 9 --- flang/test/Driver/dynamic-linker.f90 | 35 +++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index b2f2bcb6ac37910..bc04c53d7c76b9d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5152,7 +5152,8 @@ def : Flag<["-"], "nocudalib">, Alias; def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option]>, HelpText<"Link the LLVM C Library for GPUs">; def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option]>; -def nodefaultlibs : Flag<["-"], "nodefaultlibs">; +def nodefaultlibs : Flag<["-"], "nodefaultlibs">, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nodriverkitlib : Flag<["-"], "nodriverkitlib">; def nofixprebinding : Flag<["-"], "nofixprebinding">; def nolibc : Flag<["-"], "nolibc">; @@ -5162,7 +5163,8 @@ def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>; def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; -def nostartfiles : Flag<["-"], "nostartfiles">, Group; +def nostartfiles : Flag<["-"], "nostartfiles">, Group, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nostdinc : Flag<["-"], "nostdinc">, Visibility<[ClangOption, CLOption, DXCOption]>, Group; def nostdlibinc : Flag<["-"], "nostdlibinc">, Group; @@ -5170,7 +5172,8 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, CC1Option]> Group, HelpText<"Disable standard #include directories for the C++ standard library">, MarshallingInfoNegativeFlag>; -def nostdlib : Flag<["-"], "nostdlib">, Group; +def nostdlib : Flag<["-"], "nostdlib">, Group, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nostdlibxx : Flag<["-"], "nostdlib++">; def object : Flag<["-"], "object">; def o : JoinedOrSeparate<["-"], "o">, diff --git a/flang/test/Driver/dynamic-linker.f90 b/flang/test/Driver/dynamic-linker.f90 index df119c22a2ea516..aa90be5ac196e0e 100644 --- a/flang/test/Driver/dynamic-linker.f90 +++ b/flang/test/Driver/dynamic-linker.f90 @@ -18,3 +18,38 @@ ! MSVC-LINKER-OPTIONS: "{{.*}}link{{(.exe)?}}" ! MSVC-LINKER-OPTIONS-SAME: "-dll" ! MSVC-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir" + +! Verify that certain linker flags are known to the frontend and are not passed on +! to the linker. + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s + +! NOSTDLIB: "{{.*}}ld{{(.exe)?}}" +! NOSTDLIB-NOT: crt{{[^.]+}}.o +! NOSTDLIB-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s + +! NODEFAULTLIBS: "{{.*}}ld{{(.exe)?}}" +! NODEFAULTLIBS-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s + +! NOSTARTFILES: "{{.*}}ld{{(.exe)?}}" +! NOSTARTFILES-NOT: crt{{[^.]+}}.o +! NOSTARTFILES: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
@@ -1,5 +1,5 @@ -! Verify that certain linker flags are known to the frontend and are passed on -! to the linker. +! Verify that certain linker flags are known to the frontend and are passed or +! not passed on to the linker. banach-space wrote: This updated comment is confusing. Could you just split it into two? ```suggestion ! - ! 1: Default behaviour - verify that certain linker flags are known to the frontend and _are_ passed on ! to the linker. ! - (...) ! - ! 2: Non-default behaviour - verify that certain linker flags known to the frontend _are not_ passed on ! to the linker when using e.g. `-nostdlib`. ! - ``` https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
brad0 wrote: @MaskRay ? https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
brad0 wrote: Looking at this again I am not sure if ```CLOption, DXCOption``` should be specified or not. I noticed this in the previous commit for the Flang driver. https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits