[PATCH] D34136: [Solaris] replace Solaris.h hack with a set of better hacks

Fedor Sergeev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 06:28:24 PDT 2017


fedor.sergeev updated this revision to Diff 102327.
fedor.sergeev marked an inline comment as not done.
fedor.sergeev added a comment.

module.modulemap: exclude Solaris/sys/regset.h
regset.h: modifying file comments as per Joerg's suggestion.


https://reviews.llvm.org/D34136

Files:
  CMakeLists.txt
  include/llvm/Support/Host.h
  include/llvm/Support/Solaris.h
  include/llvm/Support/Solaris/sys/regset.h
  include/llvm/module.modulemap


Index: include/llvm/module.modulemap
===================================================================
--- include/llvm/module.modulemap
+++ include/llvm/module.modulemap
@@ -275,8 +275,8 @@
     umbrella "Support"
     module * { export * }
 
-    // Exclude this; it's only included on Solaris.
-    exclude header "Support/Solaris.h"
+    // Exclude this; it's only included on Solaris
+    exclude header "Support/Solaris/sys/regset.h"
 
     // Exclude this; it's fundamentally non-modular.
     exclude header "Support/PluginLoader.h"
Index: include/llvm/Support/Solaris/sys/regset.h
===================================================================
--- include/llvm/Support/Solaris/sys/regset.h
+++ include/llvm/Support/Solaris/sys/regset.h
@@ -1,30 +1,19 @@
-/*===- llvm/Support/Solaris.h ------------------------------------*- C++ -*-===*
+/*===- llvm/Support/Solaris/sys/regset.h ------------------------------------*- C++ -*-===*
  *
  *                     The LLVM Compiler Infrastructure
  *
  * This file is distributed under the University of Illinois Open Source
  * License. See LICENSE.TXT for details.
  *
  *===----------------------------------------------------------------------===*
  *
- * This file contains portability fixes for Solaris hosts.
+ * This file works around excessive name space pollution from the system header on Solaris hosts.
  *
  *===----------------------------------------------------------------------===*/
 
-#ifndef LLVM_SUPPORT_SOLARIS_H
-#define LLVM_SUPPORT_SOLARIS_H
+#ifndef LLVM_SUPPORT_SOLARIS_SYS_REGSET_H
 
-#include <sys/regset.h>
-#include <sys/types.h>
-
-/* Solaris doesn't have endian.h. SPARC is the only supported big-endian ISA. */
-#define BIG_ENDIAN 4321
-#define LITTLE_ENDIAN 1234
-#if defined(__sparc) || defined(__sparc__)
-#define BYTE_ORDER BIG_ENDIAN
-#else
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
+#include_next <sys/regset.h>
 
 #undef CS
 #undef DS
Index: include/llvm/Support/Host.h
===================================================================
--- include/llvm/Support/Host.h
+++ include/llvm/Support/Host.h
@@ -21,6 +21,15 @@
 #include <endian.h>
 #elif defined(_AIX)
 #include <sys/machine.h>
+#elif defined(__sun)
+/* Solaris doesn't have endian.h. SPARC is the only supported big-endian ISA. */
+#define BIG_ENDIAN 4321
+#define LITTLE_ENDIAN 1234
+#if defined(__sparc) || defined(__sparc__)
+#define BYTE_ORDER BIG_ENDIAN
+#else
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
 #else
 #if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32)
 #include <machine/endian.h>
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -800,7 +800,8 @@
 endif(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
 
 if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
-   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h")
+   # special hack for Solaris to handle crazy system sys/regset.h
+   include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
 endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
 
 # Make sure we don't get -rdynamic in every binary. For those that need it,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34136.102327.patch
Type: text/x-patch
Size: 3152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/11e6ac6a/attachment.bin>


More information about the llvm-commits mailing list