Skip to content

Commit 05a808c

Browse files
committed
Modifications for OpenXL Compatibility on AIX
To ensure that OMR can be built on AIX with both OpenXL and xlC, make modifications to compiler flags, macros, and linked libraries. Signed-off-by: midronij <[email protected]>
1 parent 8ff3b35 commit 05a808c

28 files changed

+195
-81
lines changed

cmake/modules/OmrDetectSystemInformation.cmake

+11
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ macro(omr_detect_system_information)
193193
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
194194
# clang on Windows mimics MSVC
195195
set(_OMR_TOOLCONFIG "msvc")
196+
elseif(CMAKE_C_COMPILER_ID MATCHES "^Clang$")
197+
# OpenXL17 uses CMAKE_C_COMPILER_ID "Clang"
198+
set(_OMR_TOOLCONFIG "gnu")
199+
set(CMAKE_C_COMPILER_IS_OPENXL TRUE CACHE BOOL "OpenXL is the C compiler")
200+
if(CMAKE_C_COMPILER_IS_OPENXL)
201+
set(OMR_ENV_OPENXL 1)
202+
set(ENV{OMR_ENV_OPENXL} ${OMR_ENV_OPENXL})
203+
else()
204+
set(OMR_ENV_OPENXL 0)
205+
set(ENV{OMR_ENV_OPENXL} ${OMR_ENV_OPENXL})
206+
endif()
196207
else()
197208
# TODO we don't actually have a clang config
198209
# just use GNU config

cmake/modules/OmrMetalC.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ function(omr_compile_metalc mfile ofile)
5858
omr_assert(TEST AS_EXECUTABLE)
5959

6060
if(OMR_ENV_DATA64)
61-
list(APPEND OMR_METALC_XLC_FLAGS "-q64")
61+
if(CMAKE_C_COMPILER_IS_OPENXL)
62+
list(APPEND OMR_METALC_XLC_FLAGS "-m64")
63+
else()
64+
list(APPEND OMR_METALC_XLC_FLAGS "-q64")
65+
endif()
6266
endif()
6367

6468
if(NOT IS_ABSOLUTE "${mfile}")

cmake/modules/platform/toolcfg/gnu.cmake

+38-10
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
# 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
2020
#############################################################################
2121

22-
set(OMR_C_WARNINGS_AS_ERROR_FLAG -Werror)
23-
set(OMR_CXX_WARNINGS_AS_ERROR_FLAG -Werror)
24-
set(OMR_NASM_WARNINGS_AS_ERROR_FLAG -Werror)
22+
# disable warnings as errors for OpenXL
23+
# (see https://github.com/eclipse-omr/omr/issues/7583)
24+
if(NOT CMAKE_C_COMPILER_IS_OPENXL)
25+
set(OMR_C_WARNINGS_AS_ERROR_FLAG -Werror)
26+
set(OMR_CXX_WARNINGS_AS_ERROR_FLAG -Werror)
27+
set(OMR_NASM_WARNINGS_AS_ERROR_FLAG -Werror)
28+
endif()
2529

2630
set(OMR_C_ENHANCED_WARNINGS_FLAG -Wall)
2731
set(OMR_CXX_ENHANCED_WARNINGS_FLAG -Wall)
@@ -68,6 +72,19 @@ if(OMR_HOST_ARCH STREQUAL "s390")
6872
list(APPEND OMR_PLATFORM_COMPILE_OPTIONS -march=z9-109)
6973
endif()
7074

75+
if(OMR_OS_AIX AND CMAKE_C_COMPILER_IS_OPENXL)
76+
omr_append_flags(CMAKE_C_FLAGS "-m64")
77+
omr_append_flags(CMAKE_CXX_FLAGS "-m64")
78+
omr_append_flags(CMAKE_ASM_FLAGS "-m64")
79+
omr_append_flags(CMAKE_SHARED_LINKER_FLAGS "-m64")
80+
81+
if(OMR_ENV_DATA64)
82+
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -X64 cr <TARGET> <LINK_FLAGS> <OBJECTS>")
83+
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -X64 cr <TARGET> <LINK_FLAGS> <OBJECTS>")
84+
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -X64 <TARGET>")
85+
endif()
86+
endif()
87+
7188
# Testarossa build variables. Longer term the distinction between TR and the rest
7289
# of the OMR code should be heavily reduced. In the meantime, we keep the distinction.
7390

@@ -110,13 +127,22 @@ function(_omr_toolchain_separate_debug_symbols tgt)
110127
else()
111128
omr_get_target_output_genex(${tgt} output_name)
112129
set(dbg_file "${output_name}${OMR_DEBUG_INFO_OUTPUT_EXTENSION}")
113-
add_custom_command(
114-
TARGET "${tgt}"
115-
POST_BUILD
116-
COMMAND "${CMAKE_OBJCOPY}" --only-keep-debug "${exe_file}" "${dbg_file}"
117-
COMMAND "${CMAKE_OBJCOPY}" --strip-debug "${exe_file}"
118-
COMMAND "${CMAKE_OBJCOPY}" --add-gnu-debuglink="${dbg_file}" "${exe_file}"
119-
)
130+
if(OMR_OS_AIX AND CMAKE_C_COMPILER_IS_OPENXL)
131+
add_custom_command(
132+
TARGET "${tgt}"
133+
POST_BUILD
134+
COMMAND "${CMAKE_COMMAND}" -E copy ${exe_file} ${dbg_file}
135+
COMMAND "${CMAKE_STRIP}" -X32_64 ${exe_file}
136+
)
137+
else()
138+
add_custom_command(
139+
TARGET "${tgt}"
140+
POST_BUILD
141+
COMMAND "${CMAKE_OBJCOPY}" --only-keep-debug "${exe_file}" "${dbg_file}"
142+
COMMAND "${CMAKE_OBJCOPY}" --strip-debug "${exe_file}"
143+
COMMAND "${CMAKE_OBJCOPY}" --add-gnu-debuglink="${dbg_file}" "${exe_file}"
144+
)
145+
endif()
120146
endif()
121147
set_target_properties(${tgt} PROPERTIES OMR_DEBUG_FILE "${dbg_file}")
122148
endfunction()
@@ -140,7 +166,9 @@ function(_omr_toolchain_process_exports TARGET_NAME)
140166
"${exp_file}"
141167
)
142168

169+
if(NOT CMAKE_C_COMPILER_IS_OPENXL)
143170
target_link_libraries(${TARGET_NAME}
144171
PRIVATE
145172
"-Wl,--version-script,${exp_file}")
173+
endif()
146174
endfunction()

compiler/codegen/OMRCodeGenerator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,7 @@ OMR::CodeGenerator::shutdown(TR_FrontEnd *fe, TR::FILE *logFile)
29092909
#endif
29102910

29112911

2912-
#if !(defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__)))
2912+
#if !(defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__)))
29132913

29142914
int32_t leadingZeroes (int32_t inputWord)
29152915
{

compiler/compile/OSRData.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ bool TR_OSRCompilationData::TR_ScratchBufferInfo::operator==(const TR_ScratchBuf
15151515

15161516
#if (defined(TR_HOST_POWER) && defined(TR_TARGET_POWER) \
15171517
|| defined(TR_HOST_S390) && defined(TR_TARGET_S390)) \
1518-
&& defined(__IBMCPP__)
1518+
&& (defined(__IBMCPP__) || defined(__open_xl__))
15191519
__attribute__((__noinline__))
15201520
//This tiny function when inlined by xlC 12 or later at -O3 breaks java -version
15211521
//on Power and causes intermittent crashes on z/OS with xlC 2.1.1

compiler/control/OptimizationPlan.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace TR { class Recompilation; }
3939
namespace TR { class Monitor; }
4040
struct TR_MethodToBeCompiled;
4141

42-
#if defined(__IBMCPP__)
42+
#if defined(__IBMCPP__) || defined(__open_xl__)
4343
// GCC (and other compilers) may assume that operator new cannot return null
4444
// unless a nothrow specification is provided. For other reasons, we build
4545
// Testarossa with -qnoeh / -fnoeh to disable exceptions. This is all fine,

compiler/cs2/bitmanip.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#ifndef CSBITMANIP_H
3030
#define CSBITMANIP_H
3131

32-
#if defined(__IBMCPP__) && defined (__PPC__)
32+
#if (defined(__IBMCPP__) || defined(__open_xl__)) && defined (__PPC__)
3333
// to __cntlz4 and related routines
3434
# include "builtins.h"
3535
#endif
@@ -130,7 +130,7 @@ inline
130130
return uint32_t(u64);
131131
}
132132

133-
#if (defined(__IBMCPP__) || defined(__ibmxl__)) && defined (__PPC__)
133+
#if (defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__)) && defined (__PPC__)
134134
inline uint32_t BitManipulator::LeadingZeroes (uint32_t inputWord) {
135135
return __cntlz4 (inputWord);
136136
}

compiler/env/defines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
/* Compiler macros */
166166
#if defined(__GNUC__)
167167
# define HOST_COMPILER COMPILER_GCC
168-
#elif defined(__IBMC__) || defined(__IBMCPP__)
168+
#elif defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__)
169169
# define HOST_COMPILER COMPILER_XLC
170170
#elif defined(_MSC_VER)
171171
# define HOST_COMPILER COMPILER_MSVC

compiler/env/jittypes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ typedef struct TR_InlinedCallSite
144144
#include <builtins.h>
145145
#endif /* __cplusplus */
146146
#define FLUSH_MEMORY(smp) if( smp ) __lwsync();
147-
#elif defined(LINUX)
147+
#elif defined(LINUX) || defined(__open_xl__)
148148
#define FLUSH_MEMORY(smp) if( smp ) __asm__("lwsync");
149149
#endif
150150
#endif

compiler/infra/Annotations.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#define OMR_NORETURN _declspec(noreturn)
6565
#elif defined(__GNUC__)
6666
#define OMR_NORETURN __attribute__ ((noreturn))
67-
#elif defined(__IBMCPP__)
67+
#elif defined(__IBMCPP__) || defined(__open_xl__)
6868
#define OMR_NORETURN __attribute__ ((noreturn))
6969
#else
7070
#warning "Noreturn attribute undefined for this platform."

compiler/infra/Bit.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static inline bool contiguousBits(uint64_t lmask)
9898
return contiguousBits((int64_t) lmask);
9999
}
100100

101-
#if defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__))
101+
#if defined(TR_HOST_POWER) && (defined(__IBMC__) || defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__))
102102
#include <builtins.h>
103103

104104
// Return a count 0..32 of leading zeroes in the given word

compiler/optimizer/OMRRegisterCandidate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ static void assign_candidate_loop_trace_increment(TR::Compilation *comp, TR::Reg
21372137
bool
21382138
OMR::RegisterCandidates::assign(TR::Block ** cfgBlocks, int32_t numberOfBlocks, int32_t & lowestNumber, int32_t & highestNumber)
21392139
{
2140-
#if (defined(__IBMCPP__) || defined(__IBMC__)) && !defined(__ibmxl__)
2140+
#if (defined(__IBMCPP__) || defined(__IBMC__)) && !(defined(__ibmxl__) || defined(__open_xl__))
21412141
// __func__ is not defined for this function on XLC compilers (Notably XLC on Linux PPC and ZOS)
21422142
static const char __func__[] = "OMR::RegisterCandidates::assign";
21432143
#endif

compiler/p/runtime/PPCCodeSync.inc

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
extern "C" void *getCodeSync();
2626

2727
#if defined(TR_HOST_POWER)
28-
#if defined(__IBMC__) || defined(__IBMCPP__)
28+
#if defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__)
2929

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

38-
#else /* defined(__IBMC__) || defined(__IBMCPP__) */
38+
#else /* defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__) */
3939

4040
static inline void dcbf(unsigned char *addr)
4141
{
@@ -55,7 +55,7 @@ static inline void isync()
5555
__asm__("isync");
5656
}
5757

58-
#endif /* defined(__IBMC__) || defined(__IBMCPP__) */
58+
#endif /* defined(__IBMC__) || defined(__IBMCPP__) || defined(__open_xl__) */
5959

6060
static inline void icbi(unsigned char *addr)
6161
{

compiler/ras/CallStack.cpp

+17-8
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,23 @@ void TR_CallStackIterator::printStackBacktrace(TR::Compilation *comp)
6161
} \
6262
while (0)
6363

64-
65-
#define GET_CURR_TOS(dst) \
66-
do \
67-
{ \
68-
/*copy current stack pointer to dst*/ \
69-
asm("la %0, 0(r1)" : "=r" (dst)); \
70-
} \
71-
while (0)
64+
#if defined(__open_xl__)
65+
#define GET_CURR_TOS(dst) \
66+
do \
67+
{ \
68+
/*copy current stack pointer to dst*/ \
69+
asm("la %0, 0(1)" : "=r" (dst)); \
70+
} \
71+
while (0)
72+
#else /* defined(__open_xl__) */
73+
#define GET_CURR_TOS(dst) \
74+
do \
75+
{ \
76+
/*copy current stack pointer to dst*/ \
77+
asm("la %0, 0(r1)" : "=r" (dst)); \
78+
} \
79+
while (0)
80+
#endif /* defined(__open_xl__) */
7281

7382
void TR_PPCCallStackIterator::_set_tb_table()
7483
{

compiler/ras/DebugCounter.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,11 @@ TR::DebugCounter *TR::DebugCounterGroup::findCounter(const char *nameChars, int3
497497
{
498498
if (nameChars == NULL)
499499
return NULL;
500+
#if defined(__open_xl__)
501+
char *name = (char*)__builtin_alloca(nameLength+1);
502+
#else /* defined(__open_xl__) */
500503
char *name = (char*)alloca(nameLength+1);
504+
#endif /* defined(__open_xl__) */
501505
strncpy(name, nameChars, nameLength);
502506
name[nameLength] = 0;
503507

@@ -513,7 +517,11 @@ TR::DebugCounterAggregation *TR::DebugCounterGroup::findAggregation(const char *
513517
{
514518
if (nameChars == NULL)
515519
return NULL;
516-
char *name = (char*)alloca(nameLength+1);
520+
#if defined(__open_xl__)
521+
char *name = (char*)__builtin_alloca(nameLength+1);
522+
#else /* defined(__open_xl__) */
523+
char *name = (char*)alloca(nameLength+1);
524+
#endif /* defined(__open_xl__) */
517525
strncpy(name, nameChars, nameLength);
518526
name[nameLength] = 0;
519527

compiler/runtime/OMRRuntimeAssumptions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "runtime/OMRRuntimeAssumptions.hpp"
2323
#include "env/jittypes.h"
2424

25-
#if defined(__IBMCPP__) && !defined(AIXPPC) && !defined(LINUXPPC)
25+
#if (defined(__IBMCPP__) || defined(__open_xl__)) && !defined(AIXPPC) && !defined(LINUXPPC)
2626
#define ASM_CALL __cdecl
2727
#else
2828
#define ASM_CALL

compiler/runtime/Runtime.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
TR_RuntimeHelperTable runtimeHelpers;
2525

26-
#if (defined(__IBMCPP__) || defined(__IBMC__) && !defined(MVS)) && !defined(LINUXPPC64)
26+
#if (defined(__IBMCPP__) || (defined(__IBMC__) && !defined(__MVS__)) || defined(__open_xl__)) && !defined(LINUXPPC64)
2727
#if defined(AIXPPC)
2828
#define JIT_HELPER(x) extern "C" void *x
2929
#else

compiler/z/codegen/S390Evaluator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ template <uint32_t numberOfBits>
154154
TR::Register * genericLoad(TR::Node * node, TR::CodeGenerator * cg, TR::MemoryReference * tempMR, TR::Register * srcRegister);
155155

156156
template <uint32_t numberOfBits, uint32_t numberOfExtendBits, enum LoadForm form>
157-
#if defined(__IBMCPP__) || defined(__ibmxl__)
157+
#if defined(__IBMCPP__) || defined(__ibmxl__) || defined(__open_xl__)
158158
inline
159159
#endif
160160
TR::Register * genericLoadHelper(TR::Node * node, TR::CodeGenerator * cg, TR::MemoryReference * tempMR, TR::Register * srcRegister, bool isSourceSigned, bool couldIgnoreExtend);

configure

+16-8
Original file line numberDiff line numberDiff line change
@@ -3764,16 +3764,24 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
37643764
return 0;
37653765
}
37663766
_ACEOF
3767-
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
3768-
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
3769-
do
3770-
CC="$ac_save_CC $ac_arg"
3771-
if ac_fn_c_try_compile "$LINENO"; then :
3772-
ac_cv_prog_cc_c89=$ac_arg
3767+
if [[ "$CC" =~ 'ibm-clang' ]]; then
3768+
options="-std=extc89 -std=ansi"
3769+
else
3770+
options="-qlanglvl=extc89 -qlanglvl=ansi"
37733771
fi
3774-
rm -f core conftest.err conftest.$ac_objext
3775-
test "x$ac_cv_prog_cc_c89" != "xno" && break
3772+
3773+
for ac_arg in '' "$options" -std \
3774+
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
3775+
3776+
do
3777+
CC="$ac_save_CC $ac_arg"
3778+
if ac_fn_c_try_compile "$LINENO"; then :
3779+
ac_cv_prog_cc_c89=$ac_arg
3780+
fi
3781+
rm -f core conftest.err conftest.$ac_objext
3782+
test "x$ac_cv_prog_cc_c89" != "xno" && break
37763783
done
3784+
37773785
rm -f conftest.$ac_ext
37783786
CC=$ac_save_CC
37793787

include_core/AtomicSupport.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <tpf/cmpswp.h>
3434
#endif
3535

36-
#if defined(__xlC__) && defined(AIXPPC)
36+
#if (defined(__xlC__) || defined(__open_xl__)) && defined(AIXPPC)
3737
#include <sys/atomic_op.h>
3838
#endif
3939

@@ -184,7 +184,7 @@ class VM_AtomicSupport
184184
_ReadWriteBarrier();
185185
#elif defined(J9ZOS390) /* _MSC_VER */
186186
__fence();
187-
#elif defined(__xlC__) /* J9ZOS390 */
187+
#elif defined(__xlC__) || defined(__open_xl__) /* J9ZOS390 */
188188
asm volatile("");
189189
#else /* __xlC__ */
190190
#error Unknown compiler
@@ -352,7 +352,7 @@ class VM_AtomicSupport
352352
#if defined(OMRZTPF)
353353
cs((cs_t *)&oldValue, (cs_t *)address, (cs_t)newValue);
354354
return oldValue;
355-
#elif defined(__xlC__) /* defined(OMRZTPF) */
355+
#elif defined(__xlC__) || defined(__open_xl__) /* defined(OMRZTPF) */
356356
__compare_and_swap((volatile int*)address, (int*)&oldValue, (int)newValue);
357357
return oldValue;
358358
#elif defined(__GNUC__) /* defined(__xlC__) */
@@ -418,7 +418,7 @@ class VM_AtomicSupport
418418
#elif defined(OMRZTPF) /* defined(OMR_ARCH_POWER) && !defined(OMR_ENV_DATA64) */
419419
csg((csg_t *)&oldValue, (csg_t *)address, (csg_t)newValue);
420420
return oldValue;
421-
#elif defined(__xlC__) /* defined(OMRZTPF) */
421+
#elif defined(__xlC__)|| defined(__open_xl__) /* defined(OMRZTPF) */
422422
#if defined(__64BIT__) || !defined(AIXPPC)
423423
__compare_and_swaplp((volatile long*)address, (long*)&oldValue, (long)newValue);
424424
#else /* defined(__64BIT__) */

include_core/omr.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ const char * const *OMR_Glue_GetMethodDictionaryPropertyNames(void);
555555
* (__xlC__ is defined by xlC_r, __ibmxl_version__ is defined by xlclang++).
556556
*/
557557
#if (defined(__xlC__) && ((__xlC__ >> 8) >= 16)) \
558-
|| (defined(__ibmxl_version__) && (__ibmxl_version__ >= 16))
558+
|| (defined(__ibmxl_version__) && (__ibmxl_version__ >= 16)) \
559+
|| defined(__open_xl__)
559560
#define ddr_constant(name, value) static enum { name = value } ddr_ref_ ## name
560561
#else /* defined(__ibmxl_version__) && (__ibmxl_version__ >= 16) */
561562
#define ddr_constant(name, value) enum { name = value }

0 commit comments

Comments
 (0)