Skip to content

Commit 25374a6

Browse files
committedJun 22, 2017
[Solaris] replace Solaris.h hack with a set of better hacks
Summary: Got rid of unwieldy -include Solaris.h portability solution, replacing it with interposed header and moving endian defines into Host.h. Fixes PR28370. Reviewers: joerg, alekseyshl, mgorny Reviewed By: joerg Subscribers: llvm-commits, mgorny, ro, krytarowski Patch by Fedor Sergeev. Differential Revision: https://reviews.llvm.org/D3413 llvm-svn: 306002
1 parent 674421e commit 25374a6

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed
 

‎llvm/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
804804
endif(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
805805

806806
if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
807-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h")
807+
# special hack for Solaris to handle crazy system sys/regset.h
808+
include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
808809
endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
809810

810811
# Make sure we don't get -rdynamic in every binary. For those that need it,

‎llvm/include/llvm/Support/Host.h

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
#include <endian.h>
2222
#elif defined(_AIX)
2323
#include <sys/machine.h>
24+
#elif defined(__sun)
25+
/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */
26+
#include <sys/types.h>
27+
#define BIG_ENDIAN 4321
28+
#define LITTLE_ENDIAN 1234
29+
#if defined(_BIG_ENDIAN)
30+
#define BYTE_ORDER BIG_ENDIAN
31+
#else
32+
#define BYTE_ORDER LITTLE_ENDIAN
33+
#endif
2434
#else
2535
#if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32)
2636
#include <machine/endian.h>

‎llvm/include/llvm/Support/Solaris.h renamed to ‎llvm/include/llvm/Support/Solaris/sys/regset.h

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*===- llvm/Support/Solaris.h ------------------------------------*- C++ -*-===*
1+
/*===- llvm/Support/Solaris/sys/regset.h ------------------------*- C++ -*-===*
22
*
33
* The LLVM Compiler Infrastructure
44
*
@@ -7,24 +7,14 @@
77
*
88
*===----------------------------------------------------------------------===*
99
*
10-
* This file contains portability fixes for Solaris hosts.
10+
* This file works around excessive name space pollution from the system header
11+
* on Solaris hosts.
1112
*
1213
*===----------------------------------------------------------------------===*/
1314

14-
#ifndef LLVM_SUPPORT_SOLARIS_H
15-
#define LLVM_SUPPORT_SOLARIS_H
15+
#ifndef LLVM_SUPPORT_SOLARIS_SYS_REGSET_H
1616

17-
#include <sys/regset.h>
18-
#include <sys/types.h>
19-
20-
/* Solaris doesn't have endian.h. SPARC is the only supported big-endian ISA. */
21-
#define BIG_ENDIAN 4321
22-
#define LITTLE_ENDIAN 1234
23-
#if defined(__sparc) || defined(__sparc__)
24-
#define BYTE_ORDER BIG_ENDIAN
25-
#else
26-
#define BYTE_ORDER LITTLE_ENDIAN
27-
#endif
17+
#include_next <sys/regset.h>
2818

2919
#undef CS
3020
#undef DS

‎llvm/include/llvm/module.modulemap

-3
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,6 @@ module LLVM_Utils {
275275
umbrella "Support"
276276
module * { export * }
277277

278-
// Exclude this; it's only included on Solaris.
279-
exclude header "Support/Solaris.h"
280-
281278
// Exclude this; it's fundamentally non-modular.
282279
exclude header "Support/PluginLoader.h"
283280

0 commit comments

Comments
 (0)