|
| 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