Skip to content

Commit

Permalink
Add macro to openxl specific changes
Browse files Browse the repository at this point in the history
Signed-off-by: Ishita Ray <ishita.ray@ibm.com>
  • Loading branch information
ishitaR88 committed Sep 30, 2024
1 parent bd7eee1 commit dfa188b
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 68 deletions.
6 changes: 5 additions & 1 deletion cmake/modules/OmrMetalC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
40 changes: 30 additions & 10 deletions cmake/modules/platform/toolcfg/gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -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()
4 changes: 2 additions & 2 deletions compiler/env/jittypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <builtins.h>
#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
Expand Down
25 changes: 17 additions & 8 deletions compiler/ras/CallStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
12 changes: 10 additions & 2 deletions compiler/ras/DebugCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
31 changes: 22 additions & 9 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 47 additions & 14 deletions omrmakefiles/rules.aix.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,61 @@ 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
GLOBAL_CFLAGS += -s -q32
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions port/unix/omrsignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
31 changes: 22 additions & 9 deletions tools/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions util/omrutil/gettimebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit dfa188b

Please sign in to comment.