diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index e9959196acb..cfea63f0e3b 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -51,6 +51,14 @@ AC_DEFUN([FLAGS_SETUP_SHARED_LIBS], SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1' SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1' + elif test "x$OPENJDK_TARGET_OS" = xaix; then + # Linking is different on aix + SHARED_LIBRARY_FLAGS="-shared -Wl,-bM:SRE -Wl,-bnoentry" + SET_EXECUTABLE_ORIGIN="" + SET_SHARED_LIBRARY_ORIGIN='' + SET_SHARED_LIBRARY_NAME='' + SET_SHARED_LIBRARY_MAPFILE='' + else # Default works for linux, might work on other platforms as well. SHARED_LIBRARY_FLAGS='-shared' @@ -206,7 +214,6 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL" DISABLED_WARNINGS="unknown-warning-option unused-parameter unused" - ;; xlc) @@ -284,9 +291,15 @@ AC_DEFUN([FLAGS_SETUP_OPTIMIZATION], C_O_FLAG_NONE="${C_O_FLAG_NONE} ${DISABLE_FORTIFY_CFLAGS}" fi elif test "x$TOOLCHAIN_TYPE" = xclang; then - C_O_FLAG_HIGHEST_JVM="-O3" - C_O_FLAG_HIGHEST="-O3" - C_O_FLAG_HI="-O3" + if test "x$OPENJDK_TARGET_OS" = xaix; then + C_O_FLAG_HIGHEST_JVM="-O3 -finline-functions" + C_O_FLAG_HIGHEST="-O3 -finline-functions" + C_O_FLAG_HI="-O3 -finline-functions" + else + C_O_FLAG_HIGHEST_JVM="-O3" + C_O_FLAG_HIGHEST="-O3" + C_O_FLAG_HI="-O3" + fi C_O_FLAG_NORM="-O2" C_O_FLAG_DEBUG_JVM="-O0" C_O_FLAG_SIZE="-Os" @@ -458,6 +471,9 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], # so for debug we build with '-qpic=large -bbigtoc'. DEBUG_CFLAGS_JVM="-qpic=large" fi + if test "x$TOOLCHAIN_TYPE" = xclang && test "x$OPENJDK_TARGET_OS" = xaix; then + DEBUG_CFLAGS_JVM="-fpic -mcmodel=large" + fi fi if test "x$DEBUG_LEVEL" != xrelease; then @@ -493,6 +509,12 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer" fi + if test "x$TOOLCHAIN_TYPE" = xclang && test "x$OPENJDK_TARGET_OS" = xaix; then + # clang compiler on aix needs -ffunction-sections + TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -ffunction-sections -ftls-model -fno-math-errno -fstack-protector" + TOOLCHAIN_CFLAGS_JDK="-ffunction-sections -fsigned-char -fstack-protector" + fi + if test "x$TOOLCHAIN_TYPE" = xgcc; then TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fstack-protector" TOOLCHAIN_CFLAGS_JDK="-pipe -fstack-protector" @@ -601,6 +623,9 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then PICFLAG="-fPIC" PIEFLAG="-fPIE" + elif test "x$TOOLCHAIN_TYPE" = xclang && test "x$OPENJDK_TARGET_OS" = xaix; then + JVM_PICFLAG="-fpic -mcmodel=large -Wl,-bbigtoc + JDK_PICFLAG="-fpic elif test "x$TOOLCHAIN_TYPE" = xxlc; then # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index c1e7218ca2c..e5c345fdef1 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,11 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], elif test "x$TOOLCHAIN_TYPE" = xclang; then BASIC_LDFLAGS_JVM_ONLY="-mno-omit-leaf-frame-pointer -mstack-alignment=16 \ -fPIC" - + if test "x$OPENJDK_TARGET_OS" = xaix; then + BASIC_LDFLAGS="-Wl,-b64 -Wl,-brtl -Wl,-bnorwexec -Wl,-bnolibpath -Wl,-bnoexpall \ + -Wl,-bernotok -Wl,-bdatapsize:64k -Wl,-btextpsize:64k -Wl,-bstackpsize:64k" + BASIC_LDFLAGS_JVM_ONLY="$BASIC_LDFLAGS_JVM_ONLY -Wl,-lC_r -Wl,-bbigtoc" + fi elif test "x$TOOLCHAIN_TYPE" = xxlc; then BASIC_LDFLAGS="-b64 -brtl -bnorwexec -bnolibpath -bnoexpall -bernotok -btextpsize:64K \ -bdatapsize:64K -bstackpsize:64K" @@ -88,7 +92,8 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], BASIC_LDFLAGS_JVM_ONLY="-opt:icf,8 -subsystem:windows" fi - if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then + if (test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang) \ + && test "x$OPENJDK_TARGET_OS" != xaix; then if test -n "$HAS_NOEXECSTACK"; then BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,noexecstack" fi @@ -116,6 +121,14 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], if test "x$DEBUG_LEVEL" != xrelease; then DEBUGLEVEL_LDFLAGS_JVM_ONLY="$DEBUGLEVEL_LDFLAGS_JVM_ONLY -bbigtoc" fi + + elif test "x$TOOLCHAIN_TYPE" = xclang && test "x$OPENJDK_TARGET_OS" = xaix; then + # We need '-fpic' or '-fpic -mcmodel=large -Wl,-bbigtoc' if the TOC overflows. + # Hotspot now overflows its 64K TOC (currently only for debug), + # so we build with '-fpic -mcmodel=large -Wl,-bbigtoc'. + if test "x$DEBUG_LEVEL" != xrelease; then + DEBUGLEVEL_LDFLAGS_JVM_ONLY="$DEBUGLEVEL_LDFLAGS_JVM_ONLY -Wl,-bbigtoc" + fi fi # Setup LDFLAGS for linking executables diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index 1ae0902e3f3..c89aab11d4b 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ VALID_TOOLCHAINS_all="gcc clang xlc microsoft" # These toolchains are valid on different platforms VALID_TOOLCHAINS_linux="gcc clang" VALID_TOOLCHAINS_macosx="clang" -VALID_TOOLCHAINS_aix="xlc" +VALID_TOOLCHAINS_aix="xlc clang" VALID_TOOLCHAINS_windows="microsoft" # Toolchain descriptions @@ -234,6 +234,25 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], # First toolchain type in the list is the default DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *} + # On AIX the default toolchain depends on the installed (found) compiler + # xlclang++ -> xlc toolchain + # ibm-clang++_r -> clang toolchain + # The compiler is searched on the PATH and TOOLCHAIN_PATH + # xlclang++ has precedence over ibm-clang++_r if both are installed + if test "x$OPENJDK_TARGET_OS" = xaix; then + DEFAULT_TOOLCHAIN="clang" + if test "x$TOOLCHAIN_PATH" != x; then + if test -e ${TOOLCHAIN_PATH}/xlclang++; then + DEFAULT_TOOLCHAIN="xlc" + fi + else + UTIL_LOOKUP_PROGS(XLCLANG_TEST_PATH, xlclang++) + if test "x$XLCLANG_TEST_PATH" != x; then + DEFAULT_TOOLCHAIN="xlc" + fi + fi + fi + if test "x$with_toolchain_type" = xlist; then # List all toolchains AC_MSG_NOTICE([The following toolchains are valid on this platform:]) @@ -263,22 +282,40 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], if test "x$TOOLCHAIN_PATH" != x; then XLC_TEST_PATH=${TOOLCHAIN_PATH}/ fi - - XLCLANG_VERSION_OUTPUT=`${XLC_TEST_PATH}xlclang++ -qversion 2>&1 | $HEAD -n 1` - $ECHO "$XLCLANG_VERSION_OUTPUT" | $GREP "IBM XL C/C++ for AIX" > /dev/null - if test $? -eq 0; then - AC_MSG_NOTICE([xlclang++ output: $XLCLANG_VERSION_OUTPUT]) + if test "x$TOOLCHAIN_TYPE" = xclang; then + TOOLCHAIN_DESCRIPTION_clang="IBM Open XL C/C++" + XLCLANG_VERSION_OUTPUT=`${XLC_TEST_PATH}ibm-clang++_r --version 2>&1 | $HEAD -n 1` + $ECHO "$XLCLANG_VERSION_OUTPUT" | $GREP "IBM Open XL C/C++ for AIX" > /dev/null + if test $? -eq 0; then + AC_MSG_NOTICE([ibm-clang++_r output: $XLCLANG_VERSION_OUTPUT]) + else + AC_MSG_ERROR([ibm-clang++_r version output check failed, output: $XLCLANG_VERSION_OUTPUT]) + fi else - AC_MSG_ERROR([xlclang++ version output check failed, output: $XLCLANG_VERSION_OUTPUT]) + XLCLANG_VERSION_OUTPUT=`${XLC_TEST_PATH}xlclang++ -qversion 2>&1 | $HEAD -n 1` + $ECHO "$XLCLANG_VERSION_OUTPUT" | $GREP "IBM XL C/C++ for AIX" > /dev/null + if test $? -eq 0; then + AC_MSG_NOTICE([xlclang++ output: $XLCLANG_VERSION_OUTPUT]) + else + AC_MSG_ERROR([xlclang++ version output check failed, output: $XLCLANG_VERSION_OUTPUT]) + fi fi fi - TOOLCHAIN_CC_BINARY_clang="clang" + if test "x$OPENJDK_TARGET_OS" = xaix; then + TOOLCHAIN_CC_BINARY_clang="ibm-clang_r" + else + TOOLCHAIN_CC_BINARY_clang="clang" + fi TOOLCHAIN_CC_BINARY_gcc="gcc" TOOLCHAIN_CC_BINARY_microsoft="cl" TOOLCHAIN_CC_BINARY_xlc="xlclang" - TOOLCHAIN_CXX_BINARY_clang="clang++" + if test "x$OPENJDK_TARGET_OS" = xaix; then + TOOLCHAIN_CXX_BINARY_clang="ibm-clang++_r" + else + TOOLCHAIN_CXX_BINARY_clang="clang++" + fi TOOLCHAIN_CXX_BINARY_gcc="g++" TOOLCHAIN_CXX_BINARY_microsoft="cl" TOOLCHAIN_CXX_BINARY_xlc="xlclang++" @@ -966,7 +1003,11 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], # Setup hotspot lecagy names for toolchains HOTSPOT_TOOLCHAIN_TYPE=$TOOLCHAIN_TYPE if test "x$TOOLCHAIN_TYPE" = xclang; then - HOTSPOT_TOOLCHAIN_TYPE=gcc + if test "x$OPENJDK_TARGET_OS" = xaix; then + HOTSPOT_TOOLCHAIN_TYPE=xlc + else + HOTSPOT_TOOLCHAIN_TYPE=gcc + fi elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then HOTSPOT_TOOLCHAIN_TYPE=visCPP fi diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index 5c8989e3efd..1005bc5000b 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk +++ b/make/hotspot/gensrc/GensrcAdlc.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,13 @@ ifeq ($(call check-jvm-feature, compiler2), true) ifeq ($(call isBuildOs, linux), true) ADLC_CFLAGS := -fno-exceptions -DLINUX else ifeq ($(call isBuildOs, aix), true) - ADLC_LDFLAGS += -q64 - ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX + ifeq ($(TOOLCHAIN_TYPE), clang) + ADLC_LDFLAGS += -m64 + ADLC_CFLAGS := -fno-rtti -fexceptions -ffunction-sections -m64 -DAIX + else + ADLC_LDFLAGS += -q64 + ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX + endif else ifeq ($(call isBuildOs, windows), true) ADLC_LDFLAGS += -nologo ADLC_CFLAGS := -nologo -EHsc diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index 377018cdb51..b50d6f8bb36 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -109,7 +109,11 @@ else ifeq ($(call isTargetOs, macosx), true) endif else ifeq ($(call isTargetOs, aix), true) - BUILD_LIBJVM_synchronizer.cpp_CXXFLAGS := -qnoinline + ifeq ($(TOOLCHAIN_TYPE), clang) + BUILD_LIBJVM_synchronizer.cpp_CXXFLAGS := -fno-inline + else + BUILD_LIBJVM_synchronizer.cpp_CXXFLAGS := -qnoinline + endif BUILD_LIBJVM_sharedRuntimeTrans.cpp_CXXFLAGS := $(CXX_O_FLAG_NONE) # Disable aggressive optimizations for functions in sharedRuntimeTrig.cpp # and sharedRuntimeTrans.cpp on ppc64. diff --git a/src/hotspot/share/utilities/globalDefinitions_xlc.hpp b/src/hotspot/share/utilities/globalDefinitions_xlc.hpp index 518a09f90a7..edeb730132b 100644 --- a/src/hotspot/share/utilities/globalDefinitions_xlc.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_xlc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2021 SAP SE. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,14 +56,23 @@ #if __ibmxl_version__ < 16 #error "xlc < 16 not supported" #endif +#elif defined(__open_xl_version__) + #if __open_xl_version__ < 17 + #error "open xlc < 17 not supported" + #endif #else - #error "xlc < 16 not supported, macro __ibmxl_version__ not found" + #error "xlc version not supported, macro __ibmxl_version__ or __open_xl_version__ not found" #endif #ifndef _AIX #error "missing AIX-specific definition _AIX" #endif +// Shortcut for the new xlc 17 compiler +#if defined(AIX) && defined(__open_xl_version__) && __open_xl_version__ >= 17 +#define AIX_XLC_GE_17 +#endif + // Use XLC compiler builtins instead of inline assembler #define USE_XLC_BUILTINS