From 9a3ec90b08a3bf40dd46147982f0fb79417e52ff Mon Sep 17 00:00:00 2001 From: Ishita Ray Date: Wed, 25 Sep 2024 15:55:21 -0400 Subject: [PATCH] Add macro to openxl specific changes Signed-off-by: Ishita Ray --- cmake/modules/OmrMetalC.cmake | 6 ++- cmake/modules/platform/toolcfg/gnu.cmake | 50 +++++++++++++++----- compiler/env/jittypes.h | 4 +- compiler/ras/CallStack.cpp | 25 ++++++---- compiler/ras/DebugCounter.cpp | 12 ++++- configure | 31 +++++++++---- omrmakefiles/rules.aix.mk | 58 ++++++++++++++++++------ port/unix/omrsignal.c | 20 ++++---- tools/configure | 31 +++++++++---- util/omrutil/gettimebase.c | 8 +++- 10 files changed, 178 insertions(+), 67 deletions(-) diff --git a/cmake/modules/OmrMetalC.cmake b/cmake/modules/OmrMetalC.cmake index 03ecfaf0e5c..8595b7ea3e4 100644 --- a/cmake/modules/OmrMetalC.cmake +++ b/cmake/modules/OmrMetalC.cmake @@ -58,7 +58,11 @@ function(omr_compile_metalc mfile ofile) omr_assert(TEST AS_EXECUTABLE) if(OMR_ENV_DATA64) - list(APPEND OMR_METALC_XLC_FLAGS "-q64") + if(CMAKE_C_COMPILER_IS_OPENXL) + list(APPEND OMR_METALC_XLC_FLAGS "-m64") + else() + list(APPEND OMR_METALC_XLC_FLAGS "-q64") + endif() endif() if(NOT IS_ABSOLUTE "${mfile}") diff --git a/cmake/modules/platform/toolcfg/gnu.cmake b/cmake/modules/platform/toolcfg/gnu.cmake index e91b41730db..cc2685d3e3c 100644 --- a/cmake/modules/platform/toolcfg/gnu.cmake +++ b/cmake/modules/platform/toolcfg/gnu.cmake @@ -19,10 +19,11 @@ # 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 ############################################################################# -set(OMR_C_WARNINGS_AS_ERROR_FLAG -Werror) -set(OMR_CXX_WARNINGS_AS_ERROR_FLAG -Werror) -set(OMR_NASM_WARNINGS_AS_ERROR_FLAG -Werror) - +if(NOT CMAKE_C_COMPILER_IS_OPENXL) + set(OMR_C_WARNINGS_AS_ERROR_FLAG -Werror) + set(OMR_CXX_WARNINGS_AS_ERROR_FLAG -Werror) + set(OMR_NASM_WARNINGS_AS_ERROR_FLAG -Werror) +endif() set(OMR_C_ENHANCED_WARNINGS_FLAG -Wall) set(OMR_CXX_ENHANCED_WARNINGS_FLAG -Wall) set(OMR_NASM_ENHANCED_WARNINGS_FLAG -Wall) @@ -68,6 +69,19 @@ if(OMR_HOST_ARCH STREQUAL "s390") list(APPEND OMR_PLATFORM_COMPILE_OPTIONS -march=z9-109) endif() +if(OMR_OS_AIX AND CMAKE_C_COMPILER_IS_OPENXL) + omr_append_flags(CMAKE_C_FLAGS "-m64") + omr_append_flags(CMAKE_CXX_FLAGS "-m64") + omr_append_flags(CMAKE_ASM_FLAGS "-m64") + omr_append_flags(CMAKE_SHARED_LINKER_FLAGS "-m64") + + if(OMR_ENV_DATA64) + set(CMAKE_CXX_ARCHIVE_CREATE " -X64 cr ") + set(CMAKE_C_ARCHIVE_CREATE " -X64 cr ") + set(CMAKE_C_ARCHIVE_FINISH " -X64 ") + endif() +endif() + # Testarossa build variables. Longer term the distinction between TR and the rest # of the OMR code should be heavily reduced. In the meantime, we keep the distinction. @@ -110,13 +124,25 @@ function(_omr_toolchain_separate_debug_symbols tgt) else() omr_get_target_output_genex(${tgt} output_name) set(dbg_file "${output_name}${OMR_DEBUG_INFO_OUTPUT_EXTENSION}") - add_custom_command( - TARGET "${tgt}" - POST_BUILD - COMMAND "${CMAKE_OBJCOPY}" --only-keep-debug "${exe_file}" "${dbg_file}" - COMMAND "${CMAKE_OBJCOPY}" --strip-debug "${exe_file}" - COMMAND "${CMAKE_OBJCOPY}" --add-gnu-debuglink="${dbg_file}" "${exe_file}" - ) + if(OMR_OS_AIX AND CMAKE_C_COMPILER_IS_OPENXL) + add_custom_command( + TARGET "${tgt}" + POST_BUILD + #COMMAND "${CMAKE_OBJCOPY}" --only-keep-debug "${exe_file}" "${dbg_file}" + #COMMAND "${CMAKE_OBJCOPY}" --strip-debug "${exe_file}" + #COMMAND "${CMAKE_OBJCOPY}" --add-gnu-debuglink="${dbg_file}" "${exe_file}" + COMMAND "${CMAKE_COMMAND}" -E copy ${exe_file} ${dbg_file} + COMMAND "${CMAKE_STRIP}" -X32_64 ${exe_file} + ) + else() + add_custom_command( + TARGET "${tgt}" + POST_BUILD + COMMAND "${CMAKE_OBJCOPY}" --only-keep-debug "${exe_file}" "${dbg_file}" + COMMAND "${CMAKE_OBJCOPY}" --strip-debug "${exe_file}" + COMMAND "${CMAKE_OBJCOPY}" --add-gnu-debuglink="${dbg_file}" "${exe_file}" + ) + endif() endif() set_target_properties(${tgt} PROPERTIES OMR_DEBUG_FILE "${dbg_file}") endfunction() @@ -140,7 +166,9 @@ function(_omr_toolchain_process_exports TARGET_NAME) "${exp_file}" ) +if(NOT CMAKE_C_COMPILER_IS_OPENXL) target_link_libraries(${TARGET_NAME} PRIVATE "-Wl,--version-script,${exp_file}") +endif() endfunction() diff --git a/compiler/env/jittypes.h b/compiler/env/jittypes.h index f13f79df1f9..c46902c6147 100644 --- a/compiler/env/jittypes.h +++ b/compiler/env/jittypes.h @@ -139,12 +139,12 @@ typedef struct TR_InlinedCallSite #define FLUSH_MEMORY(smp) #endif #else - #if defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__) + #if defined(__IBMC__) || defined(__IBMCPP__) #if defined(__cplusplus) #include #endif /* __cplusplus */ #define FLUSH_MEMORY(smp) if( smp ) __lwsync(); - #elif defined(LINUX) + #elif defined(LINUX) || defined(__open_xl__) #define FLUSH_MEMORY(smp) if( smp ) __asm__("lwsync"); #endif #endif diff --git a/compiler/ras/CallStack.cpp b/compiler/ras/CallStack.cpp index 537c38d3ed0..dae0966be42 100644 --- a/compiler/ras/CallStack.cpp +++ b/compiler/ras/CallStack.cpp @@ -61,14 +61,23 @@ void TR_CallStackIterator::printStackBacktrace(TR::Compilation *comp) } \ while (0) - -#define GET_CURR_TOS(dst) \ - do \ - { \ - /*copy current stack pointer to dst*/ \ - asm("la %0, 0(r1)" : "=r" (dst)); \ - } \ - while (0) +#if defined(__open_xl__) + #define GET_CURR_TOS(dst) \ + do \ + { \ + /*copy current stack pointer to dst*/ \ + asm("la %0, 0(1)" : "=r" (dst)); \ + } \ + while (0) +#else + #define GET_CURR_TOS(dst) \ + do \ + { \ + /*copy current stack pointer to dst*/ \ + asm("la %0, 0(r1)" : "=r" (dst)); \ + } \ + while (0) +#endif void TR_PPCCallStackIterator::_set_tb_table() { diff --git a/compiler/ras/DebugCounter.cpp b/compiler/ras/DebugCounter.cpp index d52ed978bba..326a6d857c6 100644 --- a/compiler/ras/DebugCounter.cpp +++ b/compiler/ras/DebugCounter.cpp @@ -497,7 +497,11 @@ TR::DebugCounter *TR::DebugCounterGroup::findCounter(const char *nameChars, int3 { if (nameChars == NULL) return NULL; - char *name = (char*)alloca(nameLength+1); + #if defined(__open_xl__) + char *name = (char*)__builtin_alloca(nameLength+1); + #else + char *name = (char*)alloca(nameLength+1); + #endif strncpy(name, nameChars, nameLength); name[nameLength] = 0; @@ -513,7 +517,11 @@ TR::DebugCounterAggregation *TR::DebugCounterGroup::findAggregation(const char * { if (nameChars == NULL) return NULL; - char *name = (char*)alloca(nameLength+1); + #if defined(__open_xl__) + char *name = (char*)__builtin_alloca(nameLength+1); + #else + char *name = (char*)alloca(nameLength+1); + #endif strncpy(name, nameChars, nameLength); name[nameLength] = 0; diff --git a/configure b/configure index 84ba6a7d44d..4c23f6cb878 100755 --- a/configure +++ b/configure @@ -3764,16 +3764,29 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; return 0; } _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg +if [ "$OMR_ENV_OPENXL" == "1" ]; then + for ac_arg in '' -std=extc89 -std=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" + do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg + fi + rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break + done +else + for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" + do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg + fi + rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break + done fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done rm -f conftest.$ac_ext CC=$ac_save_CC diff --git a/omrmakefiles/rules.aix.mk b/omrmakefiles/rules.aix.mk index 2d511df4ee4..7e649b7286d 100644 --- a/omrmakefiles/rules.aix.mk +++ b/omrmakefiles/rules.aix.mk @@ -28,11 +28,19 @@ ranlib $@ endef ifeq ($(OMR_ENV_DATA64),1) - GLOBAL_ARFLAGS += -X64 - GLOBAL_CFLAGS += -s -q64 - GLOBAL_CXXFLAGS += -s -q64 - GLOBAL_ASFLAGS += -a64 -many - GLOBAL_CPPFLAGS += -DPPC64 + ifeq ($(OMR_ENV_OPENXL),1) + GLOBAL_ARFLAGS += -X64 + GLOBAL_CFLAGS += -s -m64 + GLOBAL_CXXFLAGS += -s -m64 + GLOBAL_ASFLAGS += -a64 -many + GLOBAL_CPPFLAGS += -DPPC64 + else + GLOBAL_ARFLAGS += -X64 + GLOBAL_CFLAGS += -s -q64 + GLOBAL_CXXFLAGS += -s -q64 + GLOBAL_ASFLAGS += -a64 -many + GLOBAL_CPPFLAGS += -DPPC64 + endif else GLOBAL_ARFLAGS += -X32 GLOBAL_CXXFLAGS += -s -q32 @@ -40,21 +48,37 @@ else GLOBAL_ASFLAGS += -a32 -mppc endif -GLOBAL_CFLAGS += -qarch=ppc -qalias=noansi -qxflag=LTOL:LTOL0 -qsuppress=1506-1108 -GLOBAL_CXXFLAGS+=-qlanglvl=extended0x -qarch=ppc -qalias=noansi -qxflag=LTOL:LTOL0 -qsuppress=1506-1108 +ifeq ($(OMR_ENV_OPENXL),1) + GLOBAL_CFLAGS += -qarch=ppc -fno-strict-aliasing + GLOBAL_CXXFLAGS+=-std=c++11 -qarch=ppc -fno-strict-aliasing +else + GLOBAL_CFLAGS += -qarch=ppc -qalias=noansi -qxflag=LTOL:LTOL0 -qsuppress=1506-1108 + GLOBAL_CXXFLAGS+=-qlanglvl=extended0x -qarch=ppc -qalias=noansi -qxflag=LTOL:LTOL0 -qsuppress=1506-1108 +endif GLOBAL_CPPFLAGS+=-D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE -DRS6000 -DAIXPPC -D_LARGE_FILES ifeq (,$(findstring xlclang,$(notdir $(CC)))) - # xlc options - GLOBAL_CFLAGS+=-q mbcs -qlanglvl=extended -qinfo=pro + ifeq ($(OMR_ENV_OPENXL),1) + # openxl options + GLOBAL_CFLAGS+=-q mbcs -std=c89 -qinfo=pro + GLOBAL_CFLAGS+=-std=c++11 + else + # xlc options + GLOBAL_CFLAGS+=-q mbcs -qlanglvl=extended -qinfo=pro + endif else # xlclang options GLOBAL_CFLAGS+=-qlanglvl=extended0x -qxlcompatmacros endif ifeq (,$(findstring xlclang++,$(notdir $(CXX)))) - # xlc++ options - GLOBAL_CXXFLAGS+=-q mbcs -qinfo=pro + ifeq ($(OMR_ENV_OPENXL),1) + # openxl options + GLOBAL_CXXFLAGS+=-fno-exceptions + else + # xlc++ options + GLOBAL_CXXFLAGS+=-q mbcs -qinfo=pro + endif else # xlclang++ options GLOBAL_CXXFLAGS+=-qxlcompatmacros -fno-exceptions @@ -90,7 +114,11 @@ endif ### ifneq (,$(findstring executable,$(ARTIFACT_TYPE))) ifeq (1,$(OMR_ENV_DATA64)) - GLOBAL_LDFLAGS+=-q64 + ifeq ($(OMR_ENV_OPENXL),1) + GLOBAL_LDFLAGS+=-m64 + else + GLOBAL_LDFLAGS+=-q64 + endif else GLOBAL_LDFLAGS+=-q32 endif @@ -175,8 +203,10 @@ endif ## Warnings as errors ifeq ($(OMR_WARNINGS_AS_ERRORS),1) - GLOBAL_CFLAGS+=-qhalt=w - GLOBAL_CXXFLAGS+=-qhalt=w + ifneq ($(OMR_ENV_OPENXL),1) + GLOBAL_CFLAGS+=-qhalt=w + GLOBAL_CXXFLAGS+=-qhalt=w + endif endif ## Debug Information diff --git a/port/unix/omrsignal.c b/port/unix/omrsignal.c index 544df5f4bd8..930c9f1cb52 100644 --- a/port/unix/omrsignal.c +++ b/port/unix/omrsignal.c @@ -406,15 +406,17 @@ omrsig_protect(struct OMRPortLibrary *portLibrary, omrsig_protected_fn fn, void */ OMRCurrentSignal *currentSignal = omrthread_tls_get(thisThread, tlsKeyCurrentSignal); - /* setjmp/longjmp does not clear the mask setup by the OS when it delivers the signal. User sigsetjmp/siglongjmp(buf, 1) instead */ - if (0 != sigsetjmp(thisRecord.returnBuf, 1)) { - /* the handler had long jumped back here -- reset the signal handler stack and currentSignal and return */ - omrthread_tls_set(thisThread, tlsKey, thisRecord.previous); - omrthread_tls_set(thisThread, tlsKeyCurrentSignal, currentSignal); - *result = 0; - Trc_PRT_signal_omrsignal_sig_protect_Exit_long_jumped_back_to_omrsig_protect(fn, fn_arg, handler, handler_arg, flags); - return OMRPORT_SIG_EXCEPTION_OCCURRED; - } + #if !defined(__open_xl__) + /* setjmp/longjmp does not clear the mask setup by the OS when it delivers the signal. User sigsetjmp/siglongjmp(buf, 1) instead */ + if (0 != sigsetjmp(thisRecord.returnBuf, 1)) { + /* the handler had long jumped back here -- reset the signal handler stack and currentSignal and return */ + omrthread_tls_set(thisThread, tlsKey, thisRecord.previous); + omrthread_tls_set(thisThread, tlsKeyCurrentSignal, currentSignal); + *result = 0; + Trc_PRT_signal_omrsignal_sig_protect_Exit_long_jumped_back_to_omrsig_protect(fn, fn_arg, handler, handler_arg, flags); + return OMRPORT_SIG_EXCEPTION_OCCURRED; + } + #endif } if (0 != omrthread_tls_set(thisThread, tlsKey, &thisRecord)) { diff --git a/tools/configure b/tools/configure index 6d1ea9ec22a..e6741b8ca5f 100755 --- a/tools/configure +++ b/tools/configure @@ -3061,16 +3061,29 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; return 0; } _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg +if [ "$OMR_ENV_OPENXL" == "1" ]; then + for ac_arg in '' -std=extc89 -std=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" + do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg + fi + rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break + done +else + for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" + do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg + fi + rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break + done fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done rm -f conftest.$ac_ext CC=$ac_save_CC diff --git a/util/omrutil/gettimebase.c b/util/omrutil/gettimebase.c index 795629645f3..b37e5c8357b 100644 --- a/util/omrutil/gettimebase.c +++ b/util/omrutil/gettimebase.c @@ -53,8 +53,12 @@ getTimebase(void) /* PPC64 & XLC */ tsc = __mftb(); #else /* !XLC */ - /* PPC64 & !XLC */ - asm volatile("mftb %0" : "=r" (tsc)); + #if defined(__open_xl__) + __asm__ volatile("mftb %0" : "=r" (tsc)); + #else + /* PPC64 & !XLC & !OPENXL*/ + asm volatile("mftb %0" : "=r" (tsc)); + #endif /* __open_xl__ */ #endif /* __xlC__ */ #else /* !OMR_ENV_DATA64 */