[llvm-branch-commits] [clang] 58811fd - [clang] [MinGW] Let the last of -mconsole/-mwindows have effect

2021-08-09 Thread Tom Stellard via llvm-branch-commits

Author: Martin Storsjö
Date: 2021-08-09T23:23:11-07:00
New Revision: 58811fd0f7312b5f6dffd6a252bc1d68e25cfa01

URL: 
https://github.com/llvm/llvm-project/commit/58811fd0f7312b5f6dffd6a252bc1d68e25cfa01
DIFF: 
https://github.com/llvm/llvm-project/commit/58811fd0f7312b5f6dffd6a252bc1d68e25cfa01.diff

LOG: [clang] [MinGW] Let the last of -mconsole/-mwindows have effect

Don't just check for the existence of one, but check which one was
specified last, if any.

This fixes https://llvm.org/PR51296.

Differential Revision: https://reviews.llvm.org/D107261

(cherry picked from commit ce49fd024b43bd76b149f984b8f0d16e92b9bb06)

Added: 


Modified: 
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 20efbdc237a84..7ba729f36bd87 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -136,10 +136,13 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 llvm_unreachable("Unsupported target architecture.");
   }
 
-  if (Args.hasArg(options::OPT_mwindows)) {
+  Arg *SubsysArg =
+  Args.getLastArg(options::OPT_mwindows, options::OPT_mconsole);
+  if (SubsysArg && SubsysArg->getOption().matches(options::OPT_mwindows)) {
 CmdArgs.push_back("--subsystem");
 CmdArgs.push_back("windows");
-  } else if (Args.hasArg(options::OPT_mconsole)) {
+  } else if (SubsysArg &&
+ SubsysArg->getOption().matches(options::OPT_mconsole)) {
 CmdArgs.push_back("--subsystem");
 CmdArgs.push_back("console");
   }

diff  --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp
index 796bde8eebe4c..83b61ba7d33f0 100644
--- a/clang/test/Driver/mingw.cpp
+++ b/clang/test/Driver/mingw.cpp
@@ -61,3 +61,10 @@
 // RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_UNICODE %s
 // CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
 // CHECK_MINGW_UNICODE: "-DUNICODE"
+
+// RUN: %clang -target i686-windows-gnu -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_NO_SUBSYS %s
+// RUN: %clang -target i686-windows-gnu -### %s -mwindows -mconsole 2>&1 | 
FileCheck -check-prefix=CHECK_SUBSYS_CONSOLE %s
+// RUN: %clang -target i686-windows-gnu -### %s -mconsole -mwindows 2>&1 | 
FileCheck -check-prefix=CHECK_SUBSYS_WINDOWS %s
+// CHECK_NO_SUBSYS-NOT: "--subsystem"
+// CHECK_SUBSYS_CONSOLE: "--subsystem" "console"
+// CHECK_SUBSYS_WINDOWS: "--subsystem" "windows"



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] 8f24d17 - [LLD] [MinGW] Support both "--opt value" and "--opt=value" for more options

2021-08-09 Thread Tom Stellard via llvm-branch-commits

Author: Martin Storsjö
Date: 2021-08-09T23:24:23-07:00
New Revision: 8f24d178691f522d9ed46eef84f8408979b1db51

URL: 
https://github.com/llvm/llvm-project/commit/8f24d178691f522d9ed46eef84f8408979b1db51
DIFF: 
https://github.com/llvm/llvm-project/commit/8f24d178691f522d9ed46eef84f8408979b1db51.diff

LOG: [LLD] [MinGW] Support both "--opt value" and "--opt=value" for more options

This does the same fix as D107237 but for a couple more options,
converting all remaining cases of such options to accept both
forms, for consistency. This fixes building e.g. openldap, which
uses --image-base=.

Differential Revision: https://reviews.llvm.org/D107253

(cherry picked from commit b7fb5b54a93099cf3d7ac64f4a95d9942bc2e6a7)

Added: 


Modified: 
lld/MinGW/Options.td
lld/test/MinGW/driver.test

Removed: 




diff  --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td
index 7b250614e434b..fb178a1438e55 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -16,6 +16,11 @@ multiclass EqLong {
 HelpText;
 }
 
+multiclass EqNoHelp {
+  def NAME: Separate<["--", "-"], name>;
+  def NAME # _eq: Joined<["--", "-"], name # "=">, 
Alias(NAME)>;
+}
+
 multiclass B {
   def NAME: Flag<["--", "-"], name>, HelpText;
   def no_ # NAME: Flag<["--", "-"], "no-" # name>, HelpText;
@@ -57,8 +62,8 @@ defm gc_sections: B<"gc-sections",
 "Remove unused sections",
 "Don't remove unused sections">;
 def help: F<"help">, HelpText<"Print option help">;
-def icf: J<"icf=">, HelpText<"Identical code folding">;
-def image_base: S<"image-base">, HelpText<"Base address of the program">;
+defm icf: Eq<"icf", "Identical code folding">;
+defm image_base: Eq<"image-base", "Base address of the program">;
 defm insert_timestamp: B<"insert-timestamp",
 "Include PE header timestamp",
 "Don't include PE header timestamp">;
@@ -109,12 +114,11 @@ def _HASH_HASH_HASH : Flag<["-"], "###">,
 HelpText<"Print (but do not run) the commands to run for this 
compilation">;
 def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in 
the executable">;
 defm delayload: Eq<"delayload", "DLL to load only on demand">;
-def mllvm: S<"mllvm">;
+defm mllvm: EqNoHelp<"mllvm">;
 defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the 
argument is empty">;
 defm thinlto_cache_dir: EqLong<"thinlto-cache-dir",
   "Path to ThinLTO cached object file directory">;
-def Xlink : J<"Xlink=">, MetaVarName<"">,
-HelpText<"Pass  to the COFF linker">;
+defm Xlink : Eq<"Xlink", "Pass  to the COFF linker">, 
MetaVarName<"">;
 
 // Alias
 def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias;
@@ -135,15 +139,13 @@ def: F<"enable-auto-image-base">;
 def: F<"end-group">;
 def: Flag<["--"], "full-shutdown">;
 def: F<"high-entropy-va">;
-def: S<"major-image-version">;
-def: S<"minor-image-version">;
+defm: EqNoHelp<"major-image-version">;
+defm: EqNoHelp<"minor-image-version">;
 def: F<"no-undefined">;
 def: F<"nxcompat">;
 def: F<"pic-executable">;
-def: S<"plugin">;
-def: J<"plugin=">;
-def: S<"plugin-opt">;
-def: J<"plugin-opt=">;
-def: J<"sysroot">;
+defm: EqNoHelp<"plugin">;
+defm: EqNoHelp<"plugin-opt">;
+defm: EqNoHelp<"sysroot">;
 def: F<"start-group">;
 def: F<"tsaware">;

diff  --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 29ea69bd7ba94..a8f4121399f21 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -161,6 +161,7 @@ NO-DISABLE-DYNAMICBASE-NOT: -dynamicbase:no
 
 RUN: ld.lld -### -m i386pep foo.o --image-base 0x123 2>&1 | FileCheck 
-check-prefix IMAGE-BASE %s
 RUN: ld.lld -### -m i386pep foo.o -image-base 0x123 2>&1 | FileCheck 
-check-prefix IMAGE-BASE %s
+RUN: ld.lld -### -m i386pep foo.o --image-base=0x123 2>&1 | FileCheck 
-check-prefix IMAGE-BASE %s
 IMAGE-BASE: -base:0x123
 
 RUN: ld.lld -### -m i386pep foo.o 2>&1 | FileCheck -check-prefix 
NO-GC-SECTIONS %s
@@ -180,6 +181,7 @@ ICF-NONE: -opt:noicf
 
 RUN: ld.lld -### -m i386pep foo.o --icf=all 2>&1 | FileCheck -check-prefix ICF 
%s
 RUN: ld.lld -### -m i386pep foo.o -icf=all 2>&1 | FileCheck -check-prefix ICF 
%s
+RUN: ld.lld -### -m i386pep foo.o --icf all 2>&1 | FileCheck -check-prefix ICF 
%s
 ICF: -opt:icf
 
 RUN: ld.lld -### -m i386pep --start-group foo.o --end-group 2> /dev/null



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] 06b8fb7 - sanitizer_common: disable thread safety annotations for googletest

2021-08-09 Thread Tom Stellard via llvm-branch-commits

Author: Dimitry Andric
Date: 2021-08-09T23:30:45-07:00
New Revision: 06b8fb7974310f88e0fdf52b4a1db0c062075a0d

URL: 
https://github.com/llvm/llvm-project/commit/06b8fb7974310f88e0fdf52b4a1db0c062075a0d
DIFF: 
https://github.com/llvm/llvm-project/commit/06b8fb7974310f88e0fdf52b4a1db0c062075a0d.diff

LOG: sanitizer_common: disable thread safety annotations for googletest

Recently in 0da172b1766e thread safety warnings-as-errors were enabled.
However, googletest is currently not compatible with thread safety
annotations. On FreeBSD, which has the pthread functions marked with
such annotations, this results in errors when building the compiler-rt
tests:

In file included from 
compiler-rt/lib/interception/tests/interception_test_main.cpp:15:
In file included from 
llvm/utils/unittest/googletest/include/gtest/gtest.h:62:
In file included from 
llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h:40:
llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h:1636:3: 
error: mutex 'mutex_' is still held at the end of function 
[-Werror,-Wthread-safety-analysis]
  }
  ^
llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h:1633:32: 
note: mutex acquired here
GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
   ^
llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h:1645:32: 
error: releasing mutex 'mutex_' that was not held 
[-Werror,-Wthread-safety-analysis]
GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
   ^
2 errors generated.

At some point googletest will hopefully be made compatible with thread
safety annotations, but for now add corresponding `-Wno-thread-*` flags
to `COMPILER_RT_GTEST_CFLAGS` to silence these warnings-as-errors.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D107491

(cherry picked from commit b260f3fdda63bbddb7834c42cfeeb2b0a8b86a23)

Added: 


Modified: 
compiler-rt/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 84429052af5e4..e12d1eb1cebf6 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -537,6 +537,14 @@ set(COMPILER_RT_GTEST_CFLAGS
   -I${COMPILER_RT_GTEST_PATH}/include
   -I${COMPILER_RT_GTEST_PATH}
 )
+if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+  # FreeBSD has its pthread functions marked with thread safety annotations, 
but
+  # googletest is not compatible with such annotations. Disable the thread
+  # safety warnings-as-errors until googletest has been fixed.
+  list(APPEND NO_THREAD_SAFETY_FLAGS ${THREAD_SAFETY_FLAGS})
+  list(TRANSFORM NO_THREAD_SAFETY_FLAGS REPLACE "error=" "no-")
+  list(APPEND COMPILER_RT_GTEST_CFLAGS ${NO_THREAD_SAFETY_FLAGS})
+endif()
 
 # Mocking support.
 set(COMPILER_RT_GMOCK_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock)



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits