[llvm] 00d5f1e - [SystemZ/ZOS] Additions to the build system.
Kai Nacke via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 03:55:32 PDT 2020
Author: Kai Nacke
Date: 2020-08-26T06:53:44-04:00
New Revision: 00d5f1ecccc6d8ece9ac6dd19e9ad807c8a60097
URL: https://github.com/llvm/llvm-project/commit/00d5f1ecccc6d8ece9ac6dd19e9ad807c8a60097
DIFF: https://github.com/llvm/llvm-project/commit/00d5f1ecccc6d8ece9ac6dd19e9ad807c8a60097.diff
LOG: [SystemZ/ZOS] Additions to the build system.
This change extend the CMake files with the necessary additions
to build LLVM for z/OS.
Reviewed By: hubert.reinterpretcast
Differential Revision: https://reviews.llvm.org/D83866
Added:
Modified:
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/GetHostTriple.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index ddf807156327..cb36ff397be7 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -354,7 +354,12 @@ option(LLVM_ENABLE_LIBEDIT "Use libedit if available." ON)
option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON)
-option(LLVM_ENABLE_THREADS "Use threads if available." ON)
+# On z/OS, threads cannot be used because TLS is not supported.
+if (CMAKE_SYSTEM_NAME MATCHES "OS390")
+ option(LLVM_ENABLE_THREADS "Use threads if available." OFF)
+else()
+ option(LLVM_ENABLE_THREADS "Use threads if available." ON)
+endif()
set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
@@ -932,6 +937,13 @@ if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -shared")
endif()
+# Build with _XOPEN_SOURCE on z/OS.
+if (CMAKE_SYSTEM_NAME MATCHES "OS390")
+ add_definitions("-D_XOPEN_SOURCE=600")
+ add_definitions("-D_OPEN_SYS") # Needed for process information.
+ add_definitions("-D_OPEN_SYS_FILE_EXT") # Needed for EBCDIC I/O.
+endif()
+
# Build with _FILE_OFFSET_BITS=64 on Solaris to match g++ >= 9.
if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
add_definitions("-D_FILE_OFFSET_BITS=64")
@@ -942,7 +954,7 @@ endif()
# check its symbols. This is wasteful (the check was done when foo.so
# was created) and can fail since it is not the dynamic linker and
# doesn't know how to handle search paths correctly.
-if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS|AIX")
+if (UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "SunOS|AIX|OS390")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
endif()
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 7b8077efab51..1689d36171c3 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -221,7 +221,7 @@ function(add_link_opts target_name)
# Pass -O3 to the linker. This enabled
diff erent optimizations on
diff erent
# linkers.
- if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|SunOS|AIX" OR WIN32))
+ if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|SunOS|AIX|OS390" OR WIN32))
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-O3")
endif()
@@ -249,11 +249,12 @@ function(add_link_opts target_name)
LINK_FLAGS " -Wl,-z,discard-unused=sections")
endif()
elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD AND
- NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD|AIX")
+ NOT CMAKE_SYSTEM_NAME MATCHES "OpenBSD|AIX|OS390")
# Object files are compiled with -ffunction-data-sections.
# Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
# tools that use plugins. Always pass --gc-sections once we require
# a newer linker.
+ # TODO Revisit this later on z/OS.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--gc-sections")
endif()
diff --git a/llvm/cmake/modules/GetHostTriple.cmake b/llvm/cmake/modules/GetHostTriple.cmake
index 251ca1a32b14..a5f033c1110d 100644
--- a/llvm/cmake/modules/GetHostTriple.cmake
+++ b/llvm/cmake/modules/GetHostTriple.cmake
@@ -14,7 +14,9 @@ function( get_host_triple var )
else()
set( value "i686-pc-windows-gnu" )
endif()
- elseif( CMAKE_HOST_SYSTEM_NAME STREQUAL AIX )
+ elseif( CMAKE_SYSTEM_NAME MATCHES "OS390" )
+ set( value "s390x-ibm-zos" )
+ elseif( CMAKE_SYSTEM_NAME STREQUAL AIX )
# We defer to dynamic detection of the host AIX version.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( value "powerpc64-ibm-aix" )
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 4feb4b7a7f30..3a0761d56f62 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -144,6 +144,10 @@ else(WIN32)
endif(FUCHSIA OR UNIX)
endif(WIN32)
+if (CMAKE_SYSTEM_NAME MATCHES "OS390")
+ set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
+endif()
+
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
@@ -207,7 +211,7 @@ endif()
# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
# build might work on ELF but fail on MachO/COFF.
-if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|SunOS" OR
+if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|SunOS|OS390" OR
WIN32 OR CYGWIN) AND
NOT LLVM_USE_SANITIZER)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
More information about the llvm-commits
mailing list