Skip to content

Commit

Permalink
Merge pull request #7561 from midronij/openxl-final
Browse files Browse the repository at this point in the history
Modifications to ensure compatibility with OpenXL and xlC on AIX
  • Loading branch information
jdmpapin authored Dec 16, 2024
2 parents 7af9de5 + 62621c9 commit 470ed10
Show file tree
Hide file tree
Showing 29 changed files with 202 additions and 87 deletions.
11 changes: 11 additions & 0 deletions cmake/modules/OmrDetectSystemInformation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ macro(omr_detect_system_information)
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
# clang on Windows mimics MSVC
set(_OMR_TOOLCONFIG "msvc")
elseif(CMAKE_C_COMPILER_ID MATCHES "^Clang$")
# OpenXL17 uses CMAKE_C_COMPILER_ID "Clang"
set(_OMR_TOOLCONFIG "gnu")
set(CMAKE_C_COMPILER_IS_OPENXL TRUE CACHE BOOL "OpenXL is the C compiler")
if(CMAKE_C_COMPILER_IS_OPENXL)
set(OMR_ENV_OPENXL 1)
set(ENV{OMR_ENV_OPENXL} ${OMR_ENV_OPENXL})
else()
set(OMR_ENV_OPENXL 0)
set(ENV{OMR_ENV_OPENXL} ${OMR_ENV_OPENXL})
endif()
else()
# TODO we don't actually have a clang config
# just use GNU config
Expand Down
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 "-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}")
Expand Down
48 changes: 38 additions & 10 deletions cmake/modules/platform/toolcfg/gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
# 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)
# disable warnings as errors for OpenXL
# (see https://github.com/eclipse-omr/omr/issues/7583)
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)
Expand Down Expand Up @@ -68,6 +72,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 "<CMAKE_AR> -X64 cr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -X64 cr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -X64 <TARGET>")
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.

Expand Down Expand Up @@ -110,13 +127,22 @@ 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_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 @@ -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()
2 changes: 1 addition & 1 deletion compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2909,7 +2909,7 @@ OMR::CodeGenerator::shutdown(TR_FrontEnd *fe, TR::FILE *logFile)
#endif


#if !(defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__)))
#if !(defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__)))

int32_t leadingZeroes (int32_t inputWord)
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/compile/OSRData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ bool TR_OSRCompilationData::TR_ScratchBufferInfo::operator==(const TR_ScratchBuf

#if (defined(TR_HOST_POWER) && defined(TR_TARGET_POWER) \
|| defined(TR_HOST_S390) && defined(TR_TARGET_S390)) \
&& defined(__IBMCPP__)
&& (defined(__IBMCPP__) || defined(__open_xl__))
__attribute__((__noinline__))
//This tiny function when inlined by xlC 12 or later at -O3 breaks java -version
//on Power and causes intermittent crashes on z/OS with xlC 2.1.1
Expand Down
2 changes: 1 addition & 1 deletion compiler/control/OptimizationPlan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace TR { class Recompilation; }
namespace TR { class Monitor; }
struct TR_MethodToBeCompiled;

#if defined(__IBMCPP__)
#if defined(__IBMCPP__) || defined(__open_xl__)
// GCC (and other compilers) may assume that operator new cannot return null
// unless a nothrow specification is provided. For other reasons, we build
// Testarossa with -qnoeh / -fnoeh to disable exceptions. This is all fine,
Expand Down
4 changes: 2 additions & 2 deletions compiler/cs2/bitmanip.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef CSBITMANIP_H
#define CSBITMANIP_H

#if defined(__IBMCPP__) && defined (__PPC__)
#if (defined(__IBMCPP__) || defined(__open_xl__)) && defined (__PPC__)
// to __cntlz4 and related routines
# include "builtins.h"
#endif
Expand Down Expand Up @@ -130,7 +130,7 @@ inline
return uint32_t(u64);
}

#if (defined(__IBMCPP__) || defined(__ibmxl__)) && defined (__PPC__)
#if (defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__)) && defined (__PPC__)
inline uint32_t BitManipulator::LeadingZeroes (uint32_t inputWord) {
return __cntlz4 (inputWord);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/env/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
/* Compiler macros */
#if defined(__GNUC__)
# define HOST_COMPILER COMPILER_GCC
#elif defined(__IBMC__) || defined(__IBMCPP__)
#elif defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__)
# define HOST_COMPILER COMPILER_XLC
#elif defined(_MSC_VER)
# define HOST_COMPILER COMPILER_MSVC
Expand Down
2 changes: 1 addition & 1 deletion compiler/env/jittypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ typedef struct TR_InlinedCallSite
#include <builtins.h>
#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
Expand Down
2 changes: 1 addition & 1 deletion compiler/infra/Annotations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#define OMR_NORETURN _declspec(noreturn)
#elif defined(__GNUC__)
#define OMR_NORETURN __attribute__ ((noreturn))
#elif defined(__IBMCPP__)
#elif defined(__IBMCPP__) || defined(__open_xl__)
#define OMR_NORETURN __attribute__ ((noreturn))
#else
#warning "Noreturn attribute undefined for this platform."
Expand Down
2 changes: 1 addition & 1 deletion compiler/infra/Bit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static inline bool contiguousBits(uint64_t lmask)
return contiguousBits((int64_t) lmask);
}

#if defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__))
#if defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__))
#include <builtins.h>

// Return a count 0..32 of leading zeroes in the given word
Expand Down
2 changes: 1 addition & 1 deletion compiler/optimizer/OMRRegisterCandidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ static void assign_candidate_loop_trace_increment(TR::Compilation *comp, TR::Reg
bool
OMR::RegisterCandidates::assign(TR::Block ** cfgBlocks, int32_t numberOfBlocks, int32_t & lowestNumber, int32_t & highestNumber)
{
#if (defined(__IBMCPP__) || defined(__IBMC__)) && !defined(__ibmxl__)
#if (defined(__IBMCPP__) || defined(__IBMC__)) && !(defined(__ibmxl__) || defined(__open_xl__))
// __func__ is not defined for this function on XLC compilers (Notably XLC on Linux PPC and ZOS)
static const char __func__[] = "OMR::RegisterCandidates::assign";
#endif
Expand Down
13 changes: 7 additions & 6 deletions compiler/p/codegen/PPCTableOfConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,13 @@ int32_t TR_PPCTableOfConstants::lookUp(TR::SymbolReference *symRef, TR::CodeGene
}

TR::StaticSymbol *sym = symRef->getSymbol()->castToStaticSymbol();
intptr_t addr = (intptr_t)sym->getStaticAddress();
int32_t nlen, tindex;
int8_t local_buffer[1024];
int8_t *name = local_buffer;
bool isAddr = false;
intptr_t myTag;
intptr_t addr = (intptr_t)sym->getStaticAddress();
int32_t nlen = 0;
int32_t tindex = 0;
int8_t local_buffer[1024];
int8_t *name = local_buffer;
bool isAddr = false;
intptr_t myTag = 0;

if (!symRef->isUnresolved() || symRef->getCPIndex()<0 || sym->isAddressOfClassObject() || sym->isConstObjectRef() || sym->isConst())
{
Expand Down
6 changes: 3 additions & 3 deletions compiler/p/runtime/PPCCodeSync.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
extern "C" void *getCodeSync();

#if defined(TR_HOST_POWER)
#if defined(__IBMC__) || defined(__IBMCPP__)
#if defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__)

#if defined(__cplusplus)
#include <builtins.h>
Expand All @@ -35,7 +35,7 @@ extern "C" void *getCodeSync();
#define sync() __sync()
#define isync() __isync()

#else /* defined(__IBMC__) || defined(__IBMCPP__) */
#else /* defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__) */

static inline void dcbf(unsigned char *addr)
{
Expand All @@ -55,7 +55,7 @@ static inline void isync()
__asm__("isync");
}

#endif /* defined(__IBMC__) || defined(__IBMCPP__) */
#endif /* defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__) */

static inline void icbi(unsigned char *addr)
{
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(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 /* defined(__open_xl__) */
#define GET_CURR_TOS(dst) \
do \
{ \
/*copy current stack pointer to dst*/ \
asm("la %0, 0(r1)" : "=r" (dst)); \
} \
while (0)
#endif /* defined(__open_xl__) */

void TR_PPCCallStackIterator::_set_tb_table()
{
Expand Down
10 changes: 9 additions & 1 deletion compiler/ras/DebugCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,11 @@ TR::DebugCounter *TR::DebugCounterGroup::findCounter(const char *nameChars, int3
{
if (nameChars == NULL)
return NULL;
#if defined(__open_xl__)
char *name = (char*)__builtin_alloca(nameLength+1);
#else /* defined(__open_xl__) */
char *name = (char*)alloca(nameLength+1);
#endif /* defined(__open_xl__) */
strncpy(name, nameChars, nameLength);
name[nameLength] = 0;

Expand All @@ -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 /* defined(__open_xl__) */
char *name = (char*)alloca(nameLength+1);
#endif /* defined(__open_xl__) */
strncpy(name, nameChars, nameLength);
name[nameLength] = 0;

Expand Down
2 changes: 1 addition & 1 deletion compiler/runtime/OMRRuntimeAssumptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "runtime/OMRRuntimeAssumptions.hpp"
#include "env/jittypes.h"

#if defined(__IBMCPP__) && !defined(AIXPPC) && !defined(LINUXPPC)
#if (defined(__IBMCPP__) || defined(__open_xl__)) && !defined(AIXPPC) && !defined(LINUXPPC)
#define ASM_CALL __cdecl
#else
#define ASM_CALL
Expand Down
2 changes: 1 addition & 1 deletion compiler/runtime/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

TR_RuntimeHelperTable runtimeHelpers;

#if (defined(__IBMCPP__) || defined(__IBMC__) && !defined(MVS)) && !defined(LINUXPPC64)
#if (defined(__IBMCPP__) || (defined(__IBMC__) && !defined(__MVS__)) || defined(__open_xl__)) && !defined(LINUXPPC64)
#if defined(AIXPPC)
#define JIT_HELPER(x) extern "C" void *x
#else
Expand Down
2 changes: 1 addition & 1 deletion compiler/z/codegen/S390Evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ template <uint32_t numberOfBits>
TR::Register * genericLoad(TR::Node * node, TR::CodeGenerator * cg, TR::MemoryReference * tempMR, TR::Register * srcRegister);

template <uint32_t numberOfBits, uint32_t numberOfExtendBits, enum LoadForm form>
#if defined(__IBMCPP__) || defined(__ibmxl__)
#if defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__)
inline
#endif
TR::Register * genericLoadHelper(TR::Node * node, TR::CodeGenerator * cg, TR::MemoryReference * tempMR, TR::Register * srcRegister, bool isSourceSigned, bool couldIgnoreExtend);
Expand Down
24 changes: 16 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3764,16 +3764,24 @@ 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 [[ "$CC" =~ 'ibm-clang' ]]; then
options="-std=extc89 -std=ansi"
else
options="-qlanglvl=extc89 -qlanglvl=ansi"
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c89" != "xno" && break

for ac_arg in '' "$options" -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

rm -f conftest.$ac_ext
CC=$ac_save_CC

Expand Down
8 changes: 4 additions & 4 deletions include_core/AtomicSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <tpf/cmpswp.h>
#endif

#if defined(__xlC__) && defined(AIXPPC)
#if (defined(__xlC__) || defined(__open_xl__)) && defined(AIXPPC)
#include <sys/atomic_op.h>
#endif

Expand Down Expand Up @@ -184,7 +184,7 @@ class VM_AtomicSupport
_ReadWriteBarrier();
#elif defined(J9ZOS390) /* _MSC_VER */
__fence();
#elif defined(__xlC__) /* J9ZOS390 */
#elif defined(__xlC__) || defined(__open_xl__) /* J9ZOS390 */
asm volatile("");
#else /* __xlC__ */
#error Unknown compiler
Expand Down Expand Up @@ -352,7 +352,7 @@ class VM_AtomicSupport
#if defined(OMRZTPF)
cs((cs_t *)&oldValue, (cs_t *)address, (cs_t)newValue);
return oldValue;
#elif defined(__xlC__) /* defined(OMRZTPF) */
#elif defined(__xlC__) || defined(__open_xl__) /* defined(OMRZTPF) */
__compare_and_swap((volatile int*)address, (int*)&oldValue, (int)newValue);
return oldValue;
#elif defined(__GNUC__) /* defined(__xlC__) */
Expand Down Expand Up @@ -418,7 +418,7 @@ class VM_AtomicSupport
#elif defined(OMRZTPF) /* defined(OMR_ARCH_POWER) && !defined(OMR_ENV_DATA64) */
csg((csg_t *)&oldValue, (csg_t *)address, (csg_t)newValue);
return oldValue;
#elif defined(__xlC__) /* defined(OMRZTPF) */
#elif defined(__xlC__)|| defined(__open_xl__) /* defined(OMRZTPF) */
#if defined(__64BIT__) || !defined(AIXPPC)
__compare_and_swaplp((volatile long*)address, (long*)&oldValue, (long)newValue);
#else /* defined(__64BIT__) */
Expand Down
Loading

0 comments on commit 470ed10

Please sign in to comment.