r332343 - [Solaris] Only define _REENTRANT if -pthread

2018-05-15 Thread Rainer Orth via cfe-commits
Author: ro
Date: Tue May 15 04:36:00 2018
New Revision: 332343

URL: http://llvm.org/viewvc/llvm-project?rev=332343&view=rev
Log:
[Solaris] Only define _REENTRANT if -pthread

When looking at lib/Basic/Targets/OSTargets.h, I noticed that _REENTRANT is 
defined
unconditionally on Solaris, unlike all other targets and what either Studio cc 
(only define
it with -mt) or gcc (only define it with -pthread) do.

This patch follows that lead.

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

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=332343&r1=332342&r2=332343&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue May 15 04:36:00 2018
@@ -551,7 +551,8 @@ protected:
 Builder.defineMacro("_LARGEFILE_SOURCE");
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");
-Builder.defineMacro("_REENTRANT");
+if (Opts.POSIXThreads)
+  Builder.defineMacro("_REENTRANT");
 if (this->HasFloat128)
   Builder.defineMacro("__FLOAT128__");
   }


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


r335234 - [liblang] Remove DOS line endings in libclang.exports

2018-06-21 Thread Rainer Orth via cfe-commits
Author: ro
Date: Thu Jun 21 06:40:50 2018
New Revision: 335234

URL: http://llvm.org/viewvc/llvm-project?rev=335234&view=rev
Log:
[liblang] Remove DOS line endings in libclang.exports

Undefined   first referenced
 symbol in file
clang_getCompletionFixIt   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenLocation 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getToken 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTemplateCursorKind
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTUResourceUsageName   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkKind   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkText   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getSpellingLocation  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionParent  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkCompletionString 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionPriority
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionNumFixIts   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenExtent   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionNumAnnotations  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenKind 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[2]: *** 
[tools/clang/tools/libclang/CMakeFiles/libclang.dir/build.make:651: 
lib/libclang.so.7] Error 1

It turns out that this is caused by https://reviews.llvm.org/D46862: it added a
couple of CRs (^M) to some lines.  Solaris ld takes them to be part of the 
symbol
names, which of course are missing from the input objects.  GNU ld handles this
just fine.  Fixed by removing the CRs.

Bootstrapped on i386-pc-solaris2.11.  I guess this is obvious.

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

Modified:
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/tools/libclang/libclang.exports
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=335234&r1=335233&r2=335234&view=diff
==
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Thu Jun 21 06:40:50 2018
@@ -168,14 +168,14 @@ clang_getClangVersion
 clang_getCompletionAnnotation
 clang_getCompletionAvailability
 clang_getCompletionBriefComment
-clang_getCompletionChunkCompletionString
-clang_getCompletionChunkKind
-clang_getCompletionChunkText
-clang_getCompletionNumFixIts
-clang_getCompletionFixIt
-clang_getCompletionNumAnnotations
-clang_getCompletionParent
-clang_getCompletionPriority
+clang_getCompletionChunkCompletionString
+clang_getCompletionChunkKind
+clang_getCompletionChunkText
+clang_getCompletionNumFixIts
+clang_getCompletionFixIt
+clang_getCompletionNumAnnotations
+clang_getCompletionParent
+clang_getCompletionPriority
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
@@ -259,13 +259,13 @@ clang_getRemappingsFromFileList
 clang_getResultType
 clang_getSkippedRanges
 clang_getSpecializedCursorTemplate
-clang_getSpellingLocation
-clang_getTUResourceUsageName
-clang_getTemplateCursorKind
-clang_getToken
-clang_getTokenExtent
-clang_getTokenKind
-clang_getTokenLocation
+clang_getSpellingLocation
+clang_getTUResourceUsageName
+clang_getTemplateCursorKind
+clang_getToken
+clang_getTokenExtent
+clang_getTokenKind
+clang_getTokenLocation
 clang_getTokenSpelling
 clang_getTranslationUnitCursor
 clang_getTranslationUnitSpelling


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


r357917 - [python, tests] Disable Clang Python tests on SPARC

2019-04-08 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Apr  8 08:01:06 2019
New Revision: 357917

URL: http://llvm.org/viewvc/llvm-project?rev=357917&view=rev
Log:
[python, tests] Disable Clang Python tests on SPARC

Running `make check-all` fails on Solaris 11/SPARC since the clang python
tests FAIL:

  
  ==
  FAIL: test_extent (tests.cindex.test_location.TestLocation)
  --
  Traceback (most recent call last):
File "tests/cindex/test_location.py", line 87, in test_extent
  self.assert_location(one.extent.start,line=1,column=1,offset=0)
File "tests/cindex/test_location.py", line 22, in assert_location
  self.assertEqual(loc.column, column)
  AssertionError: 5 != 1
  
  ==
  FAIL: test_get_children (tests.cindex.test_cursor.TestCursor)
  --
  Traceback (most recent call last):
File "tests/cindex/test_cursor.py", line 70, in test_get_children
  self.assertEqual(tu_nodes[0].is_definition(), True)
  AssertionError: False != True
  
  --
  Ran 126 tests in 2.123s
  
  FAILED (failures=2, skipped=6)
  
Unfortunately, this aborts the rest of `make check-all`, even with `-k`, so
this patch disables the test as is already done on a couple of other
targets.
  
This allowed the `sparc-sun-solaris2.11` test to finish.

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

Modified:
cfe/trunk/bindings/python/tests/CMakeLists.txt

Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=357917&r1=357916&r2=357917&view=diff
==
--- cfe/trunk/bindings/python/tests/CMakeLists.txt (original)
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt Mon Apr  8 08:01:06 2019
@@ -32,11 +32,11 @@ if(WIN32)
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# AArch64 and Hexagon have known test failures that need to be
+# AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
 # https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 


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


r363612 - Clang :: Sema/wchar.c has long been failing on Solaris:

2019-06-17 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Jun 17 13:21:25 2019
New Revision: 363612

URL: http://llvm.org/viewvc/llvm-project?rev=363612&view=rev
Log:
Clang :: Sema/wchar.c has long been failing on Solaris:

  error: 'error' diagnostics expected but not seen: 
File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 22: initializing wide 
char array with non-wide string literal
  error: 'error' diagnostics seen but not expected: 
File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 20: array initializer 
must be an initializer list
File /vol/llvm/src/clang/local/test/Sema/wchar.c Line 22: array initializer 
must be an initializer list

It turns out the definition is wrong, as can be seen in GCC's gcc/config/sol2.h:

  /* wchar_t is called differently in  for 32 and 64-bit
 compilations.  This is called for by SCD 2.4.1, p. 6-83, Figure 6-65
 (32-bit) and p. 6P-10, Figure 6.38 (64-bit).  */
  
  #undef WCHAR_TYPE
  #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")

The following patch implements this, and at the same time corrects the wint_t
definition which is the same:

  /* Same for wint_t.  See SCD 2.4.1, p. 6-83, Figure 6-66 (32-bit).  There's
 no corresponding 64-bit definition, but this is what Solaris 8
  uses.  */
  
  #undef WINT_TYPE
  #define WINT_TYPE (TARGET_64BIT ? "int" : "long int")

Clang :: Preprocessor/wchar_t.c and Clang :: Sema/format-strings.c need to
be adjusted to account for that.

Tested on i386-pc-solaris2.11, x86_64-pc-solaris2.11, and x86_64-pc-linux-gnu.

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

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/Preprocessor/wchar_t.c
cfe/trunk/test/Sema/format-strings.c
cfe/trunk/test/Sema/wchar.c

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=363612&r1=363611&r2=363612&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Mon Jun 17 13:21:25 2019
@@ -632,7 +632,11 @@ protected:
 public:
   SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
-// FIXME: WIntType should be SignedLong
+if (this->PointerWidth == 64) {
+  this->WCharType = this->WIntType = this->SignedInt;
+} else {
+  this->WCharType = this->WIntType = this->SignedLong;
+}
 switch (Triple.getArch()) {
 default:
   break;

Modified: cfe/trunk/test/Preprocessor/wchar_t.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/wchar_t.c?rev=363612&r1=363611&r2=363612&view=diff
==
--- cfe/trunk/test/Preprocessor/wchar_t.c (original)
+++ cfe/trunk/test/Preprocessor/wchar_t.c Mon Jun 17 13:21:25 2019
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -triple i386-pc-solaris -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-SOLARIS
 // CHECK-SOLARIS-DAG: #define __WCHAR_MAX__ 2147483647
-// CHECK-SOLARIS-DAG: #define __WCHAR_TYPE__ int
+// CHECK-SOLARIS-DAG: #define __WCHAR_TYPE__ long int
 // CHECK-SOLARIS-NOT: #define __WCHAR_UNSIGNED__ 0
 
+// RUN: %clang_cc1 -triple x86_64-pc-solaris -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-SOLARIS64
+// CHECK-SOLARIS64-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-SOLARIS64-DAG: #define __WCHAR_TYPE__ int
+// CHECK-SOLARIS64-NOT: #define __WCHAR_UNSIGNED__ 0
+
 // RUN: %clang_cc1 -triple avr-unknown-unknown -fwchar-type=int -fsigned-wchar 
-dM -E %s -o - | FileCheck %s -check-prefix CHECK-AVR
 // CHECK-AVR-DAG: #define __WCHAR_MAX__ 32767
 // CHECK-AVR-DAG: #define __WCHAR_TYPE__ int

Modified: cfe/trunk/test/Sema/format-strings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=363612&r1=363611&r2=363612&view=diff
==
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Mon Jun 17 13:21:25 2019
@@ -329,7 +329,11 @@ void test_unicode_conversions(wchar_t *s
   printf("%S", s); // no-warning
   printf("%s", s); // expected-warning{{format specifies type 'char *' but the 
argument has type 'wchar_t *'}}
   printf("%C", s[0]); // no-warning
+#if defined(__sun) && !defined(__LP64__)
+  printf("%c", s[0]); // expected-warning{{format specifies type 'int' but the 
argument has type 'wchar_t' (aka 'long')}}
+#else
   printf("%c", s[0]);
+#endif
   // FIXME: This test reports inconsistent results. On Windows, '%C' expects
   // 'unsigned short'.
   // printf("%C", 10);
@@ -401,7 +405,7 @@ void bug7377_bad_length_mod_usage() {
 void pr7981(wint_t c, wchar_t c2) {
   printf("%lc", c); // no-warning
   printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
-#if __WINT_WIDTH__ == 32
+#if __WINT_WIDTH__ == 32 && !(defined(__sun) && !defined(__

r366202 - [Driver] Don't pass --dynamic-linker to ld on Solaris

2019-07-16 Thread Rainer Orth via cfe-commits
Author: ro
Date: Tue Jul 16 04:06:43 2019
New Revision: 366202

URL: http://llvm.org/viewvc/llvm-project?rev=366202&view=rev
Log:
[Driver] Don't pass --dynamic-linker to ld on Solaris

I noticed that clang currently passes --dynamic-linker to ld.  This has been 
the case
since Solaris 11 support was added initially back in 2012 by David Chisnall 
(r150580).
I couldn't find any patch submission, let alone a justification, for this, and 
it seems
completely useless: --dynamic-linker is a gld compatibility form of the option, 
the
native option being -I.  First of all, however, the dynamic linker passed is 
simply the
default, so there's no reason at all to specify it in the first place.

This patch removes passing the option and adjusts the affected testcase 
accordingly.

Tested on x86_64-pc-solaris2.11 and sparcv9-sun-solaris2.11.

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

Removed:
cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/ld.so.1
cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/ld.so.1
cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/ld.so.1
cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/ld.so.1
Modified:
cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
cfe/trunk/test/Driver/solaris-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Solaris.cpp?rev=366202&r1=366201&r2=366202&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Solaris.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Solaris.cpp Tue Jul 16 04:06:43 2019
@@ -65,10 +65,6 @@ void solaris::Linker::ConstructJob(Compi
 CmdArgs.push_back("-Bdynamic");
 if (Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-shared");
-} else {
-  CmdArgs.push_back("--dynamic-linker");
-  CmdArgs.push_back(
-  Args.MakeArgString(getToolChain().GetFilePath("ld.so.1")));
 }
 
 // libpthread has been folded into libc since Solaris 10, no need to do

Removed: cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/ld.so.1
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/ld.so.1?rev=366201&view=auto
==
(empty)

Removed: cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/ld.so.1
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/ld.so.1?rev=366201&view=auto
==
(empty)

Removed: cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/ld.so.1
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/ld.so.1?rev=366201&view=auto
==
(empty)

Removed: cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/ld.so.1
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/ld.so.1?rev=366201&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/solaris-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/solaris-ld.c?rev=366202&r1=366201&r2=366202&view=diff
==
--- cfe/trunk/test/Driver/solaris-ld.c (original)
+++ cfe/trunk/test/Driver/solaris-ld.c Tue Jul 16 04:06:43 2019
@@ -11,7 +11,6 @@
 // CHECK-LD-SPARC32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"sparc-sun-solaris2.11"
 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC32-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib{{/|}}ld.so.1"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crt1.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtbegin.o"
@@ -35,7 +34,6 @@
 // CHECK-LD-SPARC64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"sparcv9-sun-solaris2.11"
 // CHECK-LD-SPARC64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC64-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib/sparcv9{{/|}}ld.so.1"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crt1.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|}}crti.o"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtbegin.o"
@@ -59,7 +57,6 @@
 // CHECK-LD-X32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "i386-pc-solaris2.11"
 // CHECK-LD-X32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-L

r366305 - [Driver] Enable __cxa_atexit on Solaris

2019-07-17 Thread Rainer Orth via cfe-commits
Author: ro
Date: Wed Jul 17 01:37:00 2019
New Revision: 366305

URL: http://llvm.org/viewvc/llvm-project?rev=366305&view=rev
Log:
[Driver] Enable __cxa_atexit on Solaris

Starting with Solaris 11.4 (which is now the required minimal version), Solaris 
does
support __cxa_atexit.  This patch reflects that.

One might consider removing the affected tests altogether instead of inverting 
them,
as is done on other targets.

Besides, this lets two ASan tests PASS:

  AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc
  AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc

Tested on x86_64-pc-solaris2.11 and sparcv9-sun-solaris2.11.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cxa-atexit.cpp
cfe/trunk/test/Driver/solaris-opts.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=366305&r1=366304&r2=366305&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Jul 17 01:37:00 2019
@@ -4749,7 +4749,6 @@ void Clang::ConstructJob(Compilation &C,
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||

Modified: cfe/trunk/test/Driver/cxa-atexit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cxa-atexit.cpp?rev=366305&r1=366304&r2=366305&view=diff
==
--- cfe/trunk/test/Driver/cxa-atexit.cpp (original)
+++ cfe/trunk/test/Driver/cxa-atexit.cpp Wed Jul 17 01:37:00 2019
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | 
FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"

Modified: cfe/trunk/test/Driver/solaris-opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/solaris-opts.c?rev=366305&r1=366304&r2=366305&view=diff
==
--- cfe/trunk/test/Driver/solaris-opts.c (original)
+++ cfe/trunk/test/Driver/solaris-opts.c Wed Jul 17 01:37:00 2019
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck 
%s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 


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


r366820 - [clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

2019-07-23 Thread Rainer Orth via cfe-commits
Author: ro
Date: Tue Jul 23 09:24:00 2019
New Revision: 366820

URL: http://llvm.org/viewvc/llvm-project?rev=366820&view=rev
Log:
[clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

Clang :: Headers/max_align.c currently FAILs on 64-bit SPARC:

  error: 'error' diagnostics seen but not expected: 
File /vol/llvm/src/clang/dist/test/Headers/max_align.c Line 12: 
static_assert failed due to requirement '8 == _Alignof(max_align_t)' ""
  1 error generated.

This happens because SuitableAlign isn't defined for SPARCv9 unlike SPARCv8
(which uses the default of 64 bits).  gcc's sparc/sparc.h has

  #define BIGGEST_ALIGNMENT (TARGET_ARCH64 ? 128 : 64)

This patch sets SuitableAlign to match and updates the corresponding testcase.

Tested on sparcv9-sun-solaris2.11.

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

Modified:
cfe/trunk/lib/Basic/Targets/Sparc.h
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/Sparc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Sparc.h?rev=366820&r1=366819&r2=366820&view=diff
==
--- cfe/trunk/lib/Basic/Targets/Sparc.h (original)
+++ cfe/trunk/lib/Basic/Targets/Sparc.h Tue Jul 23 09:24:00 2019
@@ -208,6 +208,7 @@ public:
 // aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned.
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
+SuitableAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=366820&r1=366819&r2=366820&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Jul 23 09:24:00 2019
@@ -9599,6 +9599,7 @@
 // X86-64-DECLSPEC: #define __declspec{{.*}}
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null 
| FileCheck -match-full-lines -check-prefix SPARCV9 %s
+// SPARCV9:#define __BIGGEST_ALIGNMENT__ 16
 // SPARCV9:#define __INT64_TYPE__ long int
 // SPARCV9:#define __INTMAX_C_SUFFIX__ L
 // SPARCV9:#define __INTMAX_TYPE__ long int


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


r367305 - [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-30 Thread Rainer Orth via cfe-commits
Author: ro
Date: Tue Jul 30 03:38:41 2019
New Revision: 367305

URL: http://llvm.org/viewvc/llvm-project?rev=367305&view=rev
Log:
[Driver] Define _FILE_OFFSET_BITS=64 on Solaris

make check-all currently fails on x86_64-pc-solaris2.11 when building with GCC 
9:

  Undefined   first referenced
   symbol in file
  _ZN11__sanitizer14internal_lseekEimi 
SANITIZER_TEST_OBJECTS.sanitizer_libc_test.cc.i386.o
  _ZN11__sanitizer23MapWritableFileToMemoryEPvmim 
SANITIZER_TEST_OBJECTS.sanitizer_libc_test.cc.i386.o
  ld: fatal: symbol referencing errors
  clang-9: error: linker command failed with exit code 1 (use -v to see 
invocation)
  make[3]: *** 
[projects/compiler-rt/lib/sanitizer_common/tests/CMakeFiles/TSanitizer-i386-Test.dir/build.make:92:
 projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-i386-Test] Error 1

While e.g. __sanitizer::internal_lseek is defined in sanitizer_solaris.cc, g++ 9
predefines _FILE_OFFSET_BITS=64 while clang++ currently does not.

This patch resolves this inconsistency by following the gcc lead, which allows
make check-all to finish successfully.

There's one caveat: gcc defines _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE for 
C++ only, while clang has long been doing it for
all languages.  I'd like to keep it this way because those macros do is to make
declarations of fseek/ftello (_LARGEFILE_SOURCE) resp. the 64-bit versions
of largefile functions (*64 with _LARGEFILE64_SOURCE) visible additionally.
However, _FILE_OFFSET_BITS=64 changes all affected functions to be 
largefile-aware.
I'd like to restrict this to C++, just like gcc does.

To avoid a similar inconsistence with host compilers that don't predefine 
_FILE_OFFSET_BITS=64
(e.g. clang < 9, gcc < 9), this needs a compantion patch 
https://reviews.llvm.org/D64483.

Tested on x86_64-pc-solaris2.11.

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

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=367305&r1=367304&r2=367305&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue Jul 30 03:38:41 2019
@@ -622,8 +622,11 @@ protected:
   Builder.defineMacro("_XOPEN_SOURCE", "600");
 else
   Builder.defineMacro("_XOPEN_SOURCE", "500");
-if (Opts.CPlusPlus)
+if (Opts.CPlusPlus) {
   Builder.defineMacro("__C99FEATURES__");
+  Builder.defineMacro("_FILE_OFFSET_BITS", "64");
+}
+// GCC restricts the next two to C++.
 Builder.defineMacro("_LARGEFILE_SOURCE");
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");


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


r367351 - [Driver] Support -fsanitize=function on Solaris/x86

2019-07-30 Thread Rainer Orth via cfe-commits
Author: ro
Date: Tue Jul 30 13:04:53 2019
New Revision: 367351

URL: http://llvm.org/viewvc/llvm-project?rev=367351&view=rev
Log:
[Driver] Support -fsanitize=function on Solaris/x86

UBSan-Standalone-x86_64 :: TestCases/TypeCheck/Function/function.cpp currently
FAILs on Solaris/x86_64:

  clang-9: error: unsupported option '-fsanitize=function' for target 
'x86_64-pc-solaris2.11'

AFAICS, there's nothing more to do then enable that sanitizer in the driver 
(for x86 only),
which is what this patch does, together with updating another testcase.

Tested on x86_64-pc-solaris2.11.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Solaris.cpp?rev=367351&r1=367350&r2=367351&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Solaris.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Solaris.cpp Tue Jul 30 13:04:53 2019
@@ -177,6 +177,7 @@ Solaris::Solaris(const Driver &D, const
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   // FIXME: Omit X86_64 until 64-bit support is figured out.
   if (IsX86) {
@@ -184,6 +185,8 @@ SanitizerMask Solaris::getSupportedSanit
 Res |= SanitizerKind::PointerCompare;
 Res |= SanitizerKind::PointerSubtract;
   }
+  if (IsX86 || IsX86_64)
+Res |= SanitizerKind::Function;
   Res |= SanitizerKind::Vptr;
   return Res;
 }

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=367351&r1=367350&r2=367351&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Tue Jul 30 13:04:53 2019
@@ -727,6 +727,9 @@
 // RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s -check-prefix=SCUDO-NETBSD
 // SCUDO-NETBSD: "-fsanitize=scudo"
 
+// RUN: %clang -target i386--solaris -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// FUNCTION-SOLARIS: "-fsanitize=function"
 
 
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function 
-fsanitize=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-FSAN-UBSAN-PS4


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


r367864 - Move LangStandard*, InputKind::Language to Basic

2019-08-05 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Aug  5 06:59:26 2019
New Revision: 367864

URL: http://llvm.org/viewvc/llvm-project?rev=367864&view=rev
Log:
Move LangStandard*, InputKind::Language to Basic

This patch is a prerequisite for using LangStandard from Driver in
https://reviews.llvm.org/D64793.

It moves LangStandard* and InputKind::Language to Basic.  It is mostly
mechanical, with only a few changes of note:

- enum Language has been changed into enum class Language : uint8_t to
  avoid a clash between OpenCL in enum Language and OpenCL in enum
  LangFeatures and not to increase the size of class InputKind.

- Now that getLangStandardForName, which is currently unused, also checks
  both canonical and alias names, I've introduced a helper getLangKind
  which factors out a code pattern already used 3 times.

The patch has been tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11,
and x86_64-pc-linux-gnu.

There's a companion patch for lldb which uses LangStandard.h
(https://reviews.llvm.org/D65717).

While polly includes isl which in turn uses InputKind::C, that part of the
code isn't even built inside the llvm tree.  I've posted a patch to allow
for both InputKind::C and Language::C upstream
(https://groups.google.com/forum/#!topic/isl-development/6oEvNWOSQFE).

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

Added:
cfe/trunk/include/clang/Basic/LangStandard.h
  - copied, changed from r367863, 
cfe/trunk/include/clang/Frontend/LangStandard.h
cfe/trunk/include/clang/Basic/LangStandards.def
  - copied, changed from r367863, 
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/lib/Basic/LangStandards.cpp
  - copied, changed from r367863, cfe/trunk/lib/Frontend/LangStandards.cpp
Removed:
cfe/trunk/include/clang/Frontend/LangStandard.h
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/lib/Frontend/LangStandards.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/FrontendOptions.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
cfe/trunk/unittests/Frontend/FrontendActionTest.cpp
cfe/trunk/unittests/Frontend/OutputStreamTest.cpp

Copied: cfe/trunk/include/clang/Basic/LangStandard.h (from r367863, 
cfe/trunk/include/clang/Frontend/LangStandard.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangStandard.h?p2=cfe/trunk/include/clang/Basic/LangStandard.h&p1=cfe/trunk/include/clang/Frontend/LangStandard.h&r1=367863&r2=367864&rev=367864&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandard.h (original)
+++ cfe/trunk/include/clang/Basic/LangStandard.h Mon Aug  5 06:59:26 2019
@@ -6,16 +6,37 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H
-#define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
+#ifndef LLVM_CLANG_BASIC_LANGSTANDARD_H
+#define LLVM_CLANG_BASIC_LANGSTANDARD_H
 
 #include "clang/Basic/LLVM.h"
-#include "clang/Frontend/FrontendOptions.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
 
-namespace frontend {
+/// The language for the input, used to select and validate the language
+/// standard and possible actions.
+enum class Language : uint8_t {
+  Unknown,
+
+  /// Assembly: we accept this only so that we can preprocess it.
+  Asm,
+
+  /// LLVM IR: we accept this so that we can run the optimizer on it,
+  /// and compile it to assembly or object code.
+  LLVM_IR,
+
+  ///@{ Languages that the frontend can parse and compile.
+  C,
+  CXX,
+  ObjC,
+  ObjCXX,
+  OpenCL,
+  CUDA,
+  RenderScript,
+  HIP,
+  ///@}
+};
 
 enum LangFeatures {
   LineComment = (1 << 0),
@@ -35,22 +56,20 @@ enum LangFeatures {
   OpenCL = (1 << 14)
 };
 
-}
-
 /// LangStandard - Information about the properties of a particular language
 /// standard.
 struct LangStandard {
   enum Kind {
 #define LANGSTANDARD(id, name, lang, desc, features) \
 lang_##id,
-#include "clang/Frontend/LangStandards.def"
+#include "clang/Basic/LangStandards.def"
 lang_unspecified
   };
 
   const char *ShortName;
   const char *Description;
   unsigned Flags;
-  InputKind::Language Language;
+  clang::Language Language;

r367866 - [Driver] Properly use values-X[ca].o, values-xpg[46].o on Solaris

2019-08-05 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Aug  5 07:06:16 2019
New Revision: 367866

URL: http://llvm.org/viewvc/llvm-project?rev=367866&view=rev
Log:
[Driver] Properly use values-X[ca].o, values-xpg[46].o on Solaris

Builtins-*-sunos :: compiler_rt_logbf_test.c currently FAILs on Solaris, both 
SPARC and
x86, 32 and 64-bit.

It turned out that this is due to different behaviour of logb depending on the C
standard compiled for, as documented on logb(3M):

  RETURN VALUES
 Upon successful completion, these functions return the exponent of x.
  
 If x is subnormal:
  
 o  For SUSv3-conforming applications compiled with the c99 com-
piler  driver  (see standards(7)), the exponent of x as if x
were normalized is returned.
  
 o  Otherwise, if compiled with the cc compiler  driver,  -1022,
-126,  and  -16382  are  returned  for  logb(), logbf(), and
logbl(), respectively.

Studio c99 and gcc control this by linking with the appropriate version of 
values-xpg[46].o, but clang uses neither of those.

The following patch fixes this by following what gcc does, as corrected some 
time ago in

  Fix use of Solaris values-Xc.o (PR target/40411)
  https://gcc.gnu.org/ml/gcc-patches/2018-01/msg02350.html and
  https://gcc.gnu.org/ml/gcc-patches/2018-01/msg02384.html.

Tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and 
x86_64-pc-linux-gnu.

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

Added:
cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-Xa.o
cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-Xc.o
cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-xpg4.o
cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-xpg6.o
cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/values-Xa.o
cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/values-Xc.o
cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/values-xpg4.o
cfe/trunk/test/Driver/Inputs/solaris_x86_tree/usr/lib/values-xpg6.o
cfe/trunk/test/Driver/solaris-ld-values.c
cfe/trunk/test/Driver/solaris-ld-values.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Solaris.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Solaris.cpp?rev=367866&r1=367865&r2=367866&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Solaris.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Solaris.cpp Mon Aug  5 07:06:16 2019
@@ -8,6 +8,7 @@
 
 #include "Solaris.h"
 #include "CommonArgs.h"
+#include "clang/Basic/LangStandard.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
@@ -86,8 +87,28 @@ void solaris::Linker::ConstructJob(Compi
   Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
 
 
CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crti.o")));
+
+const Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi);
+bool HaveAnsi = false;
+const LangStandard *LangStd = nullptr;
+if (Std) {
+  HaveAnsi = Std->getOption().matches(options::OPT_ansi);
+  if (!HaveAnsi)
+LangStd = LangStandard::getLangStandardForName(Std->getValue());
+}
+
+const char *values_X = "values-Xa.o";
+// Use values-Xc.o for -ansi, -std=c*, -std=iso9899:199409.
+if (HaveAnsi || (LangStd && !LangStd->isGNUMode()))
+  values_X = "values-Xc.o";
+
CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(values_X)));
+
+const char *values_xpg = "values-xpg6.o";
+// Use values-xpg4.o for -std=c90, -std=gnu90, -std=iso9899:199409.
+if (LangStd && LangStd->getLanguage() == Language::C && !LangStd->isC99())
+  values_xpg = "values-xpg4.o";
 CmdArgs.push_back(
-Args.MakeArgString(getToolChain().GetFilePath("values-Xa.o")));
+Args.MakeArgString(getToolChain().GetFilePath(values_xpg)));
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
   }

Added: cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-Xa.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-Xa.o?rev=367866&view=auto
==
(empty)

Added: cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-Xc.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-Xc.o?rev=367866&view=auto
==
(empty)

Added: cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-xpg4.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-xpg4.o?rev=367866&

r363985 - [test][Driver] Fix Clang :: Driver/cl-response-file.c

2019-06-20 Thread Rainer Orth via cfe-commits
Author: ro
Date: Thu Jun 20 14:33:09 2019
New Revision: 363985

URL: http://llvm.org/viewvc/llvm-project?rev=363985&view=rev
Log:
[test][Driver] Fix Clang :: Driver/cl-response-file.c

Clang :: Driver/cl-response-file.c currently FAILs on Solaris:

  Command Output (stderr):
  --
  /vol/llvm/src/clang/dist/test/Driver/cl-response-file.c:10:11: error: CHECK: 
expected string not found in input
  // CHECK: "-I" "{{.*}}\\Inputs\\cl-response-file\\" "-D" "FOO=2"
^

Looking at the generated response file reveals that this is no surprise:

  /I/vol/llvm/src/clang/dist/test/Driver\Inputs

with no newline at the end.  The echo command used to create it boils down to

  echo 'a\cb'

However, one cannot expect \c to be emitted literally: e.g. bash's builtin
echo has

  \csuppress further output

I've tried various combinations of builtin echo, /usr/bin/echo, GNU echo if
different, the same for printf, and the backslash unescaped and quoted
(a\cb and a\\cb).  The only combination that worked reliably on Solaris,
Linux, and macOS was

  printf 'a\\cb'

so this is what this patch uses.  Tested on amd64-pc-solaris2.11 and
x86_64-pc-linux-gnu.

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

Modified:
cfe/trunk/test/Driver/cl-response-file.c

Modified: cfe/trunk/test/Driver/cl-response-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-response-file.c?rev=363985&r1=363984&r2=363985&view=diff
==
--- cfe/trunk/test/Driver/cl-response-file.c (original)
+++ cfe/trunk/test/Driver/cl-response-file.c Thu Jun 20 14:33:09 2019
@@ -4,7 +4,7 @@
 
 
 
-// RUN: echo '/I%S\Inputs\cl-response-file\ /DFOO=2' > %t.rsp
+// RUN: printf '/I%S\Inputs\\cl-response-file\ /DFOO=2' > %t.rsp
 // RUN: %clang_cl /c -### @%t.rsp -- %s 2>&1 | FileCheck %s
 
 // CHECK: "-I" "{{.*}}\\Inputs\\cl-response-file\\" "-D" "FOO=2"


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


Re: r363985 - [test][Driver] Fix Clang :: Driver/cl-response-file.c

2019-06-21 Thread Rainer Orth via cfe-commits
Hi Douglas,

> Your change appears to have broken the one platform you didn't test, Windows. 
> :)

sorry about that.  Unfortunately, I know next to nothing about Windows
and don't have access to any system to test.

That said...

> Script:
> --
> : 'RUN: at line 7'; printf
> '/IC:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\Inputs\\cl-response-file\
> /DFOO=2' >
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Driver\Output\cl-response-file.c.tmp.rsp

... I should have looked at the autoconf manual first which has a whole
section on the can of worms that is echo and how to properly use printf
instead.

> Looking into this locally, the path contains "\t", so the response file that 
> is generated looks like this:
>
> C:\src\git\merge\llvm\tools\clang\test\Driver>type cl-response-file.c.tmp.rsp
> /IC:\src\git\merge\llvm ools

The path not only contains \t, but \c as well, so the path is truncated
after " ools".

> Can you take a look to see if there is something that works for all platforms 
> including Windows?

Judging from both the autoconf manual and my local testing, the
following should work properly:

// RUN: printf '%s\n' '/I%S\Inputs\\cl-response-file\ /DFOO=2' > %t.rsp

i.e. use printf '%s\n' to do the printing.  I should have done this in
the first place since otherwise the response file wasn't
newline-terminated.  Obviously that didn't matter on Solaris and Linux.

Once you've confirmed this works on Windows, I'll submit a proper
follow-up patch.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r363985 - [test][Driver] Fix Clang :: Driver/cl-response-file.c

2019-06-24 Thread Rainer Orth via cfe-commits
Hi Douglas,

> I figured it out. Because you are using printf, you no longer need the
> '\\c'. If I use the following RUN line, the test passes on both
> Windows/linux (I don't have solaris to test unfortunately):
>
> // RUN: printf '%%s\n' '/I%S\Inputs\cl-response-file\ /DFOO=2' > %t.rsp

I've now tested it myself successfully on amd64-pc-solaris2.11.  I'd
figured the \\c -> \c part out already, but had to leave before
understanding the %s problem.

> I can submit this patch for you if you would like.

That would be great, thanks a lot.

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


r365396 - [Sanitizers] Don't use clang_rt.sancov_{begin, end} on Solaris

2019-07-08 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Jul  8 15:04:25 2019
New Revision: 365396

URL: http://llvm.org/viewvc/llvm-project?rev=365396&view=rev
Log:
[Sanitizers] Don't use clang_rt.sancov_{begin,end} on Solaris

As explained in https://reviews.llvm.org/D63601, there's no point using 
clang_rt.sancov_{begin,end}
on Solaris any longer.

This companion patch to the above removes their use from the driver.

Tested on amd64-pc-solaris2.11

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Solaris.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Solaris.cpp?rev=365396&r1=365395&r2=365396&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Solaris.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Solaris.cpp Mon Jul  8 15:04:25 2019
@@ -96,13 +96,6 @@ void solaris::Linker::ConstructJob(Compi
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
   }
 
-  // Provide __start___sancov_guards.  Solaris ld doesn't automatically create
-  // __start_SECNAME labels.
-  CmdArgs.push_back("--whole-archive");
-  CmdArgs.push_back(
-  getToolChain().getCompilerRTArgString(Args, "sancov_begin"));
-  CmdArgs.push_back("--no-whole-archive");
-
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
@@ -131,13 +124,6 @@ void solaris::Linker::ConstructJob(Compi
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
   }
 
-  // Provide __stop___sancov_guards.  Solaris ld doesn't automatically create
-  // __stop_SECNAME labels.
-  CmdArgs.push_back("--whole-archive");
-  CmdArgs.push_back(
-  getToolChain().getCompilerRTArgString(Args, "sancov_end"));
-  CmdArgs.push_back("--no-whole-archive");
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));


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


r330572 - [Solaris] __float128 is supported on Solaris/x86

2018-04-23 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Apr 23 02:28:08 2018
New Revision: 330572

URL: http://llvm.org/viewvc/llvm-project?rev=330572&view=rev
Log:
[Solaris] __float128 is supported on Solaris/x86

When rebasing https://reviews.llvm.org/D40898 with GCC 5.4 on Solaris 11.4, I 
ran
into a few instances of

In file included from 
/vol/llvm/src/compiler-rt/local/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc:19:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/string:40:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/char_traits.h:39:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/stl_algobase.h:64:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/stl_pair.h:59:
In file included from 
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/bits/move.h:57:
/usr/gcc/5/lib/gcc/x86_64-pc-solaris2.11/5.4.0/../../../../include/c++/5.4.0/type_traits:311:39:
 error: __float128 is not supported on this target

  struct __is_floating_point_helper<__float128>
^

during make check-all.  The line above is inside

#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)

  template<>
struct __is_floating_point_helper<__float128>
: public true_type { };

#endif

While the libstdc++ header indicates support for __float128, clang does not, but
should.  The following patch implements this and fixed those errors.

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

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/CodeGenCXX/float128-declarations.cpp

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=330572&r1=330571&r2=330572&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Mon Apr 23 02:28:08 2018
@@ -552,12 +552,22 @@ protected:
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");
 Builder.defineMacro("_REENTRANT");
+if (this->HasFloat128)
+  Builder.defineMacro("__FLOAT128__");
   }
 
 public:
   SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : OSTargetInfo(Triple, Opts) {
 // FIXME: WIntType should be SignedLong
+switch (Triple.getArch()) {
+default:
+  break;
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  this->HasFloat128 = true;
+  break;
+}
   }
 };
 

Modified: cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/float128-declarations.cpp?rev=330572&r1=330571&r2=330572&view=diff
==
--- cfe/trunk/test/CodeGenCXX/float128-declarations.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/float128-declarations.cpp Mon Apr 23 02:28:08 2018
@@ -12,6 +12,10 @@
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 // RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple i386-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-solaris2.11 -std=c++11 \
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 //
 /*  Various contexts where type __float128 can appear. The different check
 prefixes are due to different mangling on X86 and different calling


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


[clang] 7109494 - [clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos

2020-08-06 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2020-08-06T10:47:16+02:00
New Revision: 710949482edb96a329104317164909979f2387aa

URL: 
https://github.com/llvm/llvm-project/commit/710949482edb96a329104317164909979f2387aa
DIFF: 
https://github.com/llvm/llvm-project/commit/710949482edb96a329104317164909979f2387aa.diff

LOG: [clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos

`ninja check-all` currently fails on Illumos:

  [84/716] Generating default/Asan-i386-inline-Test
  FAILED: projects/compiler-rt/lib/asan/tests/default/Asan-i386-inline-Test
  cd /var/llvm/dist-amd64-release/projects/compiler-rt/lib/asan/tests && 
/var/llvm/dist-amd64-release/./bin/clang 
ASAN_INST_TEST_OBJECTS.gtest-all.cc.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_globals_test.cpp.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_interface_test.cpp.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_internal_interface_test.cpp.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_test.cpp.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_oob_test.cpp.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_mem_test.cpp.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_str_test.cpp.i386-inline.o 
ASAN_INST_TEST_OBJECTS.asan_test_main.cpp.i386-inline.o -o 
/var/llvm/dist-amd64-release/projects/compiler-rt/lib/asan/tests/default/./Asan-i386-inline-Test
 -g --driver-mode=g++ -fsanitize=address -m32
  ld: fatal: unrecognized option '--no-as-needed'
  ld: fatal: use the -z help option for usage information
  clang-11: error: linker command failed with exit code 1 (use -v to see 
invocation)

`clang` unconditionally passes `--as-needed`/`--no-as-needed` to the
linker.  This works on Solaris 11.[34] which added a couple of option
aliases to the native linker to improve compatibility with GNU `ld`.
Illumos `ld` didn't do this, so one needs to use the corresponding
native options `-z ignore`/`-z record` instead.

Because this works on both Solaris and Illumos, the current patch always
passes the native options on Solaris.  This isn't fully correct, however:
when using GNU `ld` on Solaris (not yet supported; I'm working on that),
one still needs `--as-needed` instead.

I'm hardcoding this decision because a generic detection via a `cmake` test
is hard: many systems have their own implementation of `getDefaultLinker`
and `cmake` would have to duplicate the information encoded there.
Besides, it would still break when `-fuse-ld` is used.

Tested on `amd64-pc-solaris2.11` (Solaris 11.4 and OpenIndiana 2020.04),
`sparcv9-sun-solaris2.11`, and `x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index acde6d9e2111..bb88dd405c67 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -630,6 +630,16 @@ static bool addSanitizerDynamicList(const ToolChain &TC, 
const ArgList &Args,
   return false;
 }
 
+static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
+  // While the Solaris 11.2 ld added --as-needed/--no-as-needed as aliases
+  // for the native forms -z ignore/-z record, they are missing in Illumos,
+  // so always use the native form.
+  if (TC.getTriple().isOSSolaris())
+return as_needed ? "-zignore" : "-zrecord";
+  else
+return as_needed ? "--as-needed" : "--no-as-needed";
+}
+
 void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
  ArgStringList &CmdArgs) {
   // Fuchsia never needs these.  Any sanitizer runtimes with system
@@ -639,7 +649,7 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
 
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
-  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back(getAsNeededOption(TC, false));
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
   !TC.getTriple().isAndroid()) {
@@ -836,7 +846,7 @@ bool tools::addXRayRuntime(const ToolChain&TC, const 
ArgList &Args, ArgStringLis
 }
 
 void tools::linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
-  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back(getAsNeededOption(TC, false));
   CmdArgs.push_back("-lpthread");
   if (!TC.getTriple().isOSOpenBSD())
 CmdArgs.push_back("-lrt");
@@ -1261,7 +1271,7 @@ static void AddUnwindLibrary(const ToolChain &TC, const 
Driver &D,
   bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc &&
   !TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing();
   if (AsNeeded)
-CmdArgs.push_back("--as-needed");
+CmdArgs.push_back(getAsNeededOption(TC, true));
 
   switch (UNW) {
   case ToolChain::UNW_None:
@@ -1289,7 +1299,7 @@ static void AddUnwindLibrary(const ToolChain &TC, c

[clang] f59bec7 - [clang][Driver] Default to /usr/bin/ld on Solaris

2020-08-13 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2020-08-13T22:42:58+02:00
New Revision: f59bec7acb8228fc215fca3ee1e524c38083c50b

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

LOG: [clang][Driver] Default to /usr/bin/ld on Solaris

`clang` currently requires the native linker on Solaris:

  - It passes `-C` to `ld` which GNU `ld` doesn't understand.

  - To use `gld`, one needs to pass the correct `-m EMU` option to select
the right emulation.  Solaris `ld` cannot handle that option.

So far I've worked around this by passing `-DCLANG_DEFAULT_LINKER=/usr/bin/ld`
to `cmake`.  However, if someone forgets this, it depends on the user's
`PATH` whether or not `clang` finds the correct linker, which doesn't make
for a good user experience.

While it would be nice to detect the linker flavor at runtime, this is more
involved.  Instead, this patch defaults to `/usr/bin/ld` on Solaris.  This
doesn't work on its own, however: a link fails with

  clang-12: error: unable to execute command: Executable 
"x86_64-pc-solaris2.11-/usr/bin/ld" doesn't exist!

I avoid this by leaving absolute paths alone in `ToolChain::GetLinkerPath`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

Added: 
clang/test/Driver/solaris-ld-sld.c

Modified: 
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Solaris.h
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2984537c23b4..7be83cade93a 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -568,8 +568,13 @@ std::string ToolChain::GetLinkerPath() const {
   }
   // If we're passed -fuse-ld= with no argument, or with the argument ld,
   // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath(getDefaultLinker());
+  if (UseLinker.empty() || UseLinker == "ld") {
+const char *DefaultLinker = getDefaultLinker();
+if (llvm::sys::path::is_absolute(DefaultLinker))
+  return std::string(DefaultLinker);
+else
+  return GetProgramPath(DefaultLinker);
+  }
 
   // Extending -fuse-ld= to an absolute or relative path is unexpected. 
Checking
   // for the linker flavor is brittle. In addition, prepending "ld." or "ld64."

diff  --git a/clang/lib/Driver/ToolChains/Solaris.h 
b/clang/lib/Driver/ToolChains/Solaris.h
index b79e626ef38d..fbac92c2c0f3 100644
--- a/clang/lib/Driver/ToolChains/Solaris.h
+++ b/clang/lib/Driver/ToolChains/Solaris.h
@@ -65,6 +65,11 @@ class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_ELF {
   SanitizerMask getSupportedSanitizers() const override;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
+  const char *getDefaultLinker() const override {
+// clang currently uses Solaris ld-only options.
+return "/usr/bin/ld";
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;

diff  --git a/clang/test/Driver/solaris-ld-sld.c 
b/clang/test/Driver/solaris-ld-sld.c
new file mode 100644
index ..f65153784b76
--- /dev/null
+++ b/clang/test/Driver/solaris-ld-sld.c
@@ -0,0 +1,7 @@
+// REQUIRES: system-solaris
+
+// Check that clang invokes the native ld.
+
+// RUN: test -f /usr/gnu/bin/ld && env PATH=/usr/gnu/bin %clang -o %t.o %s
+
+int main() { return 0; }

diff  --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index db557a7b1fef..e9fd75e0a5fa 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -59,6 +59,8 @@ def __init__(self, lit_config, config):
 features.add('system-netbsd')
 elif platform.system() == 'AIX':
 features.add('system-aix')
+elif platform.system() == 'SunOS':
+features.add('system-solaris')
 
 # Native compilation: host arch == default triple arch
 # Both of these values should probably be in every site config (e.g. as



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


[clang] 1e56821 - [Linux] Hack around Linux/sparc

2022-09-10 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2022-09-10T09:37:35+02:00
New Revision: 1e56821bac02a5d3c6249bbf3ef43b8b569d2551

URL: 
https://github.com/llvm/llvm-project/commit/1e56821bac02a5d3c6249bbf3ef43b8b569d2551
DIFF: 
https://github.com/llvm/llvm-project/commit/1e56821bac02a5d3c6249bbf3ef43b8b569d2551.diff

LOG: [Linux] Hack around Linux/sparc 

I've been using this hack to work around the Linux/sparc64 compile failure
described in Issue #47994
, especially since the
underlying glibc PR build/27558
 doesn't seem to be
making progress and some fix is required to have LLVM build on
`sparc64-unknown-linux-gnu` at all, as evidenced on the buildbot.

Tested on `sparc64-unknown-linux-gnu`.

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

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 54e66b5bd9e1f..c75f7d9fbafeb 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -388,6 +388,9 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
 } else {
 Builder.defineMacro("__gnu_linux__");
 }
+// Work around Issue #47994 until glibc PR build/27558 is fixed.
+if (Triple.isSPARC())
+  Builder.defineMacro("__NO_INLINE__");
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
 if (Opts.CPlusPlus)

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index e3a24824ff190..028f3448f8bda 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -874,6 +874,9 @@
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT %s
+// Check that clang defines __NO_INLINE__ unconditionally (even at -O) to
+// work around Issue #47994.
+// RUN: %clang_cc1 -E -dM -triple=sparc-unknown-linux-gnu -O < /dev/null | 
FileCheck -match-full-lines -check-prefix SPARC-LINUX %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT -check-prefix SPARC-DEFAULT-CXX %s
 //
@@ -997,6 +1000,7 @@
 // SPARC:#define __LONG_LONG_MAX__ 9223372036854775807LL
 // SPARC:#define __LONG_MAX__ 2147483647L
 // SPARC-NOT:#define __LP64__
+// SPARC-LINUX:#define __NO_INLINE__ 1
 // SPARC:#define __POINTER_WIDTH__ 32
 // SPARC-DEFAULT:#define __PTRDIFF_TYPE__ int
 // SPARC-NETOPENBSD:#define __PTRDIFF_TYPE__ long int
@@ -1380,6 +1384,11 @@
 // SPARCV9:#define __SIZEOF_POINTER__ 8
 // SPARCV9:#define __UINTPTR_TYPE__ long unsigned int
 //
+// Check that clang defines __NO_INLINE__ unconditionally (even at -O) to
+// work around Issue #47994.
+// RUN: %clang_cc1 -E -dM -triple=sparc64-unknown-linux-gnu -O < /dev/null | 
FileCheck -match-full-lines -check-prefix SPARC64-LINUX %s
+// SPARC64-LINUX:#define __NO_INLINE__ 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-openbsd < 
/dev/null | FileCheck -match-full-lines -check-prefix SPARC64-OBSD %s
 // SPARC64-OBSD:#define __INT64_TYPE__ long long int
 // SPARC64-OBSD:#define __INTMAX_C_SUFFIX__ LL



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


[clang] Perf/lexer faster slow get char and size (PR #70543)

2023-10-29 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch broke builders like 
[Solaris/amd64](https://lab.llvm.org/staging/#/builders/8/builds/761) that 
include `clang-tools-extra`.

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


[libunwind] [compiler-rt] [mlir] [llvm] [lld] [flang] [lldb] [libcxx] [libcxxabi] [clang] [libc] [clang-tools-extra] [asan] Install `pthread_atfork` (PR #75290)

2023-12-15 Thread Rainer Orth via cfe-commits

rorth wrote:

Since this patch, all asan tests loop on Solaris.  This had been hidden for a 
bit by an unrelated extended build breakage on the bots, but now every `ninja 
check-all` on the Solaris/amd64 bot times out.  I could trace this to this 
patch.

E.g. when running 
`projects/compiler-rt/test/asan/I386SunOSConfig/TestCases/Output/alloca_big_alignment.cpp.tmp`,
 I get the expected output
```
=
==3==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 
0xfeffd88a at pc 0x0812907d bp 0xfeffd7f4 sp 0xfeffd7ec
WRITE of size 1 at 0xfeffd88a thread T0
```
and afterwards the test loops.  `truss` shows an unending series of
```
22210:  yield() = 0
22210:  yield() = 0
22210:  yield() = 0
```
and `pstack` gives
```
22213:  /var/llvm/local-amd64-release-stage2-A-flang-492214/tools/clang/stage2
 fdfbebc5 yield(0x8139158, 0x8109558, 0x818a580, 0x0, 0x5dd, 0x8139158) + 15
 0810cd32 __sanitizer::FutexWait(__sanitizer::atomic_uint32_t*, unsigned int) 
(0xfe00a000, 0xfdebdd56, 0x805ad7c, 0xfdfa0107, 0xfeffc68c, 0x5) + 12
 080f4952 __asan::InstallAtForkHandler()::$_0::__invoke() (0xfde26fc0, 0x7, 
0xfe010200, 0xfe010140, 0x7, 0x5) + 12
 fdfa49c8 forkx(0x0, 0xfe5ad000, 0x89f, 0xfdfa4b8c) + c8
 fdfa4b9d fork (0x8139158, 0x811563e, 0xfeffc720, 0xfd6007a0, 0x4, 
0x8139158) + 1d
 0810ccd2 __sanitizer::internal_fork() () + 12
```
This seems no wonder given that `sanitizer_common/sanitizer_solaris.cpp` has
```
void FutexWait(atomic_uint32_t *p, u32 cmp) {
  // FIXME: implement actual blocking.
  sched_yield();
}
```
`sanitizer_mac.cpp` is the same, btw., and even `sanitizer_linux.cpp` has
```
#  if !SANITIZER_SOLARIS
void FutexWait(atomic_uint32_t *p, u32 cmp) {
#if SANITIZER_FREEBSD
  _umtx_op(p, UMTX_OP_WAIT_UINT, cmp, 0, 0);
#elif SANITIZER_NETBSD
  sched_yield(); /* No userspace futex-like synchronization */
#else
  internal_syscall(SYSCALL(futex), (uptr)p, FUTEX_WAIT_PRIVATE, cmp, 0, 0, 0);
#endif
}
```
so even NetBSD would be affected.

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


[libcxx] [libc] [clang] [lldb] [libcxxabi] [libunwind] [lld] [compiler-rt] [llvm] [clang-tools-extra] [flang] [mlir] [asan] Install `pthread_atfork` (PR #75290)

2023-12-19 Thread Rainer Orth via cfe-commits

rorth wrote:

It took me a bit to notice this snippet in `sanitizer_solaris.cpp`:
```
DECLARE__REAL_AND_INTERNAL(int, fork, void) {
  // TODO(glider): this may call user's pthread_atfork() handlers which is bad.
  return _REAL(fork)();
}
```
which didn't show up in searches for `internal_fork`.

>From what I could learn from `libc` disassembly and the OpenSolaris sources, 
>the only way to avoid the handlers on Solaris is to invoke the syscall 
>directly.  This is highly unportable, however: syscalls are an implemention 
>detail that can (and **does**) change.  There's reasonable hope that this 
>won't happen for the remaining livetime of Solaris 11.4, though.

I'll give such a patch a try...

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


[clang] [compiler-rt] [clang-tools-extra] [mlir] [libunwind] [libcxxabi] [llvm] [lldb] [libcxx] [flang] [lld] [libc] [asan] Install `pthread_atfork` (PR #75290)

2023-12-21 Thread Rainer Orth via cfe-commits

rorth wrote:

> I'll give such a patch a try...

That would be something like
```
int internal_fork(void) {
  // Call syscall directly to avoid pthread_atfork handler processing.
  //
  // This is highly unportable on Solaris since syscalls are an implementation
  // detail subject to change.
  return syscall(SYS_forksys, 0, 0);
}
```
Unfortunately, this fails miserably: at least every asan test that invokes the 
`llvm-symbolizer` fails like
```
==4030==Launching Symbolizer process: /usr/bin/llvm-symbolizer --demangle 
--inlines --default-arch=i386 
==4031==Waiting on the process failed (errno 10).
==4031==WARNING: external symbolizer didn't start up correctly!
```
>From all I could learn from the OpenSolaris `libc` code 
>(`lib/libc/port/threads/scalls.c` (`forkx`), it seems that there happens so 
>much processing on `libc`-internal data structures that cannot simply be 
>skipped that there's no reasonable chance to run `fork` without the handlers.  
>Expecting to be able to seems to be hack that may work on some platforms, but 
>not on others.

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


[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)

2024-01-08 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch broke the [Solaris/sparcv9 
buildbot](https://lab.llvm.org/buildbot/#/builders/72/builds/1709): the 
new/changed tests `FAIL` with
```
  File 
/opt/llvm-buildbot/home/solaris11-sparcv9/clang-solaris11-sparcv9/llvm/clang/test/SemaCXX/format-strings-scanf.cpp
 Line 25: _Float16 is not supported on this target
1 error generated.
```

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


[flang] [clang] [llvm] [clang-tools-extra] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2024-01-10 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch broke the Solaris build:
```
FAILED: tools/flang/runtime/CMakeFiles/obj.FortranRuntime.dir/extensions.cpp.o 
[...]
/vol/llvm/src/llvm-project/dist/flang/runtime/extensions.cpp:60:24: error: use 
of undeclared identifier 'LOGIN_NAME_MAX'
   60 |   const int nameMaxLen{LOGIN_NAME_MAX + 1};
  |^
/vol/llvm/src/llvm-project/dist/flang/runtime/extensions.cpp:61:12: warning: 
variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   61 |   char str[nameMaxLen];
  |^~
/vol/llvm/src/llvm-project/dist/flang/runtime/extensions.cpp:61:12: note: 
initializer of 'nameMaxLen' is unknown
/vol/llvm/src/llvm-project/dist/flang/runtime/extensions.cpp:60:13: note: 
declared here
   60 |   const int nameMaxLen{LOGIN_NAME_MAX + 1};
  | ^
1 warning and 1 error generated.
```
and
```
FAILED: 
tools/flang/unittests/Runtime/CMakeFiles/FlangRuntimeTests.dir/CommandTest.cpp.o
[...]
/vol/llvm/src/llvm-project/dist/flang/unittests/Runtime/CommandTest.cpp:530:21: 
error: use of undeclared identifier 'LOGIN_NAME_MAX' 
  530 |   const int charLen{LOGIN_NAME_MAX + 2};
  | ^
/vol/llvm/src/llvm-project/dist/flang/unittests/Runtime/CommandTest.cpp:531:14: 
warning: variable length arrays in C++ are a Clang extension 
[-Wvla-cxx-extension]
  531 |   char input[charLen];
  |  ^~~
/vol/llvm/src/llvm-project/dist/flang/unittests/Runtime/CommandTest.cpp:531:14: 
note: initializer of 'charLen' is unknown
/vol/llvm/src/llvm-project/dist/flang/unittests/Runtime/CommandTest.cpp:530:13: 
note: declared here
  530 |   const int charLen{LOGIN_NAME_MAX + 2};
  | ^
```
As documented in Solaris `limits.h(3HEAD)` (and exactly matching XPG7), 
`LOGIN_NAME_MAX` not being defined is an allowed configuration:
```
   Runtime Invariant Values (Possibly Indeterminate)
   A definition of one of the symbolic names  in  the  following  list  is
   omitted  fromon specific implementations where the corre-
   sponding value is equal to or greater than the stated minimum,  but  is
   unspecified.

   This  indetermination  might  depend  on the amount of available memory
   space on a specific instance of a specific implementation.  The  actual
   value  supported  by  a  specific  instance  will  be  provided  by the
   sysconf() function.
[...]
   LOGIN_NAME_MAX

   Maximum length of a login name.
```
So the code needs to fall back to `sysconf(_SC_LOGIN_NAME_MAX)` if 
`LOGIN_NAME_MAX` is not defined.

I've used the attached patch to implement this, which allowed the build and 
`ninja check-all` to finish.  I'm uncertain if support for `syscconf() == -1` 
is really necessary, though.
[lnm.txt](https://github.com/llvm/llvm-project/files/13887475/lnm.txt)


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


[clang] [clang-tools-extra] [flang] [llvm] [flang] GETLOG runtime and extension implementation: get login username (PR #74628)

2024-01-11 Thread Rainer Orth via cfe-commits

rorth wrote:

Sure: I've just created one slightly changed from the attached patch: [[flang] 
Handle missing LOGIN_NAME_MAX definition in 
runtime](https://github.com/llvm/llvm-project/pull/5)

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


[clang] 9b1897b - [Driver] Use libatomic for 32-bit SPARC atomics support on Linux

2022-07-29 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2022-07-29T09:19:38+02:00
New Revision: 9b1897bbd0e3a6e9ef099e74c3d3ed35428c0460

URL: 
https://github.com/llvm/llvm-project/commit/9b1897bbd0e3a6e9ef099e74c3d3ed35428c0460
DIFF: 
https://github.com/llvm/llvm-project/commit/9b1897bbd0e3a6e9ef099e74c3d3ed35428c0460.diff

LOG: [Driver] Use libatomic for 32-bit SPARC atomics support on Linux

This is the Linux/sparc64 equivalent to D118021
, necessary to provide an external
implementation of atomics on 32-bit SPARC which LLVM cannot inline even
with `-mcpu=v9` or an equivalent default.

Tested on `sparc64-unknown-linux-gnu`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 34396b0b59c2..f203cae1d329 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -631,6 +631,16 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+  // LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
+  // forcibly link with libatomic as a workaround.
+  // TODO: Issue #41880 and D118021.
+  if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
+CmdArgs.push_back("--push-state");
+CmdArgs.push_back("--as-needed");
+CmdArgs.push_back("-latomic");
+CmdArgs.push_back("--pop-state");
+  }
+
   if (WantPthread && !isAndroid)
 CmdArgs.push_back("-lpthread");
 

diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index d7c58431fa76..e76b35d6137c 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -1007,6 +1007,7 @@
 // CHECK-SPARCV8: "{{.*}}ld{{(.exe)?}}"
 // CHECK-SPARCV8: "-m" "elf32_sparc"
 // CHECK-SPARCV8: "-dynamic-linker" 
"{{(/usr/sparc-unknown-linux-gnu)?}}/lib/ld-linux.so.2"
+// CHECK-SPARCV8: "--push-state" "--as-needed" "-latomic" "--pop-state"
 //
 // RUN: %clang -### %s -no-pie 2>&1 \
 // RUN: --target=sparcel-unknown-linux-gnu \
@@ -1021,6 +1022,7 @@
 // CHECK-SPARCV9: "{{.*}}ld{{(.exe)?}}"
 // CHECK-SPARCV9: "-m" "elf64_sparc"
 // CHECK-SPARCV9: "-dynamic-linker" 
"{{(/usr/sparcv9-unknown-linux-gnu)?}}/lib{{(64)?}}/ld-linux.so.2"
+// CHECK-SPARCV9-NOT: "-latomic"
 
 // Test linker invocation on Android.
 // RUN: %clang -### %s -no-pie 2>&1 \



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


[clang] bf37148 - [clang][Driver] Handle SPARC -mcpu=native etc.

2022-07-29 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2022-07-29T09:27:09+02:00
New Revision: bf3714884ae4b4a0301bc6af78e8b4deff12558b

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

LOG: [clang][Driver] Handle SPARC -mcpu=native etc.

To make use of SPARC support in `getHostCPUName` as implemented by D130272
, this patch uses it to handle
`-mcpu=native` and `-mtune=native`.  To match GCC, this patch rejects
`-march` instead of silently treating it as a no-op.

Tested on `sparcv9-sun-solaris2.11` and checking that those options are
passed on as `-target-cpu` resp. `-tune-cpu` as expected.

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

Added: 
clang/test/Driver/sparc-march.c
clang/test/Driver/sparc-mcpu.c
clang/test/Driver/sparc-mtune.c

Modified: 
clang/lib/Driver/ToolChains/Arch/Sparc.cpp
clang/lib/Driver/ToolChains/Arch/Sparc.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp 
b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index 70ba8eb2a7d0..2c9d65e7714a 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -12,6 +12,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -113,6 +114,30 @@ sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
   return ABI;
 }
 
+std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
+ const llvm::Triple &Triple) {
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getSpelling() << Triple.getTriple();
+return "";
+  }
+
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
+StringRef CPUName = A->getValue();
+if (CPUName == "native") {
+  std::string CPU = std::string(llvm::sys::getHostCPUName());
+  if (!CPU.empty() && CPU != "generic")
+return CPU;
+  return "";
+}
+return std::string(CPUName);
+  }
+
+  if (Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris())
+return "v9";
+  return "";
+}
+
 void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args,
std::vector &Features) {
   sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args);

diff  --git a/clang/lib/Driver/ToolChains/Arch/Sparc.h 
b/clang/lib/Driver/ToolChains/Arch/Sparc.h
index d12a9a70e264..44658c4259c6 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.h
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.h
@@ -28,6 +28,9 @@ enum class FloatABI {
 
 FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
+std::string getSparcTargetCPU(const Driver &D, const llvm::opt::ArgList &Args,
+  const llvm::Triple &Triple);
+
 void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
 std::vector &Features);
 const char *getSparcAsmModeForCPU(llvm::StringRef Name,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index e94a4e814510..f41d6f4228b6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2213,6 +2213,18 @@ void Clang::AddSparcTargetArgs(const ArgList &Args,
 CmdArgs.push_back("-mfloat-abi");
 CmdArgs.push_back("hard");
   }
+
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
+StringRef Name = A->getValue();
+std::string TuneCPU;
+if (Name == "native")
+  TuneCPU = std::string(llvm::sys::getHostCPUName());
+else
+  TuneCPU = std::string(Name);
+
+CmdArgs.push_back("-tune-cpu");
+CmdArgs.push_back(Args.MakeArgString(TuneCPU));
+  }
 }
 
 void Clang::AddSystemZTargetArgs(const ArgList &Args,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 05afa712a809..77ce0395cf3c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -12,6 +12,7 @@
 #include "Arch/M68k.h"
 #include "Arch/Mips.h"
 #include "Arch/PPC.h"
+#include "Arch/Sparc.h"
 #include "Arch/SystemZ.h"
 #include "Arch/VE.h"
 #include "Arch/X86.h"
@@ -431,15 +432,15 @@ std::string tools::getCPUName(const Driver &D, const 
ArgList &Args,
 
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
-  case llvm::Triple::sparc:
-  case llvm::Triple::sparcel:
-  case llvm::Triple::sparcv9:
 if (const Arg *A = Args.getLastArg(options::OPT

[clang] a6afa9e - [Driver] Use libatomic for 32-bit SPARC atomics support

2022-02-10 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2022-02-10T12:40:32+01:00
New Revision: a6afa9e6b0d9a08ecc878e62343a2af80ff30435

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

LOG: [Driver] Use libatomic for 32-bit SPARC atomics support

Even after D86621 , `clang -m32` on
Solaris/sparcv9 doesn't inline atomics with 8-byte operands, unlike `gcc`.
This leads to many link failures in the testsuite (undefined references to
`__atomic_load_8` and `__sync_val_compare_and_swap_8`.  Until a proper
codegen fix can be implemented, this patch works around the first of those
by linking with `-latomic`.

Tested on `sparcv9-sun-solaris2.11`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 40364d23c5599..71f5bd7cb2820 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -756,7 +756,7 @@ static bool addSanitizerDynamicList(const ToolChain &TC, 
const ArgList &Args,
   return false;
 }
 
-static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
+const char *tools::getAsNeededOption(const ToolChain &TC, bool as_needed) {
   assert(!TC.getTriple().isOSAIX() &&
  "AIX linker does not support any form of --as-needed option yet.");
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 646fa76949b78..23012dc247e41 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -117,6 +117,8 @@ bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, 
const ToolChain &TC,
   bool ForceStaticHostRuntime = false,
   bool IsOffloadingHost = false, bool GompNeedsRT = false);
 
+const char *getAsNeededOption(const ToolChain &TC, bool as_needed);
+
 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
 llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
 

diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 4d1af094f4814..24f18b92dd661 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -132,6 +132,13 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-lssp_nonshared");
   CmdArgs.push_back("-lssp");
 }
+// LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
+// forcibly link with libatomic as a workaround.
+if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), true));
+  CmdArgs.push_back("-latomic");
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), false));
+}
 CmdArgs.push_back("-lgcc_s");
 CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 59d03c4d82253..d40e5dac2da9e 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -17,6 +17,7 @@
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
 // CHECK-LD-SPARC32-SAME: "-lgcc_s"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
@@ -40,6 +41,7 @@
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
+// CHECK-LD-SPARC64-NOT:  "-latomic"
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
 // CHECK-LD-SPARC64-SAME: "-lgcc"
@@ -63,6 +65,7 @@
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-X32-NOT:  "-latomic"
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
 // CHECK-LD-X32-SAME: "-lgcc"
@@ -86,6 +89,7 @@
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.

[clang] [clang][CodeGen] Emit atomic IR in place of optimized libcalls. (PR #73176)

2024-02-13 Thread Rainer Orth via cfe-commits

rorth wrote:

I'm pretty certain this patch broke the [Solaris/sparcv9 
buildbot](https://lab.llvm.org/buildbot/#/builders/72/builds/2541).

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


[clang] [clang][CodeGen] Emit atomic IR in place of optimized libcalls. (PR #73176)

2024-02-13 Thread Rainer Orth via cfe-commits

rorth wrote:

Confirmed: reverting the patch locally restores the build.

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


[clang] [clang][CodeGen] Emit atomic IR in place of optimized libcalls. (PR #73176)

2024-02-13 Thread Rainer Orth via cfe-commits

rorth wrote:

The libcalls per se wouldn't be a problem since on 32-bit Solaris/sparc 
`-latomic` is always linked due to that.  However, the `__sync_*` libcalls 
aren't defined in `libatomic.so`, thus the link failure.

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


[clang] [clang] Add GCC-compatible code model names for sparc64 (PR #79485)

2024-01-26 Thread Rainer Orth via cfe-commits

rorth wrote:

GCC also supports `-mcmodel=embmedany`.  Maybe it would be good to reject that 
with a clear message?

As for the generated code (not this PR, I'd say), it would certainly be good to 
test that on some larger code base (like LLVM itself) and, preferably, also 
test actual interoperability with GCC. Especially in SPARC support, I have seen 
to many cases where LLVM wouldn't interoperate with itself, let alone GCC.

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


[clang] [clang] Add GCC-compatible code model names for sparc64 (PR #79485)

2024-01-26 Thread Rainer Orth via cfe-commits

rorth wrote:

> `embmedany` is already rejected by the driver at the moment:
> 
> ```
> error: unsupported argument 'embmedany' to option '-mcmodel=' for target 
> 'sparc64'
> ```
Seems sensible indeed.
> On the testing issue, however, would compiling LLVM with each of the code 
> models + running codegen tests be enough to at least exercise the relevant 
> parts (and see if there's still issues, etc.)?

I'd run 2-stage builds/tests (either with the existing machinery or by building 
LLVM twice explicitly: once with an external compiler and then again with the 
just-built one).


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


[clang] [llvm] [LLVM][DWARF] Fix accelerator table switching between CU and TU (PR #77511)

2024-01-12 Thread Rainer Orth via cfe-commits

rorth wrote:

However, the patch broke the [Solaris/sparcv9 
buildbot](https://lab.llvm.org/buildbot/#/builders/72/builds/1834):
```
llc: error: unable to get target for 'x86_64-unknown-linux-gnu', see --version 
and --triple.
```
The bot is configured to do a Sparc-only build.

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


[clang] [llvm] [CMake] Add support for building on illumos (PR #74930)

2024-01-18 Thread Rainer Orth via cfe-commits

rorth wrote:

I wonder what the current flurry of patdhes to support Illumos is about.  I'd 
originally filed Issue #53919 to make clear what's needed from the Illumos 
project to keep it as an LLVM target, given that they haven't contributed 
either bug reports, code or testing in a long time.  Without that, keeping 
Illumos somehow in a gray zone between supported and unsupported, this doubles 
my workload for Solaris patches:

- Whenever I add or remove a feature, I need to investigate what needs to be 
done on the Illumos side.
- Depending on the outcome, I need to add separate Illumos support code 
whenever it and Solaris differ.
- And ultimately, I need to test all my patches not only on Solaris, but also 
no Illumos.

This could only be avoided if the Illumos guys (or someone else) reliably 
perform those tasks instead.  However, I don't see any contributions from them, 
so the situation hasn't changed since the Issue was filed.

It also means that cleanup that could be done on the Solaris side (I'd like to 
rip out [[sanitizer_common] Support Solaris < 11.4 in 
GetStaticTlsBoundary](https://reviews.llvm.org/D120059) as soon as Solaris 11.3 
support has been ripped out from GCC; 11.4 doesn't need it, but Illumos would 
AFAIK).

I'm perfectly happy to work with them to develop code that works on both 
variants (Illumos and Solaris), but I'm opposed to have untested/barely tested 
code in that creates massive work for me.

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


[compiler-rt] [clang-tools-extra] [clang] [PGO] Reland PGO's Counter Reset and File Dumping APIs #76471 (PR #78285)

2024-01-22 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch broke both the 
[Solaris/sparcv9](https://lab.llvm.org/buildbot/#/builders/72/builds/2015) and 
[Solaris/amd64](https://lab.llvm.org/staging/#/builders/94/builds/394) 
buildbots.

If it really requires recent `lld`, this is guaranteed to not work: `lld` 
hasn't even been ported to Solaris.  Similar issues most likely will exist on 
other targets where the bot either doesn't build `lld` or it isn't supported at 
all.

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits


@@ -2,8 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX

rorth wrote:

Done: since I'd already touched almost half the instances, I changed them all 
for consistency.

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits


@@ -21,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main

rorth wrote:

Right: they fit nicely even with the double quotes.  To avoid swamping the 
patch with unrelated changes, I've only adjusted the `UNIX` case.

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits

https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/65644

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH 1/3] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

>From bf1b865045ed4f484f24746aa18405d93e760979 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Tue, 17 Oct 2023 20:43:23 +0200
Subject: [PATCH 2/3] Rename `GNU` label to `UNIX` to better match use.

---
 flang/test/Driver/linker-flags.f90 | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 717dcc7775e2126..fd61825eb4023a5 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -2,9 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
-! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and
@@ -22,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main
+! UNIX-SAME: -lFortranRuntime
+! UNIX-SAME: -lFortranDecimal
+! UNIX-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"

>From 5e7ca991bd8b87b754e982d9836460dc0f31e59f Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Wed, 18 Oct 2023 12:01:15 +0200
Subject: [PATCH 3/3] Use `--target=`.  Join `-l` lines for `UNIX` case.

---
 flang/test/Driver/linker-flags.f90 | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/te

[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-18 Thread Rainer Orth via cfe-commits

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


[clang] Let clang-cl support CUDA/HIP (PR #68921)

2023-10-23 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch also broke the [Solaris/amd64 
buildbot](https://lab.llvm.org/staging/#/builders/8/builds/484).  I suspect 
this happens because that one is configured with `-DLLVM_TARGETS_TO_BUILD=X86`, 
thus lacking cuda support.  In fact, when manually building with support for 
all targets, the test `PASS`es. Please fix.

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


[clang] [Driver] Fix -r handling on Solaris (PR #70322)

2023-10-26 Thread Rainer Orth via cfe-commits

https://github.com/rorth created https://github.com/llvm/llvm-project/pull/70322

As discussed in [[Driver] Link Flang runtime on 
Solaris](https://github.com/llvm/llvm-project/pull/65644), `clang -r` 
incorrectly passes both `-Bdynamic` and `-e _start` to `ld` which lets the 
linker choke.

This patch fixes this, omitting `-Bdynamic` completely which is the linker 
default.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

>From 8a98b2f79931cb6e29d2fced5c86cc555667e3ef Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 26 Oct 2023 14:00:50 +0200
Subject: [PATCH] [Driver] Fix -r handling on Solaris

As discussed in [[Driver] Link Flang runtime on
Solaris](https://github.com/llvm/llvm-project/pull/65644), `clang -r`
incorrectly passes both `-Bdynamic` and `-e _start` to `ld` which lets the
linker choke.

This patch fixes this, omitting `-Bdynamic` completely which is the linker
default.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 7 +++
 clang/test/Driver/solaris-ld.c  | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index ecff8ddc4ee766f..2b1ac5a7f475c5a 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -96,7 +96,8 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (!LinkerIsGnuLd)
 CmdArgs.push_back("-C");
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_shared)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_shared,
+   options::OPT_r)) {
 CmdArgs.push_back("-e");
 CmdArgs.push_back("_start");
   }
@@ -114,10 +115,8 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-Bstatic");
 CmdArgs.push_back("-dn");
   } else {
-CmdArgs.push_back("-Bdynamic");
-if (Args.hasArg(options::OPT_shared)) {
+if (!Args.hasArg(options::OPT_r) && Args.hasArg(options::OPT_shared))
   CmdArgs.push_back("-shared");
-}
 
 // libpthread has been folded into libc since Solaris 10, no need to do
 // anything for pthreads. Claim argument to avoid warning.
diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 09e6e8b4f07cf91..8f7f168c387214d 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -177,6 +177,7 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RELOCATABLE
 // CHECK-RELOCATABLE: "-L
 // CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-e"
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
 // CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o

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


[clang] [Driver] Fix -r handling on Solaris (PR #70322)

2023-10-26 Thread Rainer Orth via cfe-commits

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


[clang] 76e85ae - [clang][Sparc] Default to -mcpu=v9 for Sparc V8 on Solaris

2020-09-11 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2020-09-11T09:53:19+02:00
New Revision: 76e85ae268f8e64540703b0d1710d27ef0d36040

URL: 
https://github.com/llvm/llvm-project/commit/76e85ae268f8e64540703b0d1710d27ef0d36040
DIFF: 
https://github.com/llvm/llvm-project/commit/76e85ae268f8e64540703b0d1710d27ef0d36040.diff

LOG: [clang][Sparc] Default to -mcpu=v9 for Sparc V8 on Solaris

As reported in Bug 42535, `clang` doesn't inline atomic ops on 32-bit
Sparc, unlike `gcc` on Solaris.  In a 1-stage build with `gcc`, only two
testcases are affected (currently `XFAIL`ed), while in a 2-stage build more
than 100 tests `FAIL` due to this issue.

The reason for this `gcc`/`clang` difference is that `gcc` on 32-bit
Solaris/SPARC defaults to `-mpcu=v9` where atomic ops are supported, unlike
with `clang`'s default of `-mcpu=v8`.  This patch changes `clang` to use
`-mcpu=v9` on 32-bit Solaris/SPARC, too.

Doing so uncovered two bugs:

`clang -m32 -mcpu=v9` chokes with any Solaris system headers included:

  /usr/include/sys/isa_defs.h:461:2: error: "Both _ILP32 and _LP64 are defined"
  #error "Both _ILP32 and _LP64 are defined"

While `clang` currently defines `__sparcv9` in a 32-bit `-mcpu=v9`
compilation, neither `gcc` nor Studio `cc` do.  In fact, the Studio 12.6
`cc(1)` man page clearly states:

These predefinitions are valid in all modes:
  [...]
   __sparcv8 (SPARC)
   __sparcv9 (SPARC -m64)

At the same time, the patch defines `__GCC_HAVE_SYNC_COMPARE_AND_SWAP_[1248]`
for a 32-bit Sparc compilation with any V9 cpu.  I've also changed
`MaxAtomicInlineWidth` for V9, matching what `gcc` does and the Oracle
Developer Studio 12.6: C User's Guide documents (Ch. 3, Support for Atomic
Types, 3.1 Size and Alignment of Atomic C Types).

The two testcases that had been `XFAIL`ed for Bug 42535 are un-`XFAIL`ed
again.

Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

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

Added: 


Modified: 
clang/lib/Basic/Targets/Sparc.cpp
clang/lib/Basic/Targets/Sparc.h
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Preprocessor/predefined-arch-macros.c
compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test
compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/Sparc.cpp 
b/clang/lib/Basic/Targets/Sparc.cpp
index 48f36c5ba1c6..5eeb77406c34 100644
--- a/clang/lib/Basic/Targets/Sparc.cpp
+++ b/clang/lib/Basic/Targets/Sparc.cpp
@@ -147,19 +147,20 @@ void SparcTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 void SparcV8TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   SparcTargetInfo::getTargetDefines(Opts, Builder);
-  switch (getCPUGeneration(CPU)) {
-  case CG_V8:
+  if (getTriple().getOS() == llvm::Triple::Solaris)
 Builder.defineMacro("__sparcv8");
-if (getTriple().getOS() != llvm::Triple::Solaris)
+  else {
+switch (getCPUGeneration(CPU)) {
+case CG_V8:
+  Builder.defineMacro("__sparcv8");
   Builder.defineMacro("__sparcv8__");
-break;
-  case CG_V9:
-Builder.defineMacro("__sparcv9");
-if (getTriple().getOS() != llvm::Triple::Solaris) {
+  break;
+case CG_V9:
+  Builder.defineMacro("__sparcv9");
   Builder.defineMacro("__sparcv9__");
   Builder.defineMacro("__sparc_v9__");
+  break;
 }
-break;
   }
   if (getTriple().getVendor() == llvm::Triple::Myriad) {
 std::string MyriadArchValue, Myriad2Value;
@@ -227,6 +228,12 @@ void SparcV8TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__myriad2__", Myriad2Value);
 Builder.defineMacro("__myriad2", Myriad2Value);
   }
+  if (getCPUGeneration(CPU) == CG_V9) {
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+  }
 }
 
 void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,

diff  --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index d24cf15d7cd6..07844abafe11 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -166,10 +166,15 @@ class LLVM_LIBRARY_VISIBILITY SparcV8TargetInfo : public 
SparcTargetInfo {
   PtrDiffType = SignedLong;
   break;
 }
-// Up to 32 bits are lock-free atomic, but we're willing to do atomic ops
-// on up to 64 bits.
+// Up to 32 bits (V8) or 64 bits (V9) are lock-free atomic, but we're
+// willing to do atomic ops on up to 64 bits.
 MaxAtomicPromoteWidth = 64;
-MaxAtomicInlineWidth = 32;
+if (getCPUGeneration(CPU) == CG_V9)
+  MaxAtomicInlineWidth = 64;
+else
+  // FIXME: This isn't correct for plain 

[clang] a382a74 - [clang] Fix libclang linking on Solaris

2021-08-07 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2021-08-07T21:14:15+02:00
New Revision: a382a746275b4a1eb1867331efa2319c614305d8

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

LOG: [clang] Fix libclang linking on Solaris

Linking `libclang.so` is currently broken on Solaris:

  ld: fatal: option --version-script requires option -z 
gnu-version-script-compat to be specified

While Solaris `ld` supports a considerable subset of `--version-script`,
there are some elements of the syntax that aren't.

The fix is equivalent to D78510 .

Additionally, use of C-style comments is a GNU extension
that can easily be avoided by using `#` as comment character, which is
supported by GNU `ld`, `gold`, and `lld`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`,
`x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang/tools/libclang/CMakeLists.txt
clang/tools/libclang/libclang.map

Removed: 




diff  --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 8cc0fc622174a..7148bdccfba48 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -162,6 +162,11 @@ if(ENABLE_SHARED)
   endif()
   if (USE_VERSION_SCRIPT)
 target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+# The Solaris 11.4 linker supports a subset of GNU ld version scripts,
+# but requires a special option to enable it.
+if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+  target_link_options(libclang PRIVATE "-Wl,-z,gnu-version-script-compat")
+endif()
 # Ensure that libclang.so gets rebuilt when the linker script changes.
 set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
  OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libclang.map)

diff  --git a/clang/tools/libclang/libclang.map 
b/clang/tools/libclang/libclang.map
index aee46b1448457..716e2474966d5 100644
--- a/clang/tools/libclang/libclang.map
+++ b/clang/tools/libclang/libclang.map
@@ -1,10 +1,8 @@
-/* If you add a symbol to this file, make sure to add it with the correct
- * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
- * symbols with the version LLVM_14.
- * On platforms where versions scripts are not used, this file will be used to
- * generate a list of exports for libclang.so
- */
-
+# If you add a symbol to this file, make sure to add it with the correct
+# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+# symbols with the version LLVM_14.
+# On platforms where versions scripts are not used, this file will be used to
+# generate a list of exports for libclang.so
 
 LLVM_13 {
   global:
@@ -407,10 +405,9 @@ LLVM_13 {
   local: *;
 };
 
-/* Example of how to add a new symbol version entry.  If you do add a new 
symbol
- * version, please update the example to depend on the version you added.
- * LLVM_X {
- * global:
- *clang_newsymbol;
- * };
- */
+# Example of how to add a new symbol version entry.  If you do add a new symbol
+# version, please update the example to depend on the version you added.
+# LLVM_X {
+# global:
+#   clang_newsymbol;
+# };



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


[clang] 7c4a70f - [Driver] Add crtfastmath.o on Solaris if appropriate

2023-01-13 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-01-13T10:08:33+01:00
New Revision: 7c4a70f8f6f37c0d22770fa60e079aaf8928a01c

URL: 
https://github.com/llvm/llvm-project/commit/7c4a70f8f6f37c0d22770fa60e079aaf8928a01c
DIFF: 
https://github.com/llvm/llvm-project/commit/7c4a70f8f6f37c0d22770fa60e079aaf8928a01c.diff

LOG: [Driver] Add crtfastmath.o on Solaris if appropriate

`Flang :: Driver/fast_math.f90` `FAIL`s on Solaris because `crtfastmath.o`
is missing from the link line.

This patch adds it as appropriate.

Tested on `amd64-pc-solaris2.11`.

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

Added: 

clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o

clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o

clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o

clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o

Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index c75375ac95f7b..7cc872c717759 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -115,6 +115,8 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 Args.MakeArgString(getToolChain().GetFilePath(values_xpg)));
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
+// Add crtfastmath.o if available and fast math is enabled.
+getToolChain().addFastMathRuntimeIfAvailable(Args, CmdArgs);
   }
 
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 2193f35ac0545..2127ad5ded074 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -114,3 +114,57 @@
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
 // CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o
+
+// Check that crtfastmath.o is linked with -ffast-math.
+
+// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC32 %s
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
+// CHECK-CRTFASTMATH-SPARC32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC32: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC32-NOT: crtfastmath.o
+
+// Check sparc-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC64 %s
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC64 %s
+// CHECK-CRTFASTMATH-SPARC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC64: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC64-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 32bi

[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-22 Thread Rainer Orth via cfe-commits

rorth wrote:

The different behaviour can easily be seen since Solaris `clang` supports 
linker selection at compile time:
```
$ clang -r -o hello-r.o hello.o -fuse-ld=gld
/usr/gnu/bin/ld: warning: cannot find entry symbol _start; not setting start 
address
$ clang -r -o hello-r.o hello.o
ld: fatal: option '-Bdynamic' is incompatible with building a relocatable object
ld: fatal: option '-e _start' is incompatible with building a relocatable object
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
I'll either fix the Solaris driver code not to pass `-Bdynamic -e _start` with 
`-r` or do a full comparison of `Gnu.cpp` and `Solaris.cpp` to check for 
undesirable differences.

However, for the patch at hand this is moot while
```
$ flang-new -r -o hello-r.o hello.o
flang-new: error: unknown argument: '-r'
```

I wonder how to proceed with the patch at hand.

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


[clang] 6b5149a - [Driver] Link shared asan runtime lib with -z now on Solaris/x86

2023-07-27 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-07-27T11:32:48+02:00
New Revision: 6b5149aa442efc10afa00e8864e58a24a9cf5c9f

URL: 
https://github.com/llvm/llvm-project/commit/6b5149aa442efc10afa00e8864e58a24a9cf5c9f
DIFF: 
https://github.com/llvm/llvm-project/commit/6b5149aa442efc10afa00e8864e58a24a9cf5c9f.diff

LOG: [Driver] Link shared asan runtime lib with -z now on Solaris/x86

As detailed in Issue #64126, several asan tests `FAIL` due to a cycle in
`AsanInitInternal`.  This can by avoided by disabling lazy binding with `ld
-z now`.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld-sanitizer.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 335a5a88cdfac6..86c789f5fcef5c 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -151,18 +151,22 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
+const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
 
   // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
   // However, ld -z relax=transtls is available since Solaris 11.2, but not
   // in Illumos.
-  const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
   if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
   (SA.needsAsanRt() || SA.needsStatsRt() ||
(SA.needsUbsanRt() && !SA.requiresMinimalRuntime(
 CmdArgs.push_back("-zrelax=transtls");
 }
+// Avoid AsanInitInternal cycle, Issue #64126.
+if (getToolChain().getTriple().isX86() && SA.needsSharedRt() &&
+SA.needsAsanRt())
+  CmdArgs.push_back("-znow");
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,

diff  --git a/clang/test/Driver/solaris-ld-sanitizer.c 
b/clang/test/Driver/solaris-ld-sanitizer.c
index caf01919d4671e..d4fe62b5e14943 100644
--- a/clang/test/Driver/solaris-ld-sanitizer.c
+++ b/clang/test/Driver/solaris-ld-sanitizer.c
@@ -49,3 +49,19 @@
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
 // CHECK-LD-X64-UBSAN: -zrelax=transtls
+
+/// General tests that the ld -z now workaround is only applied on
+/// Solaris/i386 with shared libclang_rt.asan.. Note that we use sysroot to
+/// make these tests independent of the host system.
+
+/// Check i386-pc-solaris2.11, 32bit, shared libclang_rt.asan
+// RUN: %clang -fsanitize=address -shared-libasan --target=i386-pc-solaris2.11 
%s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN-SHARED %s
+// CHECK-LD-X32-ASAN-SHARED: -znow
+
+/// Check i386-pc-solaris2.11, 32bit, static libclang_rt.asan
+// RUN: %clang -fsanitize=address --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN %s
+// CHECK-LD-X32-ASAN-NOT: -znow



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


[clang] ae84ad1 - [Driver] Select newest GCC installation on Solaris

2023-08-16 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-16T09:57:59+02:00
New Revision: ae84ad15efd7ef7da95146e900ec72ceadf98058

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

LOG: [Driver] Select newest GCC installation on Solaris

As described in Issue #53709
, since
28d58d8fe2094af6902dee7b4d68ec30a3e9d737

`clang` doesn't find the latest of several parallel GCC installations on
Solaris, but only the first in directory order, which is pretty random.

This patch sorts GCC installations in reverse version order so the latest
is picked.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/unittests/Driver/ToolChainTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index c8fb05d238782e..508ff1d8b9ae12 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2227,6 +2227,7 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 // so we need to find those /usr/gcc/*/lib/gcc libdirs and go with
 // /usr/gcc/ as a prefix.
 
+SmallVector, 8> SolarisPrefixes;
 std::string PrefixDir = concat(SysRoot, "/usr/gcc");
 std::error_code EC;
 for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(PrefixDir, 
EC),
@@ -2244,8 +2245,13 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   if (!D.getVFS().exists(CandidateLibPath))
 continue;
 
-  Prefixes.push_back(CandidatePrefix);
+  SolarisPrefixes.emplace_back(
+  std::make_pair(CandidateVersion, CandidatePrefix));
 }
+// Sort in reverse order so GCCInstallationDetector::init picks the latest.
+std::sort(SolarisPrefixes.rbegin(), SolarisPrefixes.rend());
+for (auto p : SolarisPrefixes)
+  Prefixes.emplace_back(p.second);
 return;
   }
 

diff  --git a/clang/unittests/Driver/ToolChainTest.cpp 
b/clang/unittests/Driver/ToolChainTest.cpp
index 8d3853a7b4a6de..bf61d428448289 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -168,6 +168,155 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
 S);
 }
 
+TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  const char *EmptyFiles[] = {
+  // Sort entries so the latest version doesn't come first.
+  "/usr/gcc/7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0/32/crtbegin.o",
+  "/usr/gcc/7/lib/gcc/sparcv9-sun-solaris2.11/7.5.0/crtbegin.o",
+  "/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/32/crtbegin.o",
+  "/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/crtbegin.o",
+  "/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/crtbegin.o",
+  "/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/sparcv8plus/"
+  "crtbegin.o",
+  "/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/32/crtbegin.o",
+  "/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/crtbegin.o",
+  "/usr/gcc/4.7/lib/gcc/i386-pc-solaris2.11/4.7.3/amd64/crtbegin.o",
+  "/usr/gcc/4.7/lib/gcc/i386-pc-solaris2.11/4.7.3/crtbegin.o",
+  "/usr/gcc/4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3/crtbegin.o",
+  "/usr/gcc/4.7/lib/gcc/sparc-sun-solaris2.11/4.7.3/sparcv9/crtbegin.o",
+  };
+
+  for (const char *Path : EmptyFiles)
+InMemoryFileSystem->addFile(Path, 0,
+llvm::MemoryBuffer::getMemBuffer("\n"));
+
+  {
+DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+Driver TheDriver("/bin/clang", "i386-pc-solaris2.11", Diags,
+ "clang LLVM compiler", InMemoryFileSystem);
+std::unique_ptr C(
+TheDriver.BuildCompilation({"-v", "--gcc-toolchain=", "--sysroot="}));
+ASSERT_TRUE(C);
+std::string S;
+{
+  llvm::raw_string_ostream OS(S);
+  C->getDefaultToolChain().printVerboseInfo(OS);
+}
+if (is_style_windows(llvm::sys::path::Style::native))
+  std::replace(S.begin(), S.end(), '\\', '/');
+EXPECT_EQ("Found candidate GCC installation: "
+  "/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0\n"
+  "Selected GCC installation: "
+  "/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0\n"
+  "Candidate multilib: .;@m64\n"
+  "Candidate multilib: 

[clang] 18252e6 - [Driver][unittest] Unbreak ToolChainTest.cpp compilation with -Werror

2023-08-16 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-16T10:37:14+02:00
New Revision: 18252e6c8e2b1bb9901b5cca9e9a75edfeda2c4e

URL: 
https://github.com/llvm/llvm-project/commit/18252e6c8e2b1bb9901b5cca9e9a75edfeda2c4e
DIFF: 
https://github.com/llvm/llvm-project/commit/18252e6c8e2b1bb9901b5cca9e9a75edfeda2c4e.diff

LOG: [Driver][unittest] Unbreak ToolChainTest.cpp compilation with -Werror

D157275 broke some buildbots that run with -Werror:

https://lab.llvm.org/buildbot#builders/36/builds/36604
https://lab.llvm.org/buildbot#builders/57/builds/29201

Avoid this by using an overlong line rather than appeasing `clang-format`.

Added: 


Modified: 
clang/unittests/Driver/ToolChainTest.cpp

Removed: 




diff  --git a/clang/unittests/Driver/ToolChainTest.cpp 
b/clang/unittests/Driver/ToolChainTest.cpp
index bf61d428448289..ae567abb81a9bb 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -183,8 +183,7 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
   "/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/32/crtbegin.o",
   "/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.5.0/crtbegin.o",
   "/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/crtbegin.o",
-  "/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/sparcv8plus/"
-  "crtbegin.o",
+  
"/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0/sparcv8plus/crtbegin.o",
   "/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/32/crtbegin.o",
   "/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0/crtbegin.o",
   "/usr/gcc/4.7/lib/gcc/i386-pc-solaris2.11/4.7.3/amd64/crtbegin.o",



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


[clang] 62945bb - [Driver] Add PIE support on Solaris

2023-08-18 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-18T21:09:37+02:00
New Revision: 62945bb811169ffac7cf22c64b6dd3a3ad8d38f0

URL: 
https://github.com/llvm/llvm-project/commit/62945bb811169ffac7cf22c64b6dd3a3ad8d38f0
DIFF: 
https://github.com/llvm/llvm-project/commit/62945bb811169ffac7cf22c64b6dd3a3ad8d38f0.diff

LOG: [Driver] Add PIE support on Solaris

`clang` currently lacks PIE support on Solaris.  This patch fixes this,
also linking with `crtbeginS.o` and `crtendS.o` for `-pie` and `-shared`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

Added: 

clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbeginS.o

clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtbeginS.o

Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 86c789f5fcef5c..de5a69e4ca3fd2 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -47,11 +47,24 @@ void solaris::Assembler::ConstructJob(Compilation &C, const 
JobAction &JA,
  Exec, CmdArgs, Inputs, Output));
 }
 
+static bool getPIE(const ArgList &Args, const ToolChain &TC) {
+  if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) ||
+  Args.hasArg(options::OPT_r))
+return false;
+
+  Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie,
+   options::OPT_nopie);
+  if (!A)
+return TC.isPIEDefault(Args);
+  return A->getOption().matches(options::OPT_pie);
+}
+
 void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
+  const bool IsPIE = getPIE(Args, getToolChain());
   ArgStringList CmdArgs;
 
   // Demangle C++ names in errors
@@ -62,6 +75,11 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("_start");
   }
 
+  if (IsPIE) {
+CmdArgs.push_back("-z");
+CmdArgs.push_back("type=pie");
+  }
+
   if (Args.hasArg(options::OPT_static)) {
 CmdArgs.push_back("-Bstatic");
 CmdArgs.push_back("-dn");
@@ -113,8 +131,13 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   values_xpg = "values-xpg4.o";
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath(values_xpg)));
-CmdArgs.push_back(
-Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
+
+const char *crtbegin = nullptr;
+if (Args.hasArg(options::OPT_shared) || IsPIE)
+  crtbegin = "crtbeginS.o";
+else
+  crtbegin = "crtbegin.o";
+
CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(crtbegin)));
 // Add crtfastmath.o if available and fast math is enabled.
 getToolChain().addFastMathRuntimeIfAvailable(Args, CmdArgs);
   }
@@ -171,8 +194,12 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_r)) {
-CmdArgs.push_back(
-Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
+if (Args.hasArg(options::OPT_shared) || IsPIE)
+  CmdArgs.push_back(
+  Args.MakeArgString(getToolChain().GetFilePath("crtendS.o")));
+else
+  CmdArgs.push_back(
+  Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
   }

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbeginS.o
 
b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbeginS.o
new file mode 100644
index 00..e69de29bb2d1d6

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtbeginS.o
 
b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtbeginS.o
new file mode 100644
index 00..e69de29bb2d1d6

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 2127ad5ded074b..8d97a5a3695bdc 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -106,6 +106,33 @@
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
 // CHECK-SPARC32-SHARED-NOT: "-lm"
 
+// Check the right ld flags are present with -pie.
+// RUN: %clang --target=sparc-sun-solaris2.1

[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-11 Thread Rainer Orth via cfe-commits

rorth wrote:

> > I wonder how to proceed with the patch at hand.
> 
> I'm not a Solaris expert, but based on this discussion I'd consider adding 
> support for `-fuse-ld` in Flang. This sort of changes are often as simple as 
> updating Options.td. Same for `-r`.

Support of `-fuse-ld` is not Solaris-specific in any way.  Other targets 
support e.g. `-fuse-ld=[bfd|lld]`.  That would be just another case of Flang 
needing to support common flags.  However, I don't understand how Flang option 
handling is done, unfortunately.  Whatever the case, this is an issue separate 
from this patch: the only reason we were talking about `-r` and friends is that 
my patch guards adding the Flang runtime libs with `! -nostdlib && ! 
-nodefaultlibs && ! -r`, which I believe we have now established is correct.

However, Flang accepts none of those options yet, which it should for 
compatiblity with both `clang++` and `gfortran`.  However, I won't be able to 
deal with any of this: I've quite a number of other issues on my plate.

> One important rule of thumb that I'd stick to:
> 
> * Do whatever Clang, GFortran and GCC do.
> 
> 
> In cases where there's different behavior between these compilers, just go 
> for whatever feels most sensible, but please document your design decision.

Fully agreed: I've now checked that gfortran handles all of `-r`, `-nostdlib`, 
and `-nodefaultlibs`, so I believe `flang-new` should follow suite.


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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-11 Thread Rainer Orth via cfe-commits

rorth wrote:

> I'd like for this to move forward.

Agreed: AFAICS the only open issue is whether the Solaris test should use the 
`GNU` label as I have done, introduce an new common one (like `UNIX`; there's 
nothing GNU-specific in that test), or really introduce a separate copy of the 
check under a different label per target (my least preference because it makes 
the test hard to read for no gain).

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-16 Thread Rainer Orth via cfe-commits

rorth wrote:

> I feel that we are bike-shedding here a bit. Please prioritise correctness - 
> using `GNU` as a label for Solaris would not be correct. The following would 
> be:
> 
> * duplicating tests with a different label (e.g. `SOLARIS`) would be 
> correct,
> 
> * renaming the current label from `GNU` to e.g. `UNIX` would be correct.
> 
> 
> Unless I am missing something?

I'd go for renaming the label to `UNIX` then: it avoids unnecessary duplication 
and better describes what those cases are about.

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-10-17 Thread Rainer Orth via cfe-commits

https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/65644

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH 1/2] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

>From bf1b865045ed4f484f24746aa18405d93e760979 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Tue, 17 Oct 2023 20:43:23 +0200
Subject: [PATCH 2/2] Rename `GNU` label to `UNIX` to better match use.

---
 flang/test/Driver/linker-flags.f90 | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 717dcc7775e2126..fd61825eb4023a5 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -2,9 +2,9 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
-! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,UNIX
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and
@@ -22,12 +22,12 @@
 !   run on any other platform, such as Windows that use a .exe
 !   suffix. Clang's driver will try to resolve the path to the ld
 !   executable and may find the GNU linker from MinGW or Cygwin.
-! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
-! GNU-SAME: "[[object_file]]"
-! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
-! GNU-SAME: -lm
+! UNIX-LABEL:  "{{.*}}ld{{(\.exe)?}}"
+! UNIX-SAME: "[[object_file]]"
+! UNIX-SAME: -lFortran_main
+! UNIX-SAME: -lFortranRuntime
+! UNIX-SAME: -lFortranDecimal
+! UNIX-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"

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


[clang] d0dc887 - [Driver] Remove references to Solaris 12

2023-08-03 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-03T09:54:25+02:00
New Revision: d0dc887d7ed285688004c75de3784cfe94febd34

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

LOG: [Driver] Remove references to Solaris 12

Solaris 12 was re-christened as Solaris 11.4 while still in beta, so all
references are long obsolete and can be removed.

Tested on `amd64-pc-solaris2.11`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index b64fff8b14be8a..7aa6984ab8f353 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2407,13 +2407,11 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   if (TargetTriple.getOS() == llvm::Triple::Solaris) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
-"sparc-sun-solaris2.11", "sparc-sun-solaris2.12"};
+"sparc-sun-solaris2.11"};
 static const char *const SolarisSparcV9Triples[] = {
-"sparcv9-sun-solaris2.11", "sparcv9-sun-solaris2.12"};
-static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11",
-"i386-pc-solaris2.12"};
-static const char *const SolarisX86_64Triples[] = {"x86_64-pc-solaris2.11",
-   
"x86_64-pc-solaris2.12"};
+"sparcv9-sun-solaris2.11"};
+static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11"};
+static const char *const SolarisX86_64Triples[] = 
{"x86_64-pc-solaris2.11"};
 LibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 BiarchLibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 switch (TargetTriple.getArch()) {



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


[clang] 43dfe0f - [Driver] Allow for sparcv8plus subdir with Solaris/SPARC GCC

2023-08-03 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-03T20:01:13+02:00
New Revision: 43dfe0f08ecaf50f986512d0548bd3ac84d1813b

URL: 
https://github.com/llvm/llvm-project/commit/43dfe0f08ecaf50f986512d0548bd3ac84d1813b
DIFF: 
https://github.com/llvm/llvm-project/commit/43dfe0f08ecaf50f986512d0548bd3ac84d1813b.diff

LOG: [Driver] Allow for sparcv8plus subdir with Solaris/SPARC GCC

Since GCC 11, the bundled Solaris/SPARC GCC uses the `sparcv8plus`
subdirectory for 32-bit objects, just like upstream GCC.  Before that, it
used `32` instead from a local patch.

Since `clang` doesn't know about that `sparcv8plus` subdirectory, it
wouldn't properly use GCC 11+ installations.

The new `solaris-sparc-gcc-search.test` testcase wasn't run initially (like
the existing `crash-report-null.test`) because the `.test` suffix wasn't
handled.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

Added: 

clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/32/crtbegin.o

clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/crtbegin.o

clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/crtbegin.o

clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/sparcv8plus/crtbegin.o
clang/test/Driver/solaris-sparc-gcc-search.test

Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/lit.local.cfg

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7aa6984ab8f353..485fd67ca53d3e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1874,6 +1874,12 @@ static bool findBiarchMultilibs(const Driver &D,
 .flag("-m64", /*Disallow=*/true)
 .flag("-mx32")
 .makeMultilib();
+  Multilib Alt32sparc = MultilibBuilder()
+.gccSuffix("/sparcv8plus")
+.includeSuffix("/sparcv8plus")
+.flag("-m32")
+.flag("-m64", /*Disallow=*/true)
+.makeMultilib();
 
   // GCC toolchain for IAMCU doesn't have crtbegin.o, so look for libgcc.a.
   FilterNonExistent NonExistent(
@@ -1885,10 +1891,14 @@ static bool findBiarchMultilibs(const Driver &D,
   const bool IsX32 = TargetTriple.isX32();
   if (TargetTriple.isArch32Bit() && !NonExistent(Alt32))
 Want = WANT64;
+  if (TargetTriple.isArch32Bit() && !NonExistent(Alt32sparc))
+Want = WANT64;
   else if (TargetTriple.isArch64Bit() && IsX32 && !NonExistent(Altx32))
 Want = WANT64;
   else if (TargetTriple.isArch64Bit() && !IsX32 && !NonExistent(Alt64))
 Want = WANT32;
+  else if (TargetTriple.isArch64Bit() && !NonExistent(Alt32sparc))
+Want = WANT64;
   else {
 if (TargetTriple.isArch32Bit())
   Want = NeedsBiarchSuffix ? WANT64 : WANT32;
@@ -1919,6 +1929,7 @@ static bool findBiarchMultilibs(const Driver &D,
   Result.Multilibs.push_back(Alt64);
   Result.Multilibs.push_back(Alt32);
   Result.Multilibs.push_back(Altx32);
+  Result.Multilibs.push_back(Alt32sparc);
 
   Result.Multilibs.FilterOut(NonExistent);
 
@@ -1932,7 +1943,8 @@ static bool findBiarchMultilibs(const Driver &D,
 
   if (Result.SelectedMultilibs.back() == Alt64 ||
   Result.SelectedMultilibs.back() == Alt32 ||
-  Result.SelectedMultilibs.back() == Altx32)
+  Result.SelectedMultilibs.back() == Altx32 ||
+  Result.SelectedMultilibs.back() == Alt32sparc)
 Result.BiarchSibling = Default;
 
   return true;

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/32/crtbegin.o
 
b/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/32/crtbegin.o
new file mode 100644
index 00..e69de29bb2d1d6

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/crtbegin.o
 
b/clang/test/Driver/Inputs/solaris_sparc32_tree/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.4.0/crtbegin.o
new file mode 100644
index 00..e69de29bb2d1d6

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/crtbegin.o
 
b/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/crtbegin.o
new file mode 100644
index 00..e69de29bb2d1d6

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/sparcv8plus/crtbegin.o
 
b/clang/test/Driver/Inputs/solaris_sparcv8+_tree/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.3.0/sparcv8plus/crtbegin.o
new file mode

[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/65632:

As noticed in D158846, the Solaris driver deviates from other targets in that 
it links every executable with `-lm`, but doesn't for shared objects. For C 
code, this is unnecessary, while for C++ `libm` is always needed, even for 
shared objects.

This patch fixes this by following the `Gnu.cpp` precedent.  It adjusts the 
`solaris-ld.c` test accordingly, adding some more tests.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and 
`x86_64-pc-linux-gnu`.

>From 929f162e99118ecea75684975448d72cfe46b58f Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 18:10:01 +0200
Subject: [PATCH] [Driver] Fix linking with -lm on Solaris

As noticed in D158846, the Solaris driver deviates from other targets in
that it links every executable with `-lm`, but doesn't for shared objects.
For C code, this is unnecessary, while for C++ `libm` is always needed,
even for shared objects.

This patch fixes this by following the `Gnu.cpp` precedent.  It adjusts the
`solaris-ld.c` test accordingly, adding some more tests.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp |  9 ++---
 clang/test/Driver/solaris-ld.c  | 21 -
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 4e002e348eac5f..36fe12608eefc6 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -87,6 +87,7 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
+  const Driver &D = getToolChain().getDriver();
   const bool IsPIE = getPIE(Args, getToolChain());
   ArgStringList CmdArgs;
   bool LinkerIsGnuLd = isLinkerGnuLd(getToolChain(), Args);
@@ -217,8 +218,11 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
-if (getToolChain().ShouldLinkCXXStdlib(Args))
-  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+if (D.CCCIsCXX()) {
+  if (getToolChain().ShouldLinkCXXStdlib(Args))
+getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
@@ -239,7 +243,6 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-lgcc");
-  CmdArgs.push_back("-lm");
 }
 const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 231e14966ea42f..09e6e8b4f07cf9 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -26,7 +26,6 @@
 // CHECK-GLD: "--as-needed" "-lgcc_s" "--no-as-needed"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
-// CHECK-LD-SPARC32-SAME: "-lm"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtend.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -49,7 +48,6 @@
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
 // CHECK-LD-SPARC64-SAME: "-lgcc"
-// CHECK-LD-SPARC64-SAME: "-lm"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtend.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|}}crtn.o"
 
@@ -72,7 +70,6 @@
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
 // CHECK-LD-X32-SAME: "-lgcc"
-// CHECK-LD-X32-SAME: "-lm"
 // CHECK-LD-X32-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtend.o"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -96,7 +93,6 @@
 // CHECK-LD-X64-SAME: "-lgcc_s"
 // CHECK-LD-X64-SAME: "-lc"
 // CHECK-LD-X64-SAME: "-lgcc"
-// CHECK-LD-X64-SAME: "-lm"
 // CHECK-LD-X64-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtend.o"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crtn.o"
 
@@ -110,7 +106,22 @@
 // CHECK-SPARC32-SHARED-SAME: "-lgcc_s"
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
-// CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// Check that libm is only linked with clang++.
+// RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | 

[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/65644:

I noticed that `flang-new` cannot link Fortran executables on Solaris since the 
runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase is 
augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and 
`x86_64-pc-linux-gnu`.

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Rainer Orth via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

rorth wrote:

True, but how many more copies of the same patterns do we want?  Add FreeBSD, 
OpenBSD, ... whenever they arrive?  Isn't the common patternwith or without `-lm`?  How about putting the first under 
one label and the `-lm` part under another, used where appropriate?

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-14 Thread Rainer Orth via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

rorth wrote:

@banach-space How should we proceed with this one?  Really introduce separate 
labels for each OS, even if the checks are identical?  Or consolidate labels as 
I suggested?


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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-15 Thread Rainer Orth via cfe-commits

rorth wrote:

I'd argue that handling the Flang runtime libs like C++ is the right thing to 
do here.  However, `flang-new` currently rejects all of `-r`, `-nostdlib`, and 
`-nodefaultlibs` on both Linux and Solaris.  On top of that, Solaris `clang` 
doesn't handle `-r` correctly, passing `-e _start -Bdynamic` to `ld`, which 
makes it choke...

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


[clang-tools-extra] 03dff0d - [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-27T21:15:43+02:00
New Revision: 03dff0d4acafb61bbb3b765507de79c5e5b6681a

URL: 
https://github.com/llvm/llvm-project/commit/03dff0d4acafb61bbb3b765507de79c5e5b6681a
DIFF: 
https://github.com/llvm/llvm-project/commit/03dff0d4acafb61bbb3b765507de79c5e5b6681a.diff

LOG: [clang-tidy] Disambiguate calls to log

c8644b18f570be9d26d83cdeeb2369cd3cbddaf1 

broke the Solaris/amd64 

and Solaris/sparcv9  
buildbots:

  FAILED: 
tools/clang/tools/extra/clang-tidy/altera/CMakeFiles/obj.clangTidyAlteraModule.dir/UnrollLoopsCheck.cpp.o
  [...]
  
/vol/llvm/src/llvm-project/dist/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:217:25:
 error: call to 'log' is ambiguous
217 |   Iterations = 1 + (log(EndValue) - log(InitValue)) / 
log(ConstantValue);
| ^~~
  /usr/include/iso/math_iso.h:60:15: note: candidate function
 60 | extern double log __P((double));
|   ^
  /usr/include/iso/math_iso.h:158:15: note: candidate function
158 | inline float log(float __X) { return __logf(__X); }
|  ^
  /usr/include/iso/math_iso.h:193:21: note: candidate function
193 | inline long double log(long double __X) { return __logl(__X); 
}
|^

Fixed by disambituating the calls with `double` casts.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index 37eacf565f199d..532a43bad74127 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt 
*Statement,
   Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
   break;
 case (BO_MulAssign):
-  Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
+   log((double)ConstantValue);
   break;
 case (BO_DivAssign):
-  Iterations = 1 + (log(InitValue) - log(EndValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
+   log((double)ConstantValue);
   break;
 default:
   // All other operators are not handled; assume large bounds.



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


[clang] 779353e - [Driver] Improve legibility of ld -z options on Solaris

2023-08-28 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-28T09:25:47+02:00
New Revision: 779353e576eaa6ababdfc242784484f3656ecfe0

URL: 
https://github.com/llvm/llvm-project/commit/779353e576eaa6ababdfc242784484f3656ecfe0
DIFF: 
https://github.com/llvm/llvm-project/commit/779353e576eaa6ababdfc242784484f3656ecfe0.diff

LOG: [Driver] Improve legibility of ld -z options on Solaris

Following the lead of the Linux code, this patch passes the `ld -z` options
as two separate args on Solaris, improving legibility.  For lack of a
variadic `std::push_back`, `getAsNeededOption` had to be changed to
`addAsNeededOption`, matching other `add*Options` functions, changing
callers accordingly.  The additional args are also used in a WIP revision
of the Solaris GNU ld patch D85309 , which
will allow runtime selection of the linker to use.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld-sanitizer.c
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 3b99389fdbf228..813f80223bd830 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -999,24 +999,30 @@ static bool addSanitizerDynamicList(const ToolChain &TC, 
const ArgList &Args,
   return false;
 }
 
-const char *tools::getAsNeededOption(const ToolChain &TC, bool as_needed) {
+void tools::addAsNeededOption(const ToolChain &TC,
+  const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs,
+  bool as_needed) {
   assert(!TC.getTriple().isOSAIX() &&
  "AIX linker does not support any form of --as-needed option yet.");
 
   // While the Solaris 11.2 ld added --as-needed/--no-as-needed as aliases
   // for the native forms -z ignore/-z record, they are missing in Illumos,
   // so always use the native form.
-  if (TC.getTriple().isOSSolaris())
-return as_needed ? "-zignore" : "-zrecord";
-  else
-return as_needed ? "--as-needed" : "--no-as-needed";
+  if (TC.getTriple().isOSSolaris()) {
+CmdArgs.push_back("-z");
+CmdArgs.push_back(as_needed ? "ignore" : "record");
+  } else {
+CmdArgs.push_back(as_needed ? "--as-needed" : "--no-as-needed");
+  }
 }
 
 void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
+ const llvm::opt::ArgList &Args,
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
-  CmdArgs.push_back(getAsNeededOption(TC, false));
+  addAsNeededOption(TC, Args, CmdArgs, false);
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
   !TC.getTriple().isAndroid() && !TC.getTriple().isOHOSFamily()) {
@@ -1260,8 +1266,10 @@ bool tools::addXRayRuntime(const ToolChain&TC, const 
ArgList &Args, ArgStringLis
   return false;
 }
 
-void tools::linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
-  CmdArgs.push_back(getAsNeededOption(TC, false));
+void tools::linkXRayRuntimeDeps(const ToolChain &TC,
+const llvm::opt::ArgList &Args,
+ArgStringList &CmdArgs) {
+  addAsNeededOption(TC, Args, CmdArgs, false);
   CmdArgs.push_back("-lpthread");
   if (!TC.getTriple().isOSOpenBSD())
 CmdArgs.push_back("-lrt");
@@ -1805,7 +1813,7 @@ static void AddUnwindLibrary(const ToolChain &TC, const 
Driver &D,
   !TC.getTriple().isAndroid() &&
   !TC.getTriple().isOSCygMing() && !TC.getTriple().isOSAIX();
   if (AsNeeded)
-CmdArgs.push_back(getAsNeededOption(TC, true));
+addAsNeededOption(TC, Args, CmdArgs, true);
 
   switch (UNW) {
   case ToolChain::UNW_None:
@@ -1839,7 +1847,7 @@ static void AddUnwindLibrary(const ToolChain &TC, const 
Driver &D,
   }
 
   if (AsNeeded)
-CmdArgs.push_back(getAsNeededOption(TC, false));
+addAsNeededOption(TC, Args, CmdArgs, false);
 }
 
 static void AddLibgcc(const ToolChain &TC, const Driver &D,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index b1c8441226310c..7585d24c3c0eb6 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -40,12 +40,13 @@ bool addSanitiz

[clang] b1b1f36 - [Driver] Don't default to DWARF 2 on Solaris

2023-09-01 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-09-01T20:02:37+02:00
New Revision: b1b1f364d63382637fa5f64871ee06bf74bd0405

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

LOG: [Driver] Don't default to DWARF 2 on Solaris

`clang` currently defaults to DWARF 2 on Solaris.  This dates back to LLVM
3.8.0.  I suspect this is related to `gcc/config/sol2.cc`
(`solaris_override_options`) doing the same unless
`HAVE_LD_EH_FRAME_CIEV3`.  The latter is 1 on both Solaris 11.3 and 11.4,
so the workaround has become irrelevant these days.

This patch removes the Solaris override, adjusting affected testcases
accordingly.

Tested on `amd64-pc-solaris2.11` (`Release` and `Debug` builds) and
`sparcv9-sun-solaris2.11` (`Release` build).

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Solaris.h
clang/test/CodeGen/dwarf-version.c
clang/test/Driver/clang-g-opts.c
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.h 
b/clang/lib/Driver/ToolChains/Solaris.h
index fbac92c2c0f31c..9023bf7c37c522 100644
--- a/clang/lib/Driver/ToolChains/Solaris.h
+++ b/clang/lib/Driver/ToolChains/Solaris.h
@@ -63,7 +63,6 @@ class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_ELF {
llvm::opt::ArgStringList &CC1Args) const override;
 
   SanitizerMask getSupportedSanitizers() const override;
-  unsigned GetDefaultDwarfVersion() const override { return 2; }
 
   const char *getDefaultLinker() const override {
 // clang currently uses Solaris ld-only options.

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index d307eb3f101f8f..850cedf4d14c76 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -4,6 +4,8 @@
 // RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER5
 // RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck 
%s --check-prefix=VER5
 // RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER5
+// RUN: %clang --target=i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck 
%s --check-prefix=VER5
+// RUN: %clang --target=i386-pc-solaris -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER5
 
 // The -isysroot is used as a hack to avoid LIT messing with the SDKROOT
 // environment variable which indirecty overrides the version in the target
@@ -13,8 +15,6 @@
 
 // RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER4
-// RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VER2
-// RUN: %clang -target i386-pc-solaris -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 
 // Check which debug info formats we use on Windows. By default, in an MSVC
 // environment, we should use codeview. You can enable dwarf, which implicitly

diff  --git a/clang/test/Driver/clang-g-opts.c 
b/clang/test/Driver/clang-g-opts.c
index 5ee0fe64fe484f..4882eb6068f436 100644
--- a/clang/test/Driver/clang-g-opts.c
+++ b/clang/test/Driver/clang-g-opts.c
@@ -27,8 +27,8 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g0 -g -target x86_64-pc-freebsd10.0 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
-// RUN: %clang -### -S %s -g0 -g -target i386-pc-solaris 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
+// RUN: %clang -### -S %s -g0 -g --target=i386-pc-solaris 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // CHECK-WITHOUT-G-NOT: -debug-info-kind
 // CHECK-WITH-G: "-debug-info-kind=constructor"

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index 4dbd7be10982e3..8ffa88d00dff37 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -193,8 +193,8 @@
 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 
2>&1 \
 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
-// RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \
-// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
+// RUN: %clang -### -c -gline-tables-only -g %s --target=i386-pc-solaris 2>&1 \
+// RUN: | FileCheck -check-prefix=G_ONLY %s
 // RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=GLTO_NO %s
 //
@@ -212,8 +212,8 @@
 // RUN:

[clang] d39a9e3 - [Driver] Support GNU ld on Solaris

2023-09-01 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-09-01T21:42:05+02:00
New Revision: d39a9e3b4d4afc0321fea72b9d6b8a3908c45fc1

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

LOG: [Driver] Support GNU ld on Solaris

This patch supports GNU ld on Solaris in addition to Solaris ld, the
default.

- Linker selection is dynamic: one can switch between Solaris ld and GNU ld
  at runtime, with the default selectable with `-DCLANG_DEFAULT_LINKER`.

- Testcases have been adjusted to test both variants in case there are
  differences.

- The `compiler-rt/cmake/config-ix.cmake` and
  `llvm/cmake/modules/AddLLVM.cmake` changes to restrict the tests to
  Solaris ld are necessary because GNU accepts unknown `-z` options, but
  warns every time they are used, creating a lot of noise.  Since there
  seems to be no way to check for those warnings in
  `llvm_check_compiler_linker_flag` or `llvm_check_compiler_linker_flag`, I
  restrict the cmake tests to Solaris ld in the first place.

- The changes to `clang/test/Driver/hip-link-bundle-archive.hip` and
  `flang/test/Driver/linker-flags.f90` are required when LLVM is built with
  `-DCLANG_DEFAULT_LINKER=gld` on Solaris: `MSVC.cpp`
  `visualstudio::Linker::ConstructJob` ultimately calls
  `GetProgramPath("gld")`, resulting in a search for `gld`, which exists in
  `/usr/bin/gld` on Solaris.  With `-fuse-ld=`, this doesn't happen and the
  expected `link` is returned.

- `compiler-rt/test/asan/TestCases/global-location-nodebug.cpp` needs to
  enforce the Solaris ld, otherwise the test would `XPASS` with GNU ld
  which has the `-S` semantics expected by the test.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11` with both
`-DCLANG_DEFAULT_LINKER=gld` and the default, and `x86_64-pc-linux-gnu`.
No regressions in either case.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Solaris.cpp
clang/lib/Driver/ToolChains/Solaris.h
clang/test/Driver/hip-link-bundle-archive.hip
clang/test/Driver/solaris-ld-sanitizer.c
clang/test/Driver/solaris-ld.c
compiler-rt/cmake/config-ix.cmake
compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
flang/test/Driver/linker-flags.f90
llvm/cmake/modules/AddLLVM.cmake

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4daca7ba5fc9544..37db5a2740011d4 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -22,6 +22,7 @@
 #include "HIPAMD.h"
 #include "Hexagon.h"
 #include "MSP430.h"
+#include "Solaris.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
@@ -993,9 +994,11 @@ static void addSanitizerRuntime(const ToolChain &TC, const 
ArgList &Args,
 static bool addSanitizerDynamicList(const ToolChain &TC, const ArgList &Args,
 ArgStringList &CmdArgs,
 StringRef Sanitizer) {
+  bool LinkerIsGnuLd = solaris::isLinkerGnuLd(TC, Args);
+
   // Solaris ld defaults to --export-dynamic behaviour but doesn't support
   // the option, so don't try to pass it.
-  if (TC.getTriple().getOS() == llvm::Triple::Solaris)
+  if (TC.getTriple().getOS() == llvm::Triple::Solaris && !LinkerIsGnuLd)
 return true;
   SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
   if (llvm::sys::fs::exists(SanRT + ".syms")) {
@@ -1011,11 +1014,14 @@ void tools::addAsNeededOption(const ToolChain &TC,
   bool as_needed) {
   assert(!TC.getTriple().isOSAIX() &&
  "AIX linker does not support any form of --as-needed option yet.");
+  bool LinkerIsGnuLd = solaris::isLinkerGnuLd(TC, Args);
 
   // While the Solaris 11.2 ld added --as-needed/--no-as-needed as aliases
   // for the native forms -z ignore/-z record, they are missing in Illumos,
   // so always use the native form.
-  if (TC.getTriple().isOSSolaris()) {
+  // GNU ld doesn't support -z ignore/-z record, so don't use them even on
+  // Solaris.
+  if (TC.getTriple().isOSSolaris() && !LinkerIsGnuLd) {
 CmdArgs.push_back("-z");
 CmdArgs.push_back(as_needed ? "ignore" : "record");
   } else {

diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 1a7839d739655d7..a22e4c2e47b87e6 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -16,6 +16,7 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "clang/Driver/ToolChain.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
 #include

[clang] 1bc7b75 - [clang] Consistently use isOSSolaris()

2023-09-01 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-09-01T21:45:22+02:00
New Revision: 1bc7b753a5cd1599ecf0575d629460ba08f7121e

URL: 
https://github.com/llvm/llvm-project/commit/1bc7b753a5cd1599ecf0575d629460ba08f7121e
DIFF: 
https://github.com/llvm/llvm-project/commit/1bc7b753a5cd1599ecf0575d629460ba08f7121e.diff

LOG: [clang] Consistently use isOSSolaris()

While looking over the Solaris GNU ld patch (D85309
), I noticed that we weren't using
`isOSSolaris()` consistenly in `clang`.  This patch fixes this.

Tested on `amd64-pc-solaris2.11`.

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

Added: 


Modified: 
clang/lib/Basic/Targets/Sparc.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/Sparc.cpp 
b/clang/lib/Basic/Targets/Sparc.cpp
index 8b9e149037..d1a891092b0f5c 100644
--- a/clang/lib/Basic/Targets/Sparc.cpp
+++ b/clang/lib/Basic/Targets/Sparc.cpp
@@ -141,7 +141,7 @@ void SparcTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 void SparcV8TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   SparcTargetInfo::getTargetDefines(Opts, Builder);
-  if (getTriple().getOS() == llvm::Triple::Solaris)
+  if (getTriple().isOSSolaris())
 Builder.defineMacro("__sparcv8");
   else {
 switch (getCPUGeneration(CPU)) {
@@ -168,7 +168,7 @@ void SparcV9TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   Builder.defineMacro("__sparcv9");
   Builder.defineMacro("__arch64__");
   // Solaris doesn't need these variants, but the BSDs do.
-  if (getTriple().getOS() != llvm::Triple::Solaris) {
+  if (!getTriple().isOSSolaris()) {
 Builder.defineMacro("__sparc64__");
 Builder.defineMacro("__sparc_v9__");
 Builder.defineMacro("__sparcv9__");

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 37db5a2740011d..1db05b47e11ba6 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -998,7 +998,7 @@ static bool addSanitizerDynamicList(const ToolChain &TC, 
const ArgList &Args,
 
   // Solaris ld defaults to --export-dynamic behaviour but doesn't support
   // the option, so don't try to pass it.
-  if (TC.getTriple().getOS() == llvm::Triple::Solaris && !LinkerIsGnuLd)
+  if (TC.getTriple().isOSSolaris() && !LinkerIsGnuLd)
 return true;
   SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
   if (llvm::sys::fs::exists(SanRT + ".syms")) {

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index f81a9a4982d4ca..d215dd77921778 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1838,7 +1838,7 @@ static bool findBiarchMultilibs(const Driver &D,
 
   StringRef Suff64 = "/64";
   // Solaris uses platform-specific suffixes instead of /64.
-  if (TargetTriple.getOS() == llvm::Triple::Solaris) {
+  if (TargetTriple.isOSSolaris()) {
 switch (TargetTriple.getArch()) {
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:
@@ -2220,7 +2220,7 @@ bool 
Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
 void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 const llvm::Triple &TargetTriple, SmallVectorImpl &Prefixes,
 StringRef SysRoot) {
-  if (TargetTriple.getOS() == llvm::Triple::Solaris) {
+  if (TargetTriple.isOSSolaris()) {
 // Solaris is a special case.
 // The GCC installation is under
 //   /usr/gcc/./lib/gcc//../
@@ -2422,7 +2422,7 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   using std::begin;
   using std::end;
 
-  if (TargetTriple.getOS() == llvm::Triple::Solaris) {
+  if (TargetTriple.isOSSolaris()) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
 "sparc-sun-solaris2.11"};



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


[clang] [Driver] Always use gas with -fno-integrated-as on Solaris (PR #65489)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth updated 
https://github.com/llvm/llvm-project/pull/65489:

>From b867ca65e585427a6d02c245d90797a08f6dfc8e Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Wed, 6 Sep 2023 16:35:27 +0200
Subject: [PATCH 1/2] [Driver] Always use gas with -fno-integrated-as on
 Solaris

`clang -fno-integrated-as` doesn't currently work on Solaris: it doesn't
even select between 32 or 64-bit objects.  Besides, Solaris has both the
native assembler (`/usr/bin/as`) and the GNU assembler (`/usr/bin/gas`
resp. `/usr/gnu/bin/as`).  The native sparc and x86 assemblers aren't
compatible with `clang`'s assembler syntax to varying degrees, and the
command line options for `as` and `gas` are completely different.

Therefore this patch chooses to always use `gas` on Solaris, using
`gnutools::Assembler::ConstructJob` to pass the correct options.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Gnu.cpp |  4 
 clang/lib/Driver/ToolChains/Solaris.cpp | 17 +++--
 clang/lib/Driver/ToolChains/Solaris.h   |  5 ++---
 clang/test/Driver/solaris-as.c  | 11 +++
 4 files changed, 20 insertions(+), 17 deletions(-)
 create mode 100644 clang/test/Driver/solaris-as.c

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index d215dd779217782..7aeb8e29ebc5574 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -700,6 +700,10 @@ void tools::gnutools::Assembler::ConstructJob(Compilation 
&C,
   unsigned PICLevel;
   bool IsPIE;
   const char *DefaultAssembler = "as";
+  // Enforce GNU as on Solaris; the native assembler's input syntax isn't fully
+  // compatible.
+  if (getToolChain().getTriple().isOSSolaris())
+DefaultAssembler = "gas";
   std::tie(RelocationModel, PICLevel, IsPIE) =
   ParsePICArgs(getToolChain(), Args);
 
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index a22e4c2e47b87e6..30b79b4d90e0118 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -8,6 +8,7 @@
 
 #include "Solaris.h"
 #include "CommonArgs.h"
+#include "Gnu.h"
 #include "clang/Basic/LangStandard.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
@@ -32,20 +33,8 @@ void solaris::Assembler::ConstructJob(Compilation &C, const 
JobAction &JA,
   const InputInfoList &Inputs,
   const ArgList &Args,
   const char *LinkingOutput) const {
-  claimNoWarnArgs(Args);
-  ArgStringList CmdArgs;
-
-  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
-
-  CmdArgs.push_back("-o");
-  CmdArgs.push_back(Output.getFilename());
-
-  for (const auto &II : Inputs)
-CmdArgs.push_back(II.getFilename());
-
-  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
-  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
- Exec, CmdArgs, Inputs, Output));
+  // Just call the Gnu version, which enforces gas on Solaris.
+  gnutools::Assembler::ConstructJob(C, JA, Output, Inputs, Args, 
LinkingOutput);
 }
 
 bool solaris::isLinkerGnuLd(const ToolChain &TC, const ArgList &Args) {
diff --git a/clang/lib/Driver/ToolChains/Solaris.h 
b/clang/lib/Driver/ToolChains/Solaris.h
index fe3e7f3a1f1b994..04b68c5053caa6c 100644
--- a/clang/lib/Driver/ToolChains/Solaris.h
+++ b/clang/lib/Driver/ToolChains/Solaris.h
@@ -19,10 +19,9 @@ namespace tools {
 
 /// solaris -- Directly call Solaris assembler and linker
 namespace solaris {
-class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
+class LLVM_LIBRARY_VISIBILITY Assembler : public gnutools::Assembler {
 public:
-  Assembler(const ToolChain &TC)
-  : Tool("solaris::Assembler", "assembler", TC) {}
+  Assembler(const ToolChain &TC) : gnutools::Assembler(TC) {}
 
   bool hasIntegratedCPP() const override { return false; }
 
diff --git a/clang/test/Driver/solaris-as.c b/clang/test/Driver/solaris-as.c
new file mode 100644
index 000..bf06dd97cc3862c
--- /dev/null
+++ b/clang/test/Driver/solaris-as.c
@@ -0,0 +1,11 @@
+/// General tests for assembler invocations on Solaris.
+
+/// Test that clang uses gas on Solaris.
+// RUN: %clang -x assembler %s -### -c -fno-integrated-as \
+// RUN: --target=sparc-sun-solaris2.11 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-GAS %s
+// RUN: %clang -x assembler %s -### -c -fno-integrated-as \
+// RUN: --target=sparc-sun-solaris2.11 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-GAS %s
+/// Allow for both "/usr/bin/gas" (native) and "gas" (cross) forms.
+// CHECK-GAS: gas"

>From 1aa6e3767b08b9767bee67c22863c5e170915839 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 11:24:10 +0200
Subject: [PATCH 2/2] Add -Wa, test.

---
 clang

[clang] [Driver] Always use gas with -fno-integrated-as on Solaris (PR #65489)

2023-09-07 Thread Rainer Orth via cfe-commits


@@ -0,0 +1,11 @@
+/// General tests for assembler invocations on Solaris.
+
+/// Test that clang uses gas on Solaris.
+// RUN: %clang -x assembler %s -### -c -fno-integrated-as \

rorth wrote:

Sure, done.

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


[clang] [Driver] Always use gas with -fno-integrated-as on Solaris (PR #65489)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Always use gas with -fno-integrated-as on Solaris (PR #65489)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [compiler-rt] [compiler-rt] adding safestack support for sunos platforms. (PR #95648)

2024-06-29 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch broke the 
[Solaris/amd64](https://lab.llvm.org/staging/#/builders/94/builds/4729) 
buildbot.

For god's sake, can you please either test your Illumos patches on Solaris, too 
(there are Solaris buildbots in the cfarm for exactly such a purpose) and 
finally handle Issue #53919 when it's necessary to distinguish Solaris and 
Illumos.

This happens ever and ever again with your patches and I'm getting pissed off 
by this attitude!

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


[clang] [compiler-rt] [safestack] Various Solaris fixes (PR #98001)

2024-07-08 Thread Rainer Orth via cfe-commits

https://github.com/rorth created https://github.com/llvm/llvm-project/pull/98001

At the end of the recent flurry of Illumos (and implicitly Solaris) safestack 
patches, the tests were disabled in
b0260c5b1052f8e3ff1ec77dc42a11f42da762cc without explanation.

After re-enabling them, there were many problems on Solaris:

- Every single testcase failed to link:

  ``` Undefined first referenced
   symbol   in file
  __safestack_unsafe_stack_ptrbuffer-copy-vla.o
  __safestack_init(command line)
  ld: fatal: symbol referencing errors
  ```

  The problem is that `-u __safestack_init` was passed to the linker after the 
corresponding version of `libclang_rt.safestack-*.a`.  Since the Solaris linker 
(like Unix linkers for decades) respects the command line argument order 
(unlike e.g. GNU ld which uses GNU getopt), this cannot work.  Fixed by moving 
the `-u` arg further to the front.  Two affected testcases were adjusted 
accordingly.

* While 540fd42c755f20f7b79c6c79493ec36d8cb9b3d3 enabled safestack on Solaris 
unconditionally, it ignored that Solaris also exists on SPARC and forgot to 
enable SPARC support.  This patch fixes that.

- Afterwards, the tests still fail to link with undefined references to 
`__sanitizer_internal_memset` etc.  These are from 
`sanitizer_redefine_builtins.h`.  Definitions live in `sanitizer_libc.cpp.o` 
and were added to the safestack runtime lib as is already the case e.g. for 
asan and ubsan.  Why GNU ld allows the link to complete with those symbols 
undefined is beyond me.

- The `pthread*.c` tests `FAIL` with

  ``` safestack CHECK failed: 
/vol/llvm/src/llvm-project/local/compiler-rt/lib/safestack/safestack.cpp:227 
size ```

  The problem is that `pthread_attr_init` initializes the `stacksize` attribute 
to 0, signifying the default.  Unless explicitly overridded, it stays that way. 
 I think this is allowed by XPG7.  Since safestack cannot deal with this, I set 
`size` to the defaults documented in `pthread_create(3C)`.  Unfortunately, 
there's no macro for those values outside of private `libc` headers.

- The Solaris `syscall` interface isn't stable.  This is not just a theoretical 
concern, but the syscalls have changed incompatibly several times in the past.  
Therefore this patch switches the implementations of `TgKill` (where 
`SYS_lwp_kill` doesn't exist on Solaris 11.4 anyway), `Mmap`, `Munmap`, and 
`Mprotect` to the same `_REAL*` solution already used in 
`sanitizer_solaris.cpp`.  Instead of duplicating what's already in 
`sanitizer_common`, it seems way better to me to just reuse those 
implementations, though.  A subsequent patch does just that.

With those changes, safestack compiles and all tests `PASS`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, 
`x86_64-pc-linux-gnu`, and `sparc64-unknown-linux-gnu`.

>From f8de9c3c2dbde4021f0d32a55c8a385221c0f749 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Mon, 8 Jul 2024 10:28:42 +0200
Subject: [PATCH] [safestack] Various Solaris fixes

At the end of the recent flurry of Illumos (and implicitly Solaris)
safestack patches, the tests were disabled in
b0260c5b1052f8e3ff1ec77dc42a11f42da762cc without explanation.

After re-enabling them, there were many problems on Solaris:

- Every single testcase failed to link:

  ```
  Undefined first referenced
   symbol   in file
  __safestack_unsafe_stack_ptrbuffer-copy-vla.o
  __safestack_init(command line)
  ld: fatal: symbol referencing errors
  ```

  The problem is that `-u __safestack_init` was passed to the linker after
  the corresponding version of `libclang_rt.safestack-*.a`.  Since the
  Solaris linker (like Unix linkers for decades) respects the command line
  argument order (unlike e.g. GNU ld which uses GNU getopt), this cannot
  work.  Fixed by moving the `-u` arg further to the front.  Two affected
  testcases were fixed accordingly.

* While 540fd42c755f20f7b79c6c79493ec36d8cb9b3d3 enabled safestack on
  Solaris unconditionally, it ignored that Solaris also exists on SPARC and
  forgot to enable SPARC support.  This patch fixes that.

- Afterwards, the tests still fail to link with undefined references to
  `__sanitizer_internal_memset` etc.  These are from
  `sanitizer_redefine_builtins.h`.  Definitions live in
  `sanitizer_libc.cpp.o` and were added to the safestack runtime lib as is
  already the case e.g. for asan and ubsan.  Why GNU ld allows the link to
  complete with those undefined is beyond me.

- The `pthread*.c` tests `FAIL` with

  ```
  safestack CHECK failed: 
/vol/llvm/src/llvm-project/local/compiler-rt/lib/safestack/safestack.cpp:227 
size
  ```

  The problem is that `pthread_attr_init` initializes the `stacksize`
  attribute to 0, signifying the default.  Unless explicitly overridded, it
  stays that way.  I think this is allowed by XPG7.  Since safestack cannot
  deal with this, I set 

[clang] [compiler-rt] [safestack] Various Solaris fixes (PR #98001)

2024-07-08 Thread Rainer Orth via cfe-commits

rorth wrote:

The mentioned patch to switch safestack to use the `sanitizer_common` functions 
instead of their own ones in `sanitizer_platform.h` has to wait until this one 
is approved: AFAIT github doesn't support stacked pull requests.

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


[clang] [compiler-rt] [safestack] Various Solaris fixes (PR #98001)

2024-07-08 Thread Rainer Orth via cfe-commits

rorth wrote:

> ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️
> You can test this locally with the following command:
> View the diff from clang-format here.
> 
> ```diff
> diff --git a/compiler-rt/lib/safestack/safestack_platform.h 
> b/compiler-rt/lib/safestack/safestack_platform.h
> index 77eeb9cda6..27e29d6ead 100644
> --- a/compiler-rt/lib/safestack/safestack_platform.h
> +++ b/compiler-rt/lib/safestack/safestack_platform.h
> @@ -13,9 +13,6 @@
>  #ifndef SAFESTACK_PLATFORM_H
>  #define SAFESTACK_PLATFORM_H
>  
> -#include "safestack_util.h"
> -#include "sanitizer_common/sanitizer_platform.h"
> -
>  #include 
>  #include 
>  #include 
> @@ -26,6 +23,9 @@
>  #include 
>  #include 
>  
> +#include "safestack_util.h"
> +#include "sanitizer_common/sanitizer_platform.h"
> +
>  #if !(SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX || \
>SANITIZER_SOLARIS)
>  #  error "Support for your platform has not been implemented"
> ```

I had seen that when running `clang-format-diff.py`, but chose to ignore that 
because it seems unrelated and even somewhat dangerous: there are often cases 
where you need to define some macro **before** including system headers.

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


[clang] [WIP][Driver] Enable ASan on Solaris/SPARC (PR #107403)

2024-09-05 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/107403

Once PR #107223 lands, ASan can be enabled on Solaris/SPARC.  This patch does 
just that.  As on Solaris/x86, the dynamic ASan runtime lib needs to be linked 
with `-z now` to avoid an `AsanInitInternal` cycle.

Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`.

This is not yet ready to be committed, though: even with the corresponding 
`compiler-rt` patch, 36 tests still `FAIL`.

For Linux/sparc64, nothing needs to be done since `clang` enables ASan by 
default, irrespective of target.  On top of that, test results are way worse, 
with quite a number of tests hanging completely.

>From 8cdf113112478ff7508d4e58df92f0e76a7360ce Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 5 Sep 2024 15:46:33 +0200
Subject: [PATCH] [WIP][Driver] Enable ASan on Solaris/SPARC

Once PR#107223 lands, ASan can be enabled on Solaris/SPARC.  This patch
does just that.  As on Solaris/x86, the dynamic ASan runtime lib needs to
be linked with `-z now` to avoid an `AsanInitInternal` cycle.

Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`.

This is not yet ready to be committed, though: even with the corresponding
`compiler-rt` patch, 36 tests still `FAIL`.

For Linux/sparc64, nothing needs to be done since `clang` enables ASan by
default, irrespective of target.  On top of that, test results are way
worse, with quite a number of tests hanging completely.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index e82ed2ca79ffd6..8d4ab40ce9f1de 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -265,8 +265,7 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 }
 // Avoid AsanInitInternal cycle, Issue #64126.
-if (ToolChain.getTriple().isX86() && SA.needsSharedRt() &&
-SA.needsAsanRt()) {
+if (SA.needsSharedRt() && SA.needsAsanRt()) {
   CmdArgs.push_back("-z");
   CmdArgs.push_back("now");
 }
@@ -333,10 +332,11 @@ Solaris::Solaris(const Driver &D, const llvm::Triple 
&Triple,
 }
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
+  const bool IsSparc = getTriple().getArch() == llvm::Triple::sparc;
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
-  // FIXME: Omit X86_64 until 64-bit support is figured out.
-  if (IsX86) {
+  // FIXME: Omit SparcV9 and X86_64 until 64-bit support is figured out.
+  if (IsSparc || IsX86) {
 Res |= SanitizerKind::Address;
 Res |= SanitizerKind::PointerCompare;
 Res |= SanitizerKind::PointerSubtract;

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


[clang] [Driver] Have getTargetSubDirPath better match get_compiler_rt_target (PR #100091)

2024-08-12 Thread Rainer Orth via cfe-commits

rorth wrote:

> Do we still need to fix this for 19.1.0-final?

I think so, yes.  E.g. when building on LLVM without specifying 
`LLVM_HOST_TRIPLE` explicitly (like when using `test-release.sh`), the 
`config.guess` output is used which is `sparc64-unknown-linux-gnu`.  However, 
`compiler-rt` always stores the 64-bit SPARC runtime libs in a `sparcv9-*` 
subdir, while `clang` only searches the target triple as determined or given.  
So we have a inconsistency and every attempt to link a runtime lib fails.  Not 
a particularly satisfying user experience.

The situation on Solaris/amd64 is similar.

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


[clang] [Driver] Have getTargetSubDirPath better match get_compiler_rt_target (PR #100091)

2024-08-12 Thread Rainer Orth via cfe-commits


@@ -766,9 +766,19 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
 return {};
   };
 
-  if (auto Path = getPathForTriple(getTriple()))
+  llvm::Triple Triple = getTriple();
+
+  // Try triple as is.
+  if (auto Path = getPathForTriple(Triple))
 return *Path;
 
+  // Match transformations in CompilerRTUtils.cmake:get_compiler_rt_target.

rorth wrote:

How would this change cause harm?  If a target uses e.g. an `x86_64-*` or 
`sparcv9-*` triple, it matches `compiler-rt` out of the box and this change 
doesn't make a difference.  If on the other hand a target uses the equivalent 
`amd64-*` or `sparc64-*` forms, they **need** to be transformed to the form 
that `compiler-rt` uses unconditionally, otherwise `clang` won't find the 
runtime libs.  This is what this patch does: bring `clang` and `compiler-rt` a 
little bit more in sync, nothing more, nothing less.  Where do you see any 
disruption in that?  Fixing tons of link failures in the testsuite isn't my 
definition of disruption, actually.

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


[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-08-15 Thread Rainer Orth via cfe-commits

rorth wrote:

FWIW, the hack even breaks when doing a `Debug` build: in that case the 
unresolved reference returns despite the hack.

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


[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)

2024-08-15 Thread Rainer Orth via cfe-commits

rorth wrote:

The patch also broke the [Solaris/sparcv9 
buildbot](https://lab.llvm.org/buildbot/#/builders/13/builds/1579).

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


[clang] [Driver] Have getTargetSubDirPath better match get_compiler_rt_target (PR #100091)

2024-07-23 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/100091

As explained in [[Driver] Support non-canonical triples with new runtime lib 
layout](https://reviews.llvm.org/D133407), there are massive problems if 
`clang`'s and `compiler-rt`'s ideas of the target triple don't match. This can 
happen e.g. on Solaris/amd64 (`amd64-pc-solaris2.11`, `amd64` being the 
customary name of 64-bit x86 on that target) or Linux/sparc64 
(`sparc64-unknown-linux-gnu`, where `config.sub` returns the `sparc64` form by 
default).

While some adjustments have been made in `compiler-rt` ([[compiler-rt] Handle 
non-canonical triples with new runtime lib
layout](https://reviews.llvm.org/D133406)), the `clang` side is still unfixed 
and the previous patch doesn't work any longer.

As the stop-gap measure, this patch takes two of the adjustments made in 
`CompilerRTUtils.cmake` (`get_compiler_rt_target`) and applies them to 
`ToolChain.cpp` (`getTargetSubDirPath`) which currently takes the target triple 
as is, creating a mismatch between `clang`s idea of the layout of 
`lib/clang//` and where `compiler-rt` actually installs the 
runtime libs.

The tests had to be trimmed massively because `clang -print-runtime-dir` lies 
since PR #87866: when the runtime libs are installed in the projects/classic 
layout, `clang` still emits the nonexisting runtimes layout.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

>From 4513f179765b432305bf79c71f691fcbb3fdc264 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Tue, 23 Jul 2024 11:36:07 +0200
Subject: [PATCH] [Driver] Have getTargetSubDirPath better match
 get_compiler_rt_target

As explained in [[Driver] Support non-canonical triples with new runtime
lib layout](https://reviews.llvm.org/D133407), there are massive problems
if `clang`'s and `compiler-rt`'s ideas of the target triple don't match.
This can happen e.g. on Solaris/amd64 (`amd64-pc-solaris2.11`, `amd64`
being the customary name of 64-bit x86 on that target) or Linux/sparc64
(`sparc64-unknown-linux-gnu`, where `config.sub` returns the `sparc64` form
by default).

While some adjustments have been made in `compiler-rt` ([[compiler-rt]
Handle non-canonical triples with new runtime lib
layout](https://reviews.llvm.org/D133406)), the `clang` side is still
unfixed and the previous patch doesn't work any longer.

As the stop-gap measure, this patch takes two of the adjustments made in
`CompilerRTUtils.cmake` (`get_compiler_rt_target`) and applies them to
`ToolChain.cpp` (`getTargetSubDirPath`) which currently takes the target
triple as is, creating a mismatch between `clang`s idea of the layout of
`lib/clang//` and where `compiler-rt` actually installs the
runtime libs.

The tests had to be trimmed massively because `clang -print-runtime-dir`
lies since PR #87866: when the runtime libs are installed in the
projects/classic layout, `clang` still emits the nonexisting runtimes
layout.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChain.cpp| 25 -
 .../lib/sparc64-linux-gnu/Scrt1.o |  0
 .../lib/sparc64-linux-gnu/crti.o  |  0
 .../lib/sparc64-linux-gnu/crtn.o  |  0
 .../lib/gcc/sparc64-linux-gnu/12/crtbeginS.o  |  0
 .../lib/gcc/sparc64-linux-gnu/12/crtendS.o|  0
 .../usr/lib/gcc/sparc64-linux-gnu/12/libgcc.a |  0
 .../lib/gcc/sparc64-linux-gnu/12/libgcc_s.so  |  0
 .../usr/lib/sparc64-linux-gnu/libc.so |  0
 .../usr/lib/sparc64-linux-gnu/libdl.so|  0
 .../usr/lib/sparc64-linux-gnu/libm.so |  0
 .../usr/lib/sparc64-linux-gnu/libpthread.so   |  0
 .../usr/lib/sparc64-linux-gnu/libresolv.so|  0
 .../usr/lib/sparc64-linux-gnu/librt.so|  0
 .../libclang_rt.ubsan_standalone.a|  0
 .../libclang_rt.ubsan_standalone.a|  0
 .../Driver/noncanon-per-target-runtime-dir.c  | 20 +++
 clang/test/Driver/runtime-layout.c| 35 +++
 18 files changed, 72 insertions(+), 8 deletions(-)
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/lib/sparc64-linux-gnu/Scrt1.o
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/lib/sparc64-linux-gnu/crti.o
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/lib/sparc64-linux-gnu/crtn.o
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/12/crtbeginS.o
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/12/crtendS.o
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/12/libgcc.a
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/12/libgcc_s.so
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/usr/lib/sparc64-linux-gnu/libc.so
 create mode 100644 
clang/test/Driver/Inputs/debian_sparc64_tree/usr/lib/sparc64-linux-gnu/libdl.so
 create mode 100644 
clang/tes

[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-24 Thread Rainer Orth via cfe-commits

rorth wrote:

This seems to have broken the 
[Solaris/amd64](https://lab.llvm.org/staging/#/builders/120/builds/187) and 
[Solaris/sparcv9](https://lab.llvm.org/buildbot/#/builders/13/builds/1030) 
buildbots.

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


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Rainer Orth via cfe-commits

rorth wrote:

> Aha!
> 
> https://bugs.llvm.org/show_bug.cgi?id=33767

Ah, old sins (from the GCC side no less) keep haunting me.

> We have a mixture of both `std::tm` and `::tm` in here, try switching to 
> using `::tm` and see if that helps.

Unfortunately not: I always get the undefined reference to the `std::tm const 
*` version, no matter what I tried.

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


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Rainer Orth via cfe-commits

rorth wrote:

> If you dump the symbols from the STL shared library on the system, is there 
> one for `time_put` at all? If so, what is the mangled symbol it exports?

While the source requires
```
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_

std::time_put > 
>::put(std::ostreambuf_iterator >, std::ios_base&, 
char, std::tm const*, char const*, char const*) const
```
`libstdc++.so.6` only provides
```
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPK2tmPKcSB_

std::time_put > 
>::put(std::ostreambuf_iterator >, std::ios_base&, 
char, tm const*, char const*, char const*) const
```
i.e. `tm const *` instead of `std::tm const *`.
> 
> (As a perhaps terrible idea, could we use the `alias` attribute on a 
> redeclaration to try to force to link against the correct mangling for 
> Solaris only?)

A hack along the lines of
```
asm("_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_
 = 
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPK2tmPKcSB_");
```
at least allows `clang` to link.

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


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Rainer Orth via cfe-commits

rorth wrote:

At least in the short term.  ISTM that `clang++` may need to do something along 
the lines of Bug 33767 (resp. the underlying GCC bug/patch), otherwise users 
are in for a nasty surprise.

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


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-26 Thread Rainer Orth via cfe-commits

rorth wrote:

> > At least in the short term. ISTM that `clang++` may need to do something 
> > along the lines of Bug 33767 (resp. the underlying GCC bug/patch), 
> > otherwise users are in for a nasty surprise.
> 
> Agreed; long-term we need a better solution. Hopefully someone maintaining 
> Solaris support can step in and help there, because this is quite surprising 
> behavior.

The cleaned-up hack is in the final rounds of testing.  Wlll create a PR once 
that's done.

There's no real Solaris maintainer AFAIK: while I do run the buildbots and try 
to keep the port in shape as time allows, I can only do so much.  The Solaris 
GCC maintainership takes enough of my time and splitting it would only be to 
the detriment of both projects.

TBH, I wouldn't even know where to look: I've mostly dealt with `compiler-rt` 
and driver issues so far.

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


[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-07-26 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/100724

The introduction of `std::put_time` in
fad17b43dbc09ac7e0a95535459845f72c2b739a broke the Solaris build:
```
Undefined   first referenced
 symbol in file
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_
 lib/libclangLex.a(PPMacroExpansion.cpp.o)
ld: fatal: symbol referencing errors
```
As discussed in PR #99075, the problem is that GCC mangles `std::tm` as `tm` on 
Solaris for binary compatility, while `clang` doesn't (Issue #33114).

As a stop-gap measure, this patch introduces an `asm` level alias to the same 
effect.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and 
`x86_64-pc-linux-gnu`.

>From 139569a6e48ceda0adc9fa8ca8e2d5d238f0712a Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Fri, 26 Jul 2024 11:15:16 +0200
Subject: [PATCH] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp

The introduction of `std::put_time` in
fad17b43dbc09ac7e0a95535459845f72c2b739a broke the Solaris build:
```
Undefined   first referenced
 symbol in file
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_
 lib/libclangLex.a(PPMacroExpansion.cpp.o)
ld: fatal: symbol referencing errors
```
As discussed in PR #99075, the problem is that GCC mangles `std::tm` as
`tm` on Solaris for binary compatility, while `clang` doesn't (Issue

As a stop-gap measure, this patch introduces an `asm` level alias to the
same effect.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Lex/PPMacroExpansion.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 879f01e87806e..1e31fcc3d731e 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1604,6 +1604,16 @@ static bool isTargetVariantEnvironment(const TargetInfo 
&TI,
   return false;
 }
 
+#if defined(__sun__) && defined(__svr4__)
+// GCC mangles std::tm as tm for binary compatibility on Solaris (Issue
+// #33114).  We need to match this to allow the std::put_time calls to link
+// (PR #99075).
+asm("_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"
+"RSt8ios_basecPKSt2tmPKcSB_ = "
+"_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_"
+"RSt8ios_basecPK2tmPKcSB_");
+#endif
+
 /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded
 /// as a builtin macro, handle it and return the next token as 'Tok'.
 void Preprocessor::ExpandBuiltinMacro(Token &Tok) {

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


[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-07-26 Thread Rainer Orth via cfe-commits

rorth wrote:

> Thank you for helping out with this odd edge case! I don't suppose there's a 
> way we can shove this hack into CMake (basically, like a kind of linker 
> script hack)? If so, can we apply it broadly enough so that any use of 
> `time_put` in other TUs will also benefit?

This would have to apply to all instances of `std::tm`, so I cannot say if this 
is feasible at all.  Besides, `clang` on Solaris supports both Solaris `ld` and 
GNU `ld`, which have different linker script syntax, duplicating the code if in 
fact both support the renaming.

This all seems like a waste of time to me.

> (If there are better alternatives than this approach, I'd love to hear about 
> them, this is a pretty gnarly way to go about working around the issue.)

I believe `clang` should something like `g++` to handle the mangling difference 
itself.  On the `g++` side of things, there's the 
`TARGET_CXX_DECL_MANGLING_CONTEXT` target hook, implemented for Solaris in 
`gcc/config/sol2-cxx.cc` (`solaris_cxx_decl_mangling_context`) and applied in 
`gcc/cp/mangle.cc` (`decl_mangling_context`) where it is called as 
`targetm.cxx.decl_mangling_context`.

As I've mentioned before, I've no idea where to do something similar in 
`clang`.  I believe that would be `clang/lib/CodeGen`

Whatever the case, we need at least a short-term solution now: the Solaris 
buildbots have been broken for two days now.


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


[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-07-26 Thread Rainer Orth via cfe-commits

rorth wrote:

> > Whatever the case, we need at least a short-term solution now: the Solaris 
> > buildbots have been broken for two days now.
> 
> Agreed that we need something in the short term, I'm just trying to find the 
> cleanest "something" under the assumption that this hack will live for a long 
> time. That's why I was hoping we could shove this into CMake somewhere (it's 
> less in everyone's face than the current approach). If we can't do that, then 
> I can live with this approach.

I just don't see how this can be done.  And TBH rather than pile hack upon 
hack, I'd rather spend some time on duplicating what GCC already does in Clang. 
 This will require tons and tons of guidance, though.

> Note: precommit CI failures look unrelated.

I think so: I've seen the same failure in my Linux/x86_64 but not on Solaris.

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


[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-07-26 Thread Rainer Orth via cfe-commits

rorth wrote:

Right, as is it's just a ugly hack with the underlying problem like to rear its 
ugly head again in the future.

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


[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-07-26 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Have getTargetSubDirPath better match get_compiler_rt_target (PR #100091)

2024-07-29 Thread Rainer Orth via cfe-commits

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


  1   2   >