Skip to content

Commit

Permalink
Set up AIX XLClang flags for CMake builds
Browse files Browse the repository at this point in the history
The new compiler ID XLClang is for CMake 3.15 and beyond.

[skip ci]

Signed-off-by: Sharon Wang <sharon-wang-cpsc@outlook.com>

Co-authored-by: Devin Nakamura <devinn@ca.ibm.com>
  • Loading branch information
sharon-wang and dnakamura committed Feb 8, 2021
1 parent 63d2e6c commit 80b63f1
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmake/modules/OmrCompilerSupport.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -108,7 +108,7 @@ function(ppc_spp2s_files out_var compiler)
file(MAKE_DIRECTORY ${out_dir}) # just in case it doesn't exist already

add_custom_command(OUTPUT ${ipp_out_f}
COMMAND ${SPP_CMD} ${SPP_FLAGS} ${SPP_DEFINES} ${SPP_INCLUDES} -E -P ${absolute_in_f} > ${ipp_out_f}
COMMAND ${SPP_CMD} ${SPP_FLAGS} ${SPP_DEFINES} ${SPP_INCLUDES} ${absolute_in_f} > ${ipp_out_f}
DEPENDS ${in_f}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running preprocessing ${in_f} to create ${ipp_out_f}"
Expand Down
15 changes: 12 additions & 3 deletions cmake/modules/OmrDetectSystemInformation.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -75,7 +75,7 @@ endfunction()

# Translate from CMake's view of the system to the OMR view of the system.
# Exports a number of variables indicating platform, os, endianness, etc.
# - OMR_ARCH_{AARCH64,X86,ARM,S390} # TODO: Add POWER
# - OMR_ARCH_{AARCH64,X86,ARM,S390,POWER}
# - OMR_ENV_DATA{32,64}
# - OMR_ENV_TARGET_DATASIZE (either 32 or 64)
# - OMR_ENV_LITTLE_ENDIAN
Expand Down Expand Up @@ -198,8 +198,17 @@ macro(omr_detect_system_information)
# just use GNU config
set(_OMR_TOOLCONFIG "gnu")
endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "XL" OR CMAKE_C_COMPILER_ID STREQUAL "zOS")
elseif(CMAKE_C_COMPILER_ID MATCHES "^XL(Clang)?$" OR CMAKE_C_COMPILER_ID STREQUAL "zOS")
# In CMake 3.14 and prior, XLClang uses CMAKE_C_COMPILER_ID "XL"
# In CMake 3.15 and beyond, XLClang uses CMAKE_C_COMPILER_ID "XLClang"
set(_OMR_TOOLCONFIG "xlc")
if(CMAKE_C_COMPILER MATCHES ".*xlclang$")
# Checking the CMAKE_C_COMPILER command is necessary to determine if XLClang is
# the compiler, since XLClang might have CMAKE_C_COMPILER_ID "XL" or "XLClang"
# depending on the CMake version. Without this check, it's ambiguous whether the
# compiler is XLC or XLClang.
set(CMAKE_C_COMPILER_IS_XLCLANG TRUE CACHE BOOL "XLClang is the C compiler")
endif()
else()
message(FATAL_ERROR "OMR: Unknown compiler ID: '${CMAKE_CXX_COMPILER_ID}'")
endif()
Expand Down
8 changes: 7 additions & 1 deletion cmake/modules/ddr/DDRSetStub.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2019, 2020 IBM Corp. and others
# Copyright (c) 2019, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -141,6 +141,12 @@ function(process_source_files src_files)
)

set(pp_command "@CMAKE_C_COMPILER@")
if("@CMAKE_C_COMPILER_IS_XLCLANG@")
# XLClang seems to have trouble with *.h and *.hpp files here, claiming:
# "error: invalid argument '-std=gnu++0x' not allowed with 'C/ObjC'"
# Adding this option to the command alleviates this issue.
list(APPEND pp_command "-xc++")
endif()
list(APPEND pp_command ${BASE_ARGS} "-E" "${stub_file}")
add_custom_command(
OUTPUT "${annt_file}"
Expand Down
45 changes: 39 additions & 6 deletions cmake/modules/platform/toolcfg/xlc.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -19,6 +19,17 @@
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
###############################################################################

if(CMAKE_C_COMPILER_IS_XLCLANG)
macro(omr_toolconfig_global_setup)
# For XLClang, remove any usages of -qhalt=e or -qhalt=s provided by default
# in the CMAKE CXX/C/ASM FLAGS, since xlclang/xlclang++ are not compatible
# with the e or s options.
omr_remove_flags(CMAKE_ASM_FLAGS -qhalt=e)
omr_remove_flags(CMAKE_CXX_FLAGS -qhalt=s)
omr_remove_flags(CMAKE_C_FLAGS -qhalt=e)
endmacro(omr_toolconfig_global_setup)
endif()

if(OMR_HOST_ARCH STREQUAL "ppc")
set(OMR_WARNING_AS_ERROR_FLAG -qhalt=w)

Expand Down Expand Up @@ -53,23 +64,36 @@ if(OMR_HOST_ARCH STREQUAL "ppc")
list(APPEND TR_COMPILE_OPTIONS
-qarch=pwr7
-qtls
-qnotempinc
-qenum=small
-qmbcs
-qfuncsect
-qsuppress=1540-1087:1540-1088:1540-1090:1540-029:1500-029
-qdebug=nscrep
)

if(NOT CMAKE_C_COMPILER_IS_XLCLANG)
# xlc/xlc++ options
list(APPEND TR_COMPILE_OPTIONS
-qnotempinc
-qenum=small
-qmbcs
)
endif()

# Configure the platform dependent library for multithreading
set(OMR_PLATFORM_THREAD_LIBRARY -lpthread)
endif()

if(OMR_OS_AIX)
list(APPEND OMR_PLATFORM_COMPILE_OPTIONS -qinfo=pro)
list(APPEND OMR_PLATFORM_C_COMPILE_OPTIONS -qlanglvl=extended)
list(APPEND OMR_PLATFORM_CXX_COMPILE_OPTIONS -qlanglvl=extended0x)

if(CMAKE_C_COMPILER_IS_XLCLANG)
# xlclang/xlclang++ options
list(APPEND OMR_PLATFORM_COMPILE_OPTIONS -qxlcompatmacros)
else()
# xlc/xlc++ options
list(APPEND OMR_PLATFORM_COMPILE_OPTIONS -qinfo=pro)
endif()

set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lm -liconv -ldl -lperfstat")

if(OMR_ENV_DATA64)
Expand Down Expand Up @@ -177,7 +201,16 @@ elseif(OMR_OS_ZOS)
endif()

set(SPP_CMD ${CMAKE_C_COMPILER})
set(SPP_FLAGS -E -P)

if(CMAKE_C_COMPILER_IS_XLCLANG)
# xlclang/xlclang++ options
# The -P option doesn't sit well with XLClang, so it's not included. It causes:
# "ld: 0711-317 ERROR: Undefined symbol: <SYMBOL>" when libj9jit29.so is getting linked.
set(SPP_FLAGS -E)
else()
# xlc/xlc++ options
set(SPP_FLAGS -E -P)
endif()

if(OMR_OS_ZOS)
function(_omr_toolchain_process_exports TARGET_NAME)
Expand Down

0 comments on commit 80b63f1

Please sign in to comment.