From 1e8f62e21e2a43d4eab54fc5b10b5d22bc37197c 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 | 40 ++++++++++++---- compiler/env/jittypes.h | 4 +- compiler/ras/CallStack.cpp | 25 ++++++---- compiler/ras/DebugCounter.cpp | 12 ++++- configure | 31 ++++++++---- omrmakefiles/rules.aix.mk | 61 ++++++++++++++++++------ port/unix/omrsignal.c | 22 ++++----- tools/configure | 31 ++++++++---- util/omrutil/gettimebase.c | 8 +++- 10 files changed, 172 insertions(+), 68 deletions(-) diff --git a/cmake/modules/OmrMetalC.cmake b/cmake/modules/OmrMetalC.cmake index 232e66728a7..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 "-m64") + 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 5a85ffb15e6..cc2685d3e3c 100644 --- a/cmake/modules/platform/toolcfg/gnu.cmake +++ b/cmake/modules/platform/toolcfg/gnu.cmake @@ -19,6 +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 ############################################################################# +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) @@ -64,7 +69,7 @@ if(OMR_HOST_ARCH STREQUAL "s390") list(APPEND OMR_PLATFORM_COMPILE_OPTIONS -march=z9-109) endif() -if(OMR_OS_AIX) +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") @@ -119,15 +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}" - COMMAND "${CMAKE_COMMAND}" -E copy ${exe_file} ${dbg_file} - COMMAND "${CMAKE_STRIP}" -X32_64 ${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() @@ -151,4 +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 3546b01b346..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(); - #else + #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 e15f7aac559..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(1)" : "=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 3522b6e42bc..537170dd9ea 100644 --- a/compiler/ras/DebugCounter.cpp +++ b/compiler/ras/DebugCounter.cpp @@ -466,7 +466,11 @@ TR::DebugCounter *TR::DebugCounterGroup::findCounter(const char *nameChars, int3 { if (nameChars == NULL) return NULL; - char *name = (char*)__builtin_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; @@ -482,7 +486,11 @@ TR::DebugCounterAggregation *TR::DebugCounterGroup::findAggregation(const char * { if (nameChars == NULL) return NULL; - char *name = (char*)__builtin_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 efec24020dc..b9626e557f5 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 '' -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 +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 c04a63d2780..af2d697b3e1 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 -m64 - GLOBAL_CXXFLAGS += -s -m64 - 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,24 +48,41 @@ else GLOBAL_ASFLAGS += -a32 -mppc endif -GLOBAL_CFLAGS += -qarch=ppc -fno-strict-aliasing -GLOBAL_CXXFLAGS+=-std=c++11 -qarch=ppc -fno-strict-aliasing +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 -std=c89 -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+=-std=c++11 + 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+=-fno-exceptions + GLOBAL_CXXFLAGS+=-qxlcompatmacros -fno-exceptions + # GLOBAL_CXXFLAGS+=-fno-exceptions ifeq (0,$(OMR_RTTI)) GLOBAL_CXXFLAGS+=-fno-rtti endif @@ -90,7 +115,11 @@ endif ### ifneq (,$(findstring executable,$(ARTIFACT_TYPE))) ifeq (1,$(OMR_ENV_DATA64)) - GLOBAL_LDFLAGS+=-m64 + ifeq ($(OMR_ENV_OPENXL),1) + GLOBAL_LDFLAGS+=-m64 + else + GLOBAL_LDFLAGS+=-q64 + endif else GLOBAL_LDFLAGS+=-q32 endif @@ -175,6 +204,10 @@ endif ## Warnings as errors ifeq ($(OMR_WARNINGS_AS_ERRORS),1) + 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 f0abd4a8ae4..930c9f1cb52 100644 --- a/port/unix/omrsignal.c +++ b/port/unix/omrsignal.c @@ -406,17 +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 a1b5401a758..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 '' -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 +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 8b94e921c4b..2c8fc82b165 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 */