Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compiler options needed by openXL #7447

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions cmake/modules/OmrDetectSystemInformation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,21 @@ 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")
else()
# TODO we don't actually have a clang config
# just use GNU config
set(_OMR_TOOLCONFIG "gnu")
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
set(_OMR_TOOLCONFIG "gnu")
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES "^XL(Clang)?$" OR CMAKE_C_COMPILER_ID STREQUAL "zOS")
# In CMake 3.14 and prior, XLClang uses CMAKE_C_COMPILER_ID "XL"
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
50 changes: 39 additions & 11 deletions cmake/modules/platform/toolcfg/gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 "<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 +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()
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__) && defined(__cplusplus)
// 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(__cplusplus)) && 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__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks out of place ... shouldn't it be defined in the same clause for AIX? strongly recommend to do that just for readability.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it looks out of place, but the else part is supposed to be for power not sure why there is a check for LINUX in that. But as the definition used for smp is same for open_xl and LINUX macro I didn't put it under another if checking.

#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
2 changes: 1 addition & 1 deletion compiler/p/codegen/PPCTableOfConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ int32_t TR_PPCTableOfConstants::lookUp(TR::SymbolReference *symRef, TR::CodeGene
int8_t local_buffer[1024];
int8_t *name = local_buffer;
bool isAddr = false;
intptr_t myTag;
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
#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 @@ -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;

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
char *name = (char*)alloca(nameLength+1);
#endif
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(__open_xl__) && !defined(MVS)) && !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
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 '' -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

Expand Down
Loading
Loading