Skip to content

[clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake #118640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

Maetveis
Copy link
Contributor

@Maetveis Maetveis commented Dec 4, 2024

When these options were enabled for flang the visibility was also extended to clang-cl and dxc. I believe this was due to a misunderstanding of the default value for Visibility.

This is marked as draft because I would like to discuss if any of these options should remain, and once that is done add tests to ensure they or are not supported for the relevant driver modes.

When these options were enabled for flang the visibility was also
extended to clang-cl and dxc. I believe this was due to a misunderstanding
of the default value for `Visibility`.
@Maetveis
Copy link
Contributor Author

Maetveis commented Dec 4, 2024

@tarunprabhu Continuing our discussion on #108868 here. These are what I found, by searching for commits that added both FlangOption and CLOption to Options.td and were still reachable in the blame of the file. It is possible that this is not all of them.

The default can get quite confusing to track because IIUC the OptionGroup's Visibility gets unioned with the visibility defined on the record.

@Maetveis
Copy link
Contributor Author

Maetveis commented Dec 4, 2024

@HaohaiWen can you check if this makes sense for clang-cl? @bob80905 same for DXC please.

@tarunprabhu
Copy link
Contributor

Thanks for this. I think you have caught all everything I changed. But I'll take another look to see if there was anything else.

@Maetveis Maetveis requested a review from tarunprabhu December 4, 2024 14:21
@tarunprabhu
Copy link
Contributor

I checked and I don't think there are any others that have been accidentally enabled. Are there any tests that check to these options produce warnings? If not, it might be worth adding them. What do you think?

@HaohaiWen
Copy link
Contributor

HaohaiWen commented Dec 5, 2024

Better to double check with author who specified those CLOption.

@Maetveis
Copy link
Contributor Author

Maetveis commented Dec 6, 2024

I checked and I don't think there are any others that have been accidentally enabled.

Thanks.

Are there any tests that check to these options produce warnings? If not, it might be worth adding them. What do you think?

No there aren't any, and yes I agree, I will add them to this PR once we figure out if I should include -Xlinker and -fdiagnostics-color=.

@Maetveis
Copy link
Contributor Author

Maetveis commented Dec 6, 2024

Better to double check with author who specified those CLOption.

Do you mean the person that added CLOption to these flags? That was @tarunprabhu, but IIUC that was by mistake; his intention was to extend these flags only to Flang.

Otherwise -Xlinker has been around for very long. I guess I will revert these flags to be clang and flang only, then open issues for the discussion of potentially enabling them to clang-cl.

For now this is done only for the problematic options but it could
be automatically generated for all driver modes and all unsupported
options by parsing tablegen's json output.
@Maetveis Maetveis marked this pull request as ready for review December 6, 2024 20:54
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Dec 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 6, 2024

@llvm/pr-subscribers-clang-driver

Author: Mészáros Gergely (Maetveis)

Changes

When these options were enabled for flang the visibility was also extended to clang-cl and dxc. I believe this was due to a misunderstanding of the default value for Visibility.

This is marked as draft because I would like to discuss if any of these options should remain, and once that is done add tests to ensure they or are not supported for the relevant driver modes.


Full diff: https://github.com/llvm/llvm-project/pull/118640.diff

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+12-12)
  • (added) clang/test/Driver/unknown-arg-drivermodes.test (+55)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 4bc0b97ea68f2f..aa705f95ca399a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1055,11 +1055,11 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
 def offload_link : Flag<["--"], "offload-link">, Group<Link_Group>,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
   Group<Link_Group>;
 def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Pass <arg> to the offload linkers or the ones identified by -<triple>">,
   MetaVarName<"<triple> <arg>">, Group<Link_Group>;
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, Group<Preprocessor_Group>,
@@ -1175,7 +1175,7 @@ def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
 def config : Joined<["--"], "config=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, MetaVarName<"<file>">,
   HelpText<"Specify configuration file">;
-def : Separate<["--"], "config">, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, Alias<config>;
+def : Separate<["--"], "config">, Visibility<[ClangOption, FlangOption]>, Alias<config>;
 def no_default_config : Flag<["--"], "no-default-config">,
   Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"Disable loading default configuration files">;
@@ -1989,7 +1989,7 @@ def : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   Alias<fno_color_diagnostics>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group<f_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Values<"auto,always,never">,
   HelpText<"When to use colors in diagnostics">;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group<f_Group>,
@@ -2015,10 +2015,10 @@ argument are escaped with backslashes. This format differs from the format of
 the equivalent section produced by GCC with the -frecord-gcc-switches flag.
 This option is currently only supported on ELF targets.}]>,
   Group<f_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
   Group<f_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
 def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
 def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
@@ -5643,7 +5643,7 @@ def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, FlangO
   HelpText<"Link the LLVM C Library for GPUs">;
 def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">,
-  Visibility<[ClangOption, FlangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def nodriverkitlib : Flag<["-"], "nodriverkitlib">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
@@ -5665,10 +5665,10 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, CC1Option]>
   HelpText<"Disable standard #include directories for the C++ standard library">,
   MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseStandardCXXIncludes">>;
 def nostdlib : Flag<["-"], "nostdlib">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Group<Link_Group>;
 def stdlib : Flag<["-"], "stdlib">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Group<Link_Group>;
 def nostdlibxx : Flag<["-"], "nostdlib++">;
 def object : Flag<["-"], "object">;
@@ -5782,7 +5782,7 @@ def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   Alias<resource_dir>;
 def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def rtlib_EQ : Joined<["-", "--"], "rtlib=">, Visibility<[ClangOption, CLOption, FlangOption]>,
   HelpText<"Compiler runtime library to use">;
 def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>,
@@ -5846,7 +5846,7 @@ def segs__read__write__addr : Separate<["-"], "segs_read_write_addr">;
 def segs__read__ : Joined<["-"], "segs_read_">;
 def shared_libgcc : Flag<["-"], "shared-libgcc">;
 def shared : Flag<["-", "--"], "shared">, Group<Link_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def single__module : Flag<["-"], "single_module">;
 def specs_EQ : Joined<["-", "--"], "specs=">, Group<Link_Group>;
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
@@ -5856,7 +5856,7 @@ def start_no_unused_arguments : Flag<["--"], "start-no-unused-arguments">,
 def static_libgcc : Flag<["-"], "static-libgcc">;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
 def static : Flag<["-", "--"], "static">, Group<Link_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">,
diff --git a/clang/test/Driver/unknown-arg-drivermodes.test b/clang/test/Driver/unknown-arg-drivermodes.test
new file mode 100644
index 00000000000000..60f79426968360
--- /dev/null
+++ b/clang/test/Driver/unknown-arg-drivermodes.test
@@ -0,0 +1,55 @@
+// RUN: %clang_cl                  \
+// RUN: --config                   \
+// RUN: -fdiagnostics-color=auto   \
+// RUN: -fno-record-command-line   \
+// RUN: -frecord-command-line      \
+// RUN: -nodefaultlibs             \
+// RUN: -nostdlib                  \
+// RUN: -rpath                     \
+// RUN: -shared                    \
+// RUN: -static                    \
+// RUN: -stdlib                    \
+// RUN: -Xlinker                   \
+// RUN: -Xoffload-linker           \
+// RUN: -### -x c++ -c - < /dev/null 2>&1 | FileCheck %s --check-prefix=CL
+
+// RUN: not %clang_dxc             \
+// RUN: --config                   \
+// RUN: -fdiagnostics-color=auto   \
+// RUN: -fno-record-command-line   \
+// RUN: -frecord-command-line      \
+// RUN: -nodefaultlibs             \
+// RUN: -nostdlib                  \
+// RUN: -rpath                     \
+// RUN: -shared                    \
+// RUN: -static                    \
+// RUN: -stdlib                    \
+// RUN: -Xlinker                   \
+// RUN: -Xoffload-linker           \
+// RUN: -### -T lib_6_3 -Vd - < /dev/null 2>&1 | FileCheck %s --check-prefix=DXC
+
+// CL: warning: unknown argument ignored in clang-cl: '--config'
+// CL: warning: unknown argument ignored in clang-cl: '-fdiagnostics-color=auto'
+// CL: warning: unknown argument ignored in clang-cl: '-fno-record-command-line'
+// CL: warning: unknown argument ignored in clang-cl: '-frecord-command-line'
+// CL: warning: unknown argument ignored in clang-cl: '-nodefaultlibs'
+// CL: warning: unknown argument ignored in clang-cl: '-nostdlib'
+// CL: warning: unknown argument ignored in clang-cl: '-rpath'
+// CL: warning: unknown argument ignored in clang-cl: '-shared'
+// CL: warning: unknown argument ignored in clang-cl: '-static'
+// CL: warning: unknown argument ignored in clang-cl: '-stdlib'
+// CL: warning: unknown argument ignored in clang-cl: '-Xlinker'
+// CL: warning: unknown argument ignored in clang-cl: '-Xoffload-linker'
+
+// DXC: error: unknown argument: '--config'
+// DXC: error: unknown argument: '-fdiagnostics-color=auto'
+// DXC: error: unknown argument: '-fno-record-command-line'
+// DXC: error: unknown argument: '-frecord-command-line'
+// DXC: error: unknown argument: '-nodefaultlibs'
+// DXC: error: unknown argument: '-nostdlib'
+// DXC: error: unknown argument: '-rpath'
+// DXC: error: unknown argument: '-shared'
+// DXC: error: unknown argument: '-static'
+// DXC: error: unknown argument: '-stdlib'
+// DXC: error: unknown argument: '-Xlinker'
+// DXC: error: unknown argument: '-Xoffload-linker'

@llvmbot
Copy link
Member

llvmbot commented Dec 6, 2024

@llvm/pr-subscribers-clang

Author: Mészáros Gergely (Maetveis)

Changes

When these options were enabled for flang the visibility was also extended to clang-cl and dxc. I believe this was due to a misunderstanding of the default value for Visibility.

This is marked as draft because I would like to discuss if any of these options should remain, and once that is done add tests to ensure they or are not supported for the relevant driver modes.


Full diff: https://github.com/llvm/llvm-project/pull/118640.diff

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+12-12)
  • (added) clang/test/Driver/unknown-arg-drivermodes.test (+55)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 4bc0b97ea68f2f..aa705f95ca399a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1055,11 +1055,11 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
 def offload_link : Flag<["--"], "offload-link">, Group<Link_Group>,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
   Group<Link_Group>;
 def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Pass <arg> to the offload linkers or the ones identified by -<triple>">,
   MetaVarName<"<triple> <arg>">, Group<Link_Group>;
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, Group<Preprocessor_Group>,
@@ -1175,7 +1175,7 @@ def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
 def config : Joined<["--"], "config=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, MetaVarName<"<file>">,
   HelpText<"Specify configuration file">;
-def : Separate<["--"], "config">, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, Alias<config>;
+def : Separate<["--"], "config">, Visibility<[ClangOption, FlangOption]>, Alias<config>;
 def no_default_config : Flag<["--"], "no-default-config">,
   Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"Disable loading default configuration files">;
@@ -1989,7 +1989,7 @@ def : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   Alias<fno_color_diagnostics>;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group<f_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Values<"auto,always,never">,
   HelpText<"When to use colors in diagnostics">;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group<f_Group>,
@@ -2015,10 +2015,10 @@ argument are escaped with backslashes. This format differs from the format of
 the equivalent section produced by GCC with the -frecord-gcc-switches flag.
 This option is currently only supported on ELF targets.}]>,
   Group<f_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
   Group<f_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
 def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
 def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
@@ -5643,7 +5643,7 @@ def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, FlangO
   HelpText<"Link the LLVM C Library for GPUs">;
 def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">,
-  Visibility<[ClangOption, FlangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def nodriverkitlib : Flag<["-"], "nodriverkitlib">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
@@ -5665,10 +5665,10 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, CC1Option]>
   HelpText<"Disable standard #include directories for the C++ standard library">,
   MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseStandardCXXIncludes">>;
 def nostdlib : Flag<["-"], "nostdlib">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Group<Link_Group>;
 def stdlib : Flag<["-"], "stdlib">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Group<Link_Group>;
 def nostdlibxx : Flag<["-"], "nostdlib++">;
 def object : Flag<["-"], "object">;
@@ -5782,7 +5782,7 @@ def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   Alias<resource_dir>;
 def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def rtlib_EQ : Joined<["-", "--"], "rtlib=">, Visibility<[ClangOption, CLOption, FlangOption]>,
   HelpText<"Compiler runtime library to use">;
 def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>,
@@ -5846,7 +5846,7 @@ def segs__read__write__addr : Separate<["-"], "segs_read_write_addr">;
 def segs__read__ : Joined<["-"], "segs_read_">;
 def shared_libgcc : Flag<["-"], "shared-libgcc">;
 def shared : Flag<["-", "--"], "shared">, Group<Link_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def single__module : Flag<["-"], "single_module">;
 def specs_EQ : Joined<["-", "--"], "specs=">, Group<Link_Group>;
 def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>;
@@ -5856,7 +5856,7 @@ def start_no_unused_arguments : Flag<["--"], "start-no-unused-arguments">,
 def static_libgcc : Flag<["-"], "static-libgcc">;
 def static_libstdcxx : Flag<["-"], "static-libstdc++">;
 def static : Flag<["-", "--"], "static">, Group<Link_Group>,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">,
diff --git a/clang/test/Driver/unknown-arg-drivermodes.test b/clang/test/Driver/unknown-arg-drivermodes.test
new file mode 100644
index 00000000000000..60f79426968360
--- /dev/null
+++ b/clang/test/Driver/unknown-arg-drivermodes.test
@@ -0,0 +1,55 @@
+// RUN: %clang_cl                  \
+// RUN: --config                   \
+// RUN: -fdiagnostics-color=auto   \
+// RUN: -fno-record-command-line   \
+// RUN: -frecord-command-line      \
+// RUN: -nodefaultlibs             \
+// RUN: -nostdlib                  \
+// RUN: -rpath                     \
+// RUN: -shared                    \
+// RUN: -static                    \
+// RUN: -stdlib                    \
+// RUN: -Xlinker                   \
+// RUN: -Xoffload-linker           \
+// RUN: -### -x c++ -c - < /dev/null 2>&1 | FileCheck %s --check-prefix=CL
+
+// RUN: not %clang_dxc             \
+// RUN: --config                   \
+// RUN: -fdiagnostics-color=auto   \
+// RUN: -fno-record-command-line   \
+// RUN: -frecord-command-line      \
+// RUN: -nodefaultlibs             \
+// RUN: -nostdlib                  \
+// RUN: -rpath                     \
+// RUN: -shared                    \
+// RUN: -static                    \
+// RUN: -stdlib                    \
+// RUN: -Xlinker                   \
+// RUN: -Xoffload-linker           \
+// RUN: -### -T lib_6_3 -Vd - < /dev/null 2>&1 | FileCheck %s --check-prefix=DXC
+
+// CL: warning: unknown argument ignored in clang-cl: '--config'
+// CL: warning: unknown argument ignored in clang-cl: '-fdiagnostics-color=auto'
+// CL: warning: unknown argument ignored in clang-cl: '-fno-record-command-line'
+// CL: warning: unknown argument ignored in clang-cl: '-frecord-command-line'
+// CL: warning: unknown argument ignored in clang-cl: '-nodefaultlibs'
+// CL: warning: unknown argument ignored in clang-cl: '-nostdlib'
+// CL: warning: unknown argument ignored in clang-cl: '-rpath'
+// CL: warning: unknown argument ignored in clang-cl: '-shared'
+// CL: warning: unknown argument ignored in clang-cl: '-static'
+// CL: warning: unknown argument ignored in clang-cl: '-stdlib'
+// CL: warning: unknown argument ignored in clang-cl: '-Xlinker'
+// CL: warning: unknown argument ignored in clang-cl: '-Xoffload-linker'
+
+// DXC: error: unknown argument: '--config'
+// DXC: error: unknown argument: '-fdiagnostics-color=auto'
+// DXC: error: unknown argument: '-fno-record-command-line'
+// DXC: error: unknown argument: '-frecord-command-line'
+// DXC: error: unknown argument: '-nodefaultlibs'
+// DXC: error: unknown argument: '-nostdlib'
+// DXC: error: unknown argument: '-rpath'
+// DXC: error: unknown argument: '-shared'
+// DXC: error: unknown argument: '-static'
+// DXC: error: unknown argument: '-stdlib'
+// DXC: error: unknown argument: '-Xlinker'
+// DXC: error: unknown argument: '-Xoffload-linker'

@tarunprabhu
Copy link
Contributor

Better to double check with author who specified those CLOption.

Do you mean the person that added CLOption to these flags? That was @tarunprabhu, but IIUC that was by mistake; his intention was to extend these flags only to Flang.

That is correct, the intention was to extend those flags only to Flang

@HaohaiWen
Copy link
Contributor

Better to double check with author who specified those CLOption.

Do you mean the person that added CLOption to these flags? That was @tarunprabhu, but IIUC that was by mistake; his intention was to extend these flags only to Flang.

Otherwise -Xlinker has been around for very long. I guess I will revert these flags to be clang and flang only, then open issues for the discussion of potentially enabling them to clang-cl.

Some of our project have already used -Xlinker on Windows. Is there any equivalent flag for CL?
Can we keep this flag for CL in this PR and open an issue to discuss whether it should be disabled for CL?

@Maetveis
Copy link
Contributor Author

Maetveis commented Dec 9, 2024

Can we keep this flag for CL in this PR and open an issue to discuss whether it should be disabled for CL?

Sure, see latest commit and #119179.

@Maetveis
Copy link
Contributor Author

Maetveis commented Dec 9, 2024

@HaohaiWen can you review and approve if it looks good now for clang-cl? I'll try pinging discord and waiting a little bit for HLSL people before merging.

Gentle ping @bob80905.

Copy link
Contributor

@HaohaiWen HaohaiWen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for -Xlinker.

@HaohaiWen
Copy link
Contributor

@MaskRay, may need to merge https://github.com/llvm/llvm-project/blob/main/clang/test/Driver/fprofile-sample-use.c to clang/test/Driver/unknown-arg-drivermodes.test

Copy link
Contributor

@bob80905 bob80905 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Maetveis Maetveis requested a review from MaskRay December 10, 2024 11:37
@Maetveis
Copy link
Contributor Author

ping @MaskRay

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test as well. LGTM.

@Maetveis Maetveis merged commit ef31141 into llvm:main Dec 16, 2024
8 checks passed
@Maetveis Maetveis deleted the fix_accidental_options branch December 16, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants