[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-10-02 Thread Tobias Hieta via cfe-commits

tru wrote:

Yeah i noticed when I got further down in my notification stack :)

https://github.com/llvm/llvm-project/pull/67891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-10-02 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> Did you plan to backport this as well @mstorsjo ?

Yes, I did - in #64464, with 
https://github.com/llvm/llvm-project-release-prs/pull/716 (where tests failed 
after cherrypicking; looking into that test issue right now).

https://github.com/llvm/llvm-project/pull/67891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-10-02 Thread Tobias Hieta via cfe-commits

tru wrote:

Did you plan to backport this as well @mstorsjo ?

https://github.com/llvm/llvm-project/pull/67891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-10-01 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo closed 
https://github.com/llvm/llvm-project/pull/67891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-10-01 Thread via cfe-commits

https://github.com/alvinhochun approved this pull request.

Thanks, looks good to me codewise. I haven't tested it myself but I trust that 
you have.
This seems worth backporting to 17.x since it technically fixes a new 
regression.

https://github.com/llvm/llvm-project/pull/67891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-platform-windows


Changes

Prior to 591c4b64b3650884c2c68eb47d755ebb62981b99, the mingw specific linker 
options -mthreads, -mconsole, -mwindows and -mdll would be tolerated also at 
compile time, but generating a warning about being unused.

After that commit, they were marked as target specific, which means that it's 
an error if they're unused (which would consider them used for the wrong 
target). These specific options are only relevant when linking, but we want to 
tolerate them at compile time too, like before.

This was fixed for -mthreads in
a79995ca6004082774a87f7a58ab6be5343364b7, while the other options didn't seem 
to be commonly used during compilation.

After the 17.x release, we've got more reports about this actually being an 
issue, in #64464. Therefore, apply the same fix for them; marking them 
as tolerated for mingw targets during compilation, even if they're unused. Also 
add a testcase for -mthreads which was already handled.

Thus, this fixes #64464.

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/MinGW.cpp (+5-2) 
- (added) clang/test/Driver/mingw-linker-options.c (+10) 


``diff
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 5af7ea985a28a18..5872e13bda358f8 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -709,8 +709,11 @@ void toolchains::MinGW::addClangTargetOptions(
 }
   }
 
-  if (Arg *A = DriverArgs.getLastArgNoClaim(options::OPT_mthreads))
-A->ignoreTargetSpecific();
+  for (auto Opt : {options::OPT_mthreads, options::OPT_mwindows,
+   options::OPT_mconsole, options::OPT_mdll}) {
+if (Arg *A = DriverArgs.getLastArgNoClaim(Opt))
+  A->ignoreTargetSpecific();
+  }
 }
 
 void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
diff --git a/clang/test/Driver/mingw-linker-options.c 
b/clang/test/Driver/mingw-linker-options.c
new file mode 100644
index 000..b4f1d05a719f3af
--- /dev/null
+++ b/clang/test/Driver/mingw-linker-options.c
@@ -0,0 +1,10 @@
+// RUN: %clang --target=x86_64-windows-gnu -c -mwindows %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mconsole %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mdll %s -### 2>&1 | FileCheck 
%s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mthreads %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: not %clang --target=x86_64-windows-msvc -c -mwindows %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mconsole %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mdll %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mthreads %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// WARNING: warning: argument unused during compilation: '{{.*}}' 
[-Wunused-command-line-argument]
+// ERROR: error: unsupported option '{{.*}}' for target '{{.*}}'

``




https://github.com/llvm/llvm-project/pull/67891
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-09-30 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo updated 
https://github.com/llvm/llvm-project/pull/67891

From da64c467a35cf544df5346b512746715ffc3db32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Sun, 1 Oct 2023 00:29:21 +0300
Subject: [PATCH] [clang] [MinGW] Tolerate mingw specific linker options during
 compilation

Prior to 591c4b64b3650884c2c68eb47d755ebb62981b99, the mingw
specific linker options -mthreads, -mconsole, -mwindows and -mdll
would be tolerated also at compile time, but generating a warning
about being unused.

After that commit, they were marked as target specific, which means
that it's an error if they're unused (which would consider them
used for the wrong target). These specific options are only relevant
when linking, but we want to tolerate them at compile time too,
like before.

This was fixed for -mthreads in
a79995ca6004082774a87f7a58ab6be5343364b7, while the other options
didn't seem to be commonly used during compilation.

After the 17.x release, we've got more reports about this
actually being an issue, in #64464. Therefore, apply the same
fix for them; marking them as tolerated for mingw targets during
compilation, even if they're unused. Also add a testcase for
-mthreads which was already handled.

Thus, this fixes #64464.
---
 clang/lib/Driver/ToolChains/MinGW.cpp|  7 +--
 clang/test/Driver/mingw-linker-options.c | 10 ++
 2 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/mingw-linker-options.c

diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 5af7ea985a28a18..5872e13bda358f8 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -709,8 +709,11 @@ void toolchains::MinGW::addClangTargetOptions(
 }
   }
 
-  if (Arg *A = DriverArgs.getLastArgNoClaim(options::OPT_mthreads))
-A->ignoreTargetSpecific();
+  for (auto Opt : {options::OPT_mthreads, options::OPT_mwindows,
+   options::OPT_mconsole, options::OPT_mdll}) {
+if (Arg *A = DriverArgs.getLastArgNoClaim(Opt))
+  A->ignoreTargetSpecific();
+  }
 }
 
 void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
diff --git a/clang/test/Driver/mingw-linker-options.c 
b/clang/test/Driver/mingw-linker-options.c
new file mode 100644
index 000..b4f1d05a719f3af
--- /dev/null
+++ b/clang/test/Driver/mingw-linker-options.c
@@ -0,0 +1,10 @@
+// RUN: %clang --target=x86_64-windows-gnu -c -mwindows %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mconsole %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mdll %s -### 2>&1 | FileCheck 
%s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mthreads %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: not %clang --target=x86_64-windows-msvc -c -mwindows %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mconsole %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mdll %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mthreads %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// WARNING: warning: argument unused during compilation: '{{.*}}' 
[-Wunused-command-line-argument]
+// ERROR: error: unsupported option '{{.*}}' for target '{{.*}}'

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [MinGW] Tolerate mingw specific linker options during compilation (PR #67891)

2023-09-30 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo created 
https://github.com/llvm/llvm-project/pull/67891

Prior to 591c4b64b3650884c2c68eb47d755ebb62981b99, the mingw specific linker 
options -mthreads, -mconsole, -mwindows and -mdll would be tolerated also at 
compile time, but generating a warning about being unused.

After that commit, they were marked as target specific, which means that it's 
an error if they're unused (which would consider them used for the wrong 
target). These specific options are only relevant when linking, but we want to 
tolerate them at compile time too, like before.

This was fixed for -mthreads in
a79995ca6004082774a87f7a58ab6be5343364b7, while the other options didn't seem 
to be commonly used during compilation.

After the 17.x release, we've got more reports about this actually being an 
issue, in #64464. Therefore, apply the same fix for them; marking them as 
tolerated for mingw targets during compilation, even if they're unused. Also 
add a testcase for -mthreads which was already handled.

Thus, this fixes #64464.

From 5aa262b7805c0d6b82d3216c2f53550c85bf443d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Sun, 1 Oct 2023 00:29:21 +0300
Subject: [PATCH] [clang] [MinGW] Tolerate mingw specific linker options during
 compilation

Prior to 591c4b64b3650884c2c68eb47d755ebb62981b99, the mingw
specific linker options -mthreads, -mconsole, -mwindows and -mdll
would be tolerated also at compile time, but generating a warning
about being unused.

After that commit, they were marked as target specific, which means
that it's an error if they're unused (which would consider them
used for the wrong target). These specific options are only relevant
when linking, but we want to tolerate them at compile time too,
like before.

This was fixed for -mthreads in
a79995ca6004082774a87f7a58ab6be5343364b7, while the other options
didn't seem to be commonly used during compilation.

After the 17.x release, we've got more reports about this
actually being an issue, in #64464. Therefore, apply the same
fix for them; marking them as tolerated for mingw targets during
compilation, even if they're unused.

Thus, this fixes #64464.
---
 clang/lib/Driver/ToolChains/MinGW.cpp|  7 +--
 clang/test/Driver/mingw-linker-options.c | 10 ++
 2 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/mingw-linker-options.c

diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 5af7ea985a28a18..5872e13bda358f8 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -709,8 +709,11 @@ void toolchains::MinGW::addClangTargetOptions(
 }
   }
 
-  if (Arg *A = DriverArgs.getLastArgNoClaim(options::OPT_mthreads))
-A->ignoreTargetSpecific();
+  for (auto Opt : {options::OPT_mthreads, options::OPT_mwindows,
+   options::OPT_mconsole, options::OPT_mdll}) {
+if (Arg *A = DriverArgs.getLastArgNoClaim(Opt))
+  A->ignoreTargetSpecific();
+  }
 }
 
 void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
diff --git a/clang/test/Driver/mingw-linker-options.c 
b/clang/test/Driver/mingw-linker-options.c
new file mode 100644
index 000..b4f1d05a719f3af
--- /dev/null
+++ b/clang/test/Driver/mingw-linker-options.c
@@ -0,0 +1,10 @@
+// RUN: %clang --target=x86_64-windows-gnu -c -mwindows %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mconsole %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mdll %s -### 2>&1 | FileCheck 
%s --check-prefix=WARNING
+// RUN: %clang --target=x86_64-windows-gnu -c -mthreads %s -### 2>&1 | 
FileCheck %s --check-prefix=WARNING
+// RUN: not %clang --target=x86_64-windows-msvc -c -mwindows %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mconsole %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mdll %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// RUN: not %clang --target=x86_64-windows-msvc -c -mthreads %s -### 2>&1 | 
FileCheck %s --check-prefix=ERROR
+// WARNING: warning: argument unused during compilation: '{{.*}}' 
[-Wunused-command-line-argument]
+// ERROR: error: unsupported option '{{.*}}' for target '{{.*}}'

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits