Skip to content

Commit 7dfa384

Browse files
authored
Merge pull request #7319 from Deigue/openxl-toolchain
Add Open XL toolchain and config changes for z/OS
2 parents bb9528d + 0126fe0 commit 7dfa384

File tree

3 files changed

+148
-2
lines changed

3 files changed

+148
-2
lines changed

cmake/modules/OmrDetectSystemInformation.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,25 @@ macro(omr_detect_system_information)
202202
# just use GNU config
203203
set(_OMR_TOOLCONFIG "gnu")
204204
endif()
205+
elseif((CMAKE_C_COMPILER_ID MATCHES "IBMClang$") OR (CMAKE_C_COMPILER MATCHES ".*ibm-clang.*"))
206+
set(_OMR_TOOLCONFIG "openxl")
207+
set(CMAKE_C_COMPILER_IS_OPENXL ON CACHE BOOL "ibm-clang is the C compiler")
205208
elseif(CMAKE_C_COMPILER_ID MATCHES "^XL(Clang)?$" OR CMAKE_C_COMPILER_ID STREQUAL "zOS")
206209
# In CMake 3.14 and prior, XLClang uses CMAKE_C_COMPILER_ID "XL"
207210
# In CMake 3.15 and beyond, XLClang uses CMAKE_C_COMPILER_ID "XLClang"
208211
set(_OMR_TOOLCONFIG "xlc")
212+
message(STATUS "CMAKE_C_COMPILER is ${CMAKE_C_COMPILER}")
209213
if(CMAKE_C_COMPILER MATCHES ".*xlclang$")
210214
# Checking the CMAKE_C_COMPILER command is necessary to determine if XLClang is
211215
# the compiler, since XLClang might have CMAKE_C_COMPILER_ID "XL" or "XLClang"
212216
# depending on the CMake version. Without this check, it's ambiguous whether the
213217
# compiler is XLC or XLClang.
214218
set(CMAKE_C_COMPILER_IS_XLCLANG TRUE CACHE BOOL "XLClang is the C compiler")
219+
else()
220+
message(STATUS "NO XLClang match. Using xlc toolchain.")
215221
endif()
216222
else()
217-
message(FATAL_ERROR "OMR: Unknown compiler ID: '${CMAKE_CXX_COMPILER_ID}'")
223+
message(FATAL_ERROR "OMR: Unknown compiler ID: '${CMAKE_C_COMPILER_ID}'")
218224
endif()
219225
set(OMR_TOOLCONFIG ${_OMR_TOOLCONFIG} CACHE STRING "Name of toolchain configuration options to use")
220226
endif()

cmake/modules/ddr/DDRSetStub.cmake.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function(process_source_files src_files)
145145
# Adding this option to the command alleviates this issue.
146146
list(APPEND pp_command "-xc++")
147147
endif()
148-
if("@OMR_OS_ZOS@" AND "@OMR_ENV_DATA64@")
148+
if("@OMR_OS_ZOS@" AND "@OMR_ENV_DATA64@" AND NOT "@OMR_TOOLCONFIG@" STREQUAL "openxl")
149149
# We need to set 64 bit code generation to ensure that limits.h macros are set correctly.
150150
list(APPEND pp_command "-Wc,lp64")
151151
endif()
+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
###############################################################################
2+
# Copyright IBM Corp. and others 2024
3+
#
4+
# This program and the accompanying materials are made available under
5+
# the terms of the Eclipse Public License 2.0 which accompanies this
6+
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7+
# or the Apache License, Version 2.0 which accompanies this distribution
8+
# and is available at https://www.apache.org/licenses/LICENSE-2.0.
9+
#
10+
# This Source Code may also be made available under the following Secondary
11+
# Licenses when the conditions for such availability set forth in the
12+
# Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
13+
# version 2 with the GNU Classpath Exception [1] and GNU General Public
14+
# License, version 2 with the OpenJDK Assembly Exception [2].
15+
#
16+
# [1] https://www.gnu.org/software/classpath/license.html
17+
# [2] https://openjdk.org/legal/assembly-exception.html
18+
#
19+
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
20+
###############################################################################
21+
22+
if(OMR_OS_ZOS)
23+
set(OMR_ZOS_COMPILE_ARCHITECTURE "arch10" CACHE STRING "z/OS compile machine architecture" FORCE)
24+
set(OMR_ZOS_COMPILE_TARGET "ZOSV2R4" CACHE STRING "z/OS compile target operating system" FORCE)
25+
set(OMR_ZOS_COMPILE_TUNE "12" CACHE STRING "z/OS compile machine architecture tuning" FORCE)
26+
set(OMR_ZOS_LINK_COMPAT "ZOSV2R4" CACHE STRING "z/OS link compatible operating system" FORCE)
27+
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "--shared")
28+
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "--shared")
29+
30+
set(CMAKE_ASM_FLAGS "-fno-integrated-as")
31+
string(APPEND CMAKE_ASM_FLAGS " \"-Wa,-mgoff\"")
32+
if(OMR_ENV_DATA64)
33+
string(APPEND CMAKE_ASM_FLAGS " \"-Wa,-mSYSPARM(BIT64)\"")
34+
endif()
35+
36+
list(APPEND OMR_PLATFORM_COMPILE_OPTIONS
37+
"-fstrict-aliasing"
38+
"-mzos-target=${OMR_ZOS_COMPILE_TARGET}"
39+
"-m64"
40+
)
41+
42+
list(APPEND OMR_PLATFORM_C_COMPILE_OPTIONS
43+
-march=${OMR_ZOS_COMPILE_ARCHITECTURE}
44+
)
45+
46+
# -std=gnu++14 is used over -std=cpp++14, as the gnu* options are closest to
47+
# -qlanglvl=extended (enabling most extensions by default). This is preferred
48+
# in order to avoid defining _EXT repeatedly in most places.
49+
list(APPEND OMR_PLATFORM_CXX_COMPILE_OPTIONS
50+
-march=${OMR_ZOS_COMPILE_ARCHITECTURE}
51+
"-std=gnu++14"
52+
-fasm
53+
)
54+
55+
list(APPEND OMR_PLATFORM_SHARED_COMPILE_OPTIONS
56+
-fvisibility=default
57+
)
58+
59+
if(OMR_ENV_DATA64)
60+
list(APPEND OMR_PLATFORM_DEFINITIONS
61+
-DJ9ZOS39064
62+
)
63+
else()
64+
list(APPEND OMR_PLATFORM_DEFINITIONS
65+
-D_LARGE_FILES
66+
)
67+
endif()
68+
69+
# Testarossa build variables. Longer term the distinction between TR and the rest
70+
# of the OMR code should be heavily reduced. In the mean time, we keep
71+
# the distinction.
72+
73+
# TR_COMPILE_OPTIONS are variables appended to CMAKE_{C,CXX}_FLAGS, and so
74+
# apply to both C and C++ compilations.
75+
list(APPEND TR_COMPILE_OPTIONS
76+
-DYYLMAX=1000
77+
)
78+
79+
list(APPEND TR_CXX_COMPILE_OPTIONS
80+
-Wuninitialized
81+
-mnocsect
82+
)
83+
84+
# Configure the platform-dependent library for multithreading.
85+
set(OMR_PLATFORM_THREAD_LIBRARY "")
86+
endif()
87+
88+
set(SPP_CMD ${CMAKE_C_COMPILER})
89+
set(SPP_FLAGS -E -P)
90+
91+
if(OMR_OS_ZOS)
92+
function(_omr_toolchain_process_exports TARGET_NAME)
93+
# Any type of target which says it has exports should get the DLL, and EXPORTALL
94+
# compile flags.
95+
# Open XL equivalent has been added below.
96+
target_compile_options(${TARGET_NAME}
97+
PRIVATE
98+
-fvisibility=default
99+
)
100+
101+
get_target_property(target_type ${TARGET_NAME} TYPE)
102+
if(NOT target_type STREQUAL "SHARED_LIBRARY")
103+
return()
104+
endif()
105+
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
106+
COMMAND "${CMAKE_COMMAND}"
107+
"-DLIBRARY_FILE_NAME=$<TARGET_FILE_NAME:${TARGET_NAME}>"
108+
"-DRUNTIME_DIR=$<TARGET_FILE_DIR:${TARGET_NAME}>"
109+
"-DARCHIVE_DIR=$<TARGET_PROPERTY:${TARGET_NAME},ARCHIVE_OUTPUT_DIRECTORY>"
110+
-P "${omr_SOURCE_DIR}/cmake/modules/platform/toolcfg/zos_rename_exports.cmake"
111+
)
112+
endfunction()
113+
else()
114+
function(_omr_toolchain_process_exports TARGET_NAME)
115+
get_target_property(target_type ${TARGET_NAME} TYPE)
116+
if(NOT target_type STREQUAL "SHARED_LIBRARY")
117+
return()
118+
endif()
119+
120+
set(exp_file "$<TARGET_PROPERTY:${TARGET_NAME},BINARY_DIR>/${TARGET_NAME}.exp")
121+
omr_process_template(
122+
"${omr_SOURCE_DIR}/cmake/modules/platform/toolcfg/xlc_exports.exp.in"
123+
"${exp_file}"
124+
)
125+
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-bE:${TARGET_NAME}.exp")
126+
endfunction()
127+
128+
function(_omr_toolchain_separate_debug_symbols tgt)
129+
set(exe_file "$<TARGET_FILE:${tgt}>")
130+
omr_get_target_output_genex(${tgt} output_name)
131+
set(dbg_file "${output_name}${OMR_DEBUG_INFO_OUTPUT_EXTENSION}")
132+
add_custom_command(
133+
TARGET "${tgt}"
134+
POST_BUILD
135+
COMMAND "${CMAKE_COMMAND}" -E copy ${exe_file} ${dbg_file}
136+
COMMAND "${CMAKE_STRIP}" -X32_64 -t ${exe_file}
137+
)
138+
set_target_properties(${tgt} PROPERTIES OMR_DEBUG_FILE "${dbg_file}")
139+
endfunction()
140+
endif()

0 commit comments

Comments
 (0)