From 66a405b467abbcd7aac3a5f0b14833b819235351 Mon Sep 17 00:00:00 2001 From: Gaurav Chaudhari Date: Thu, 25 Apr 2024 08:17:53 -0700 Subject: [PATCH] Flag changes and minor fixes for Open XL compile Some of the remaining compiling issues require some updates to the existing ZOS flags in order to compile properly using Open XL for z/OS. Tested to ensure that XLC remains compiling properly and passes its tests. Bump to D_OPEN_THREADS=3 as recommended by Open XL devs to enable/expose pthread functions that may be used and without which can cause compilation issues. source: https://www.ibm.com/docs/en/zos/2.5.0?topic=files-feature-test-macros Signed-off-by: Gaurav Chaudhari --- cmake/modules/platform/os/zos.cmake | 2 +- .../platform/toolcfg/zos_rename_exports.cmake | 7 ++++--- fvtest/omrGtestGlue/CMakeLists.txt | 7 ++++++- fvtest/porttest/omrvmemTest.cpp | 1 + fvtest/sigtest/sigTest.cpp | 2 +- omrsigcompat/omrsig.cpp | 2 +- .../include/gtest/internal/gtest-port.h | 14 +++++++------- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cmake/modules/platform/os/zos.cmake b/cmake/modules/platform/os/zos.cmake index 76f7de5746..179bc9be48 100644 --- a/cmake/modules/platform/os/zos.cmake +++ b/cmake/modules/platform/os/zos.cmake @@ -21,7 +21,7 @@ list(APPEND OMR_PLATFORM_DEFINITIONS -D_ALL_SOURCE - -D_OPEN_THREADS=2 + -D_OPEN_THREADS=3 -D_POSIX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_ISOC99_SOURCE diff --git a/cmake/modules/platform/toolcfg/zos_rename_exports.cmake b/cmake/modules/platform/toolcfg/zos_rename_exports.cmake index d6556493fb..614030dbf1 100644 --- a/cmake/modules/platform/toolcfg/zos_rename_exports.cmake +++ b/cmake/modules/platform/toolcfg/zos_rename_exports.cmake @@ -37,7 +37,7 @@ if(NOT ARCHIVE_DIR) set(ARCHIVE_DIR ${RUNTIME_DIR}) endif() -if(NOT EXISTS "${ARCHVIVE_DIR}") +if(NOT EXISTS "${ARCHIVE_DIR}") file(MAKE_DIRECTORY "${ARCHIVE_DIR}") endif() string(FIND "${LIBRARY_FILE_NAME}" "." dot_pos REVERSE) @@ -45,11 +45,12 @@ string(SUBSTRING "${LIBRARY_FILE_NAME}" 0 ${dot_pos} base_name) set(SRC_FILE "${CMAKE_BINARY_DIR}/${base_name}.x") set(DEST_FILE "${ARCHIVE_DIR}/${base_name}.x") -if(NOT "${SRC_FILE}" STREQUAL "${DEST_FILE}") + +if(EXISTS ${SRC_FILE} AND NOT "${SRC_FILE}" STREQUAL "${DEST_FILE}") file(RENAME "${SRC_FILE}" "${DEST_FILE}") endif() # Work around a bug in CMake where it looks for .x files in the runime dir rather than the archive dir. -if(NOT "${ARCHIVE_DIR}" STREQUAL "${RUNTIME_DIR}") +if(EXISTS ${DEST_FILE} AND NOT "${ARCHIVE_DIR}" STREQUAL "${RUNTIME_DIR}") file(COPY "${DEST_FILE}" DESTINATION "${RUNTIME_DIR}") endif() diff --git a/fvtest/omrGtestGlue/CMakeLists.txt b/fvtest/omrGtestGlue/CMakeLists.txt index d01af32ec2..18b26ca7f8 100644 --- a/fvtest/omrGtestGlue/CMakeLists.txt +++ b/fvtest/omrGtestGlue/CMakeLists.txt @@ -66,8 +66,13 @@ endif() if(OMR_OS_AIX OR OMR_OS_ZOS) list(APPEND OMR_GTEST_DEFINITIONS -DGTEST_ENV_HAS_STD_TUPLE_ - -D__IBMCPP_TR1__ ) + + if(NOT OMR_TOOLCONFIG STREQUAL "openxl") + list(APPEND OMR_GTEST_DEFINITIONS + -D__IBMCPP_TR1__ + ) + endif() endif() target_compile_options(omrGtest diff --git a/fvtest/porttest/omrvmemTest.cpp b/fvtest/porttest/omrvmemTest.cpp index 1704e6f36a..c31b373f4e 100644 --- a/fvtest/porttest/omrvmemTest.cpp +++ b/fvtest/porttest/omrvmemTest.cpp @@ -265,6 +265,7 @@ isNewPageSize(uintptr_t pageSize, uintptr_t pageFlags) * On z/OS, 1M fixed and 2G fixed pages can be used only to allocate above 2G bar. * Only 4K and 1M pageable pages can be used to allocate memory below the bar. */ +BOOLEAN isPageSizeSupportedBelowBar(uintptr_t pageSize, uintptr_t pageFlags) { if ((FOUR_KB == pageSize) || diff --git a/fvtest/sigtest/sigTest.cpp b/fvtest/sigtest/sigTest.cpp index 244309fdf5..25b08e8bd6 100644 --- a/fvtest/sigtest/sigTest.cpp +++ b/fvtest/sigtest/sigTest.cpp @@ -20,7 +20,7 @@ *******************************************************************************/ #if defined(J9ZOS390) -#define _OPEN_THREADS 2 +#define _OPEN_THREADS 3 #define _UNIX03_SOURCE #endif /* defined(J9ZOS390) */ diff --git a/omrsigcompat/omrsig.cpp b/omrsigcompat/omrsig.cpp index ac4b153453..194d0b4df8 100644 --- a/omrsigcompat/omrsig.cpp +++ b/omrsigcompat/omrsig.cpp @@ -21,7 +21,7 @@ *******************************************************************************/ #if defined(J9ZOS390) -#define _OPEN_THREADS 2 +#define _OPEN_THREADS 3 #define _UNIX03_SOURCE #endif /* defined(J9ZOS390) */ diff --git a/third_party/gtest-1.8.0/include/gtest/internal/gtest-port.h b/third_party/gtest-1.8.0/include/gtest/internal/gtest-port.h index 79559f29b2..2489d2f2a9 100644 --- a/third_party/gtest-1.8.0/include/gtest/internal/gtest-port.h +++ b/third_party/gtest-1.8.0/include/gtest/internal/gtest-port.h @@ -478,7 +478,7 @@ struct _RTL_CRITICAL_SECTION; // detecting whether they are enabled or not. Therefore, we assume that // they are enabled unless the user tells us otherwise. # define GTEST_HAS_EXCEPTIONS 1 -# elif defined(__IBMCPP__) && __EXCEPTIONS +# elif (defined(__IBMCPP__) || (defined(__open_xl__) && defined(__cplusplus))) && __EXCEPTIONS // xlC defines __EXCEPTIONS to 1 iff exceptions are enabled. # define GTEST_HAS_EXCEPTIONS 1 # elif defined(__HP_aCC) @@ -570,7 +570,7 @@ struct _RTL_CRITICAL_SECTION; // Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if // both the typeid and dynamic_cast features are present. -# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900) +# elif (defined(__IBMCPP__) && (__IBMCPP__ >= 900)) || (defined(__open_xl__) && defined(__cplusplus)) # ifdef __RTTI_ALL__ # define GTEST_HAS_RTTI 1 @@ -690,11 +690,11 @@ struct _RTL_CRITICAL_SECTION; # elif GTEST_ENV_HAS_STD_TUPLE_ # include -#if defined(J9ZOS390) || defined(AIXPPC) +#if (defined(J9ZOS390) && !defined(__open_xl__)) || defined(AIXPPC) // On z/OS and AIX, tuple is defined in the ::std::tr1 namespace as it is an // extension class since xlc does not support the full C++11 standard. As such, // we expose the tuple class in the ::std namespace such that code below will -// work. +// work. However, Open XL does support C++11 standard. namespace std { using ::std::tr1::get; @@ -821,7 +821,7 @@ using ::std::tuple_size; // Typed tests need and variadic macros, which GCC, VC++ 8.0, // Sun Pro CC, IBM Visual Age, and HP aCC support. #if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \ - defined(__IBMCPP__) || defined(__HP_aCC) + defined(__IBMCPP__) || defined(__HP_aCC) || (defined(__open_xl__) && defined(__cplusplus)) # define GTEST_HAS_TYPED_TEST 1 # define GTEST_HAS_TYPED_TEST_P 1 #endif @@ -2200,7 +2200,7 @@ GTEST_API_ size_t GetThreadCount(); // for objects passed through ellipsis (...), failing for uncopyable // objects. We define this to ensure that only POD is passed through // ellipsis on these systems. -#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC) +#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC) || (defined(__open_xl__) && defined(__cplusplus)) // We lose support for NULL detection where the compiler doesn't like // passing non-POD classes through ellipsis (...). # define GTEST_ELLIPSIS_NEEDS_POD_ 1 @@ -2212,7 +2212,7 @@ GTEST_API_ size_t GetThreadCount(); // const T& and const T* in a function template. These compilers // _can_ decide between class template specializations for T and T*, // so a tr1::type_traits-like is_pointer works. -#if defined(__SYMBIAN32__) || defined(__IBMCPP__) +#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || (defined(__open_xl__) && defined(__cplusplus)) # define GTEST_NEEDS_IS_POINTER_ 1 #endif