< prev index next >

make/autoconf/flags-cflags.m4

Print this page

  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 ################################################################################
  27 #
  28 # Setup flags for C/C++ compiler
  29 #
  30 
  31 ###############################################################################
  32 #
  33 # How to compile shared libraries.
  34 #
  35 AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
  36 [
  37   if test "x$TOOLCHAIN_TYPE" = xgcc; then
  38     # Default works for linux, might work on other platforms as well.
  39     SHARED_LIBRARY_FLAGS='-shared'
  40     SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'



  41     SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
  42     SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
  43     SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
  44 
  45   elif test "x$TOOLCHAIN_TYPE" = xclang; then
  46     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
  47       # Linking is different on MacOSX
  48       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0"
  49       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
  50       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
  51       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
  52       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
  53 
  54     elif test "x$OPENJDK_TARGET_OS" = xaix; then
  55       # Linking is different on aix
  56       SHARED_LIBRARY_FLAGS="-shared -Wl,-bM:SRE -Wl,-bnoentry"
  57       SET_EXECUTABLE_ORIGIN=""
  58       SET_SHARED_LIBRARY_ORIGIN=''
  59       SET_SHARED_LIBRARY_NAME=''
  60       SET_SHARED_LIBRARY_MAPFILE=''
  61 
  62     else
  63       # Default works for linux, might work on other platforms as well.
  64       SHARED_LIBRARY_FLAGS='-shared'
  65       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'



  66       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
  67       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
  68 
  69       # arm specific settings
  70       if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
  71         # '-Wl,-z,origin' isn't used on arm.
  72         SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
  73       else
  74         SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
  75       fi
  76     fi
  77 
  78   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
  79     SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
  80     SET_EXECUTABLE_ORIGIN=""
  81     SET_SHARED_LIBRARY_ORIGIN=''
  82     SET_SHARED_LIBRARY_NAME=''
  83     SET_SHARED_LIBRARY_MAPFILE=''
  84 
  85   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then

 105   ASFLAGS_DEBUG_SYMBOLS=""
 106 
 107   # Debug prefix mapping if supported by compiler
 108   DEBUG_PREFIX_CFLAGS=
 109 
 110   # Debug symbols
 111   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 112     if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
 113       # Check if compiler supports -fdebug-prefix-map. If so, use that to make
 114       # the debug symbol paths resolve to paths relative to the workspace root.
 115       workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
 116       DEBUG_PREFIX_CFLAGS="-fdebug-prefix-map=${workspace_root_trailing_slash}="
 117       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_PREFIX_CFLAGS}],
 118         IF_FALSE: [
 119             DEBUG_PREFIX_CFLAGS=
 120         ],
 121         IF_TRUE: [
 122             # Add debug prefix map gcc system include paths, as they cause
 123             # non-deterministic debug paths depending on gcc path location.
 124             DEBUG_PREFIX_MAP_GCC_INCLUDE_PATHS





 125         ]
 126       )
 127     fi
 128 
 129     CFLAGS_DEBUG_SYMBOLS="-g -gdwarf-4"
 130     ASFLAGS_DEBUG_SYMBOLS="-g"
 131   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 132     if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
 133       # Check if compiler supports -fdebug-prefix-map. If so, use that to make
 134       # the debug symbol paths resolve to paths relative to the workspace root.
 135       workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
 136       DEBUG_PREFIX_CFLAGS="-fdebug-prefix-map=${workspace_root_trailing_slash}="
 137       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_PREFIX_CFLAGS}],
 138         IF_FALSE: [
 139             DEBUG_PREFIX_CFLAGS=
 140         ]
 141       )
 142     fi
 143 
 144     # -gdwarf-4 and -gdwarf-aranges were introduced in clang 5.0

 468   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_], [BUILD_])
 469 
 470   CC="$CC_OLD"
 471   CXX="$CXX_OLD"
 472   CFLAGS="$CFLAGS_OLD"
 473   CXXFLAGS="$CXXFLAGS_OLD"
 474 ])
 475 
 476 ################################################################################
 477 # platform independent
 478 AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
 479 [
 480   #### OS DEFINES, these should be independent on toolchain
 481   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 482     CFLAGS_OS_DEF_JVM="-DLINUX -D_FILE_OFFSET_BITS=64"
 483     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 484   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 485     CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
 486     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 487   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 488     CFLAGS_OS_DEF_JVM="-DAIX"
 489   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 490     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
 491   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
 492     CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
 493   fi
 494 
 495   CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 496 
 497   #### GLOBAL DEFINES
 498   # Set some common defines. These works for all compilers, but assume
 499   # -D is universally accepted.
 500 
 501   # Always enable optional macros for VM.
 502   ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
 503 
 504   # Setup some hard coded includes
 505   ALWAYS_CFLAGS_JDK=" \
 506       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
 507       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
 508       -I${TOPDIR}/src/java.base/share/native/libjava \

  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 ################################################################################
  27 #
  28 # Setup flags for C/C++ compiler
  29 #
  30 
  31 ################################################################################
  32 #
  33 # How to compile shared libraries.
  34 #
  35 AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
  36 [
  37   if test "x$TOOLCHAIN_TYPE" = xgcc; then
  38     # Default works for linux, might work on other platforms as well.
  39     SHARED_LIBRARY_FLAGS='-shared'
  40     # --disable-new-dtags forces use of RPATH instead of RUNPATH for rpaths.
  41     # This protects internal library dependencies within the JDK from being
  42     # overridden using LD_LIBRARY_PATH. See JDK-8326891 for more information.
  43     SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1 -Wl,--disable-new-dtags'
  44     SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
  45     SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
  46     SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
  47 
  48   elif test "x$TOOLCHAIN_TYPE" = xclang; then
  49     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
  50       # Linking is different on MacOSX
  51       SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0"
  52       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
  53       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
  54       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
  55       SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
  56 
  57     elif test "x$OPENJDK_TARGET_OS" = xaix; then
  58       # Linking is different on aix
  59       SHARED_LIBRARY_FLAGS="-shared -Wl,-bM:SRE -Wl,-bnoentry"
  60       SET_EXECUTABLE_ORIGIN=""
  61       SET_SHARED_LIBRARY_ORIGIN=''
  62       SET_SHARED_LIBRARY_NAME=''
  63       SET_SHARED_LIBRARY_MAPFILE=''
  64 
  65     else
  66       # Default works for linux, might work on other platforms as well.
  67       SHARED_LIBRARY_FLAGS='-shared'
  68       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
  69       if test "x$OPENJDK_TARGET_OS" = xlinux; then
  70         SET_EXECUTABLE_ORIGIN="$SET_EXECUTABLE_ORIGIN -Wl,--disable-new-dtags"
  71       fi
  72       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
  73       SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
  74 
  75       # arm specific settings
  76       if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
  77         # '-Wl,-z,origin' isn't used on arm.
  78         SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
  79       else
  80         SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
  81       fi
  82     fi
  83 
  84   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
  85     SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
  86     SET_EXECUTABLE_ORIGIN=""
  87     SET_SHARED_LIBRARY_ORIGIN=''
  88     SET_SHARED_LIBRARY_NAME=''
  89     SET_SHARED_LIBRARY_MAPFILE=''
  90 
  91   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then

 111   ASFLAGS_DEBUG_SYMBOLS=""
 112 
 113   # Debug prefix mapping if supported by compiler
 114   DEBUG_PREFIX_CFLAGS=
 115 
 116   # Debug symbols
 117   if test "x$TOOLCHAIN_TYPE" = xgcc; then
 118     if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
 119       # Check if compiler supports -fdebug-prefix-map. If so, use that to make
 120       # the debug symbol paths resolve to paths relative to the workspace root.
 121       workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
 122       DEBUG_PREFIX_CFLAGS="-fdebug-prefix-map=${workspace_root_trailing_slash}="
 123       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_PREFIX_CFLAGS}],
 124         IF_FALSE: [
 125             DEBUG_PREFIX_CFLAGS=
 126         ],
 127         IF_TRUE: [
 128             # Add debug prefix map gcc system include paths, as they cause
 129             # non-deterministic debug paths depending on gcc path location.
 130             DEBUG_PREFIX_MAP_GCC_INCLUDE_PATHS
 131 
 132             # Add debug prefix map for OUTPUTDIR to handle the scenario when
 133             # it is not located within WORKSPACE_ROOT
 134             outputdir_slash="${OUTPUTDIR%/}/"
 135             DEBUG_PREFIX_CFLAGS="$DEBUG_PREFIX_CFLAGS -fdebug-prefix-map=${outputdir_slash}="
 136         ]
 137       )
 138     fi
 139 
 140     CFLAGS_DEBUG_SYMBOLS="-g -gdwarf-4"
 141     ASFLAGS_DEBUG_SYMBOLS="-g"
 142   elif test "x$TOOLCHAIN_TYPE" = xclang; then
 143     if test "x$ALLOW_ABSOLUTE_PATHS_IN_OUTPUT" = "xfalse"; then
 144       # Check if compiler supports -fdebug-prefix-map. If so, use that to make
 145       # the debug symbol paths resolve to paths relative to the workspace root.
 146       workspace_root_trailing_slash="${WORKSPACE_ROOT%/}/"
 147       DEBUG_PREFIX_CFLAGS="-fdebug-prefix-map=${workspace_root_trailing_slash}="
 148       FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_PREFIX_CFLAGS}],
 149         IF_FALSE: [
 150             DEBUG_PREFIX_CFLAGS=
 151         ]
 152       )
 153     fi
 154 
 155     # -gdwarf-4 and -gdwarf-aranges were introduced in clang 5.0

 479   FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_], [BUILD_])
 480 
 481   CC="$CC_OLD"
 482   CXX="$CXX_OLD"
 483   CFLAGS="$CFLAGS_OLD"
 484   CXXFLAGS="$CXXFLAGS_OLD"
 485 ])
 486 
 487 ################################################################################
 488 # platform independent
 489 AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
 490 [
 491   #### OS DEFINES, these should be independent on toolchain
 492   if test "x$OPENJDK_TARGET_OS" = xlinux; then
 493     CFLAGS_OS_DEF_JVM="-DLINUX -D_FILE_OFFSET_BITS=64"
 494     CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
 495   elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
 496     CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
 497     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
 498   elif test "x$OPENJDK_TARGET_OS" = xaix; then
 499     CFLAGS_OS_DEF_JVM="-DAIX -D_LARGE_FILES"
 500   elif test "x$OPENJDK_TARGET_OS" = xbsd; then
 501     CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
 502   elif test "x$OPENJDK_TARGET_OS" = xwindows; then
 503     CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
 504   fi
 505 
 506   CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
 507 
 508   #### GLOBAL DEFINES
 509   # Set some common defines. These works for all compilers, but assume
 510   # -D is universally accepted.
 511 
 512   # Always enable optional macros for VM.
 513   ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
 514 
 515   # Setup some hard coded includes
 516   ALWAYS_CFLAGS_JDK=" \
 517       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
 518       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
 519       -I${TOPDIR}/src/java.base/share/native/libjava \
< prev index next >