common/autoconf/lib-std.m4
author ddmitriev
Wed, 07 Sep 2016 15:34:38 +0300
changeset 40965 8f3eb2bcd1a4
parent 37402 62b5f067032e
child 41170 30db66a57e7d
permissions -rw-r--r--
8165513: Quarantine sun/tools/jps/TestJpsJar.java Reviewed-by: dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     1
#
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
     2
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     4
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    10
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    15
# accompanied this code).
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    16
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    20
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    23
# questions.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    24
#
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    25
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    26
################################################################################
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    27
# Setup the standard C/C++ runtime libraries.
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    28
#
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    29
# Most importantly, determine if stdc++ should be linked statically or
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    30
# dynamically.
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    31
################################################################################
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    32
AC_DEFUN_ONCE([LIB_SETUP_STD_LIBS],
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    33
[
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    34
  # statically link libstdc++ before C++ ABI is stablized on Linux unless
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    35
  # dynamic build is configured on command line.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    36
  AC_ARG_WITH([stdc++lib], [AS_HELP_STRING([--with-stdc++lib=<static>,<dynamic>,<default>],
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    37
      [force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as fallback])],
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    38
      [
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    39
        if test "x$with_stdc__lib" != xdynamic && test "x$with_stdc__lib" != xstatic \
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    40
                && test "x$with_stdc__lib" != xdefault; then
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    41
          AC_MSG_ERROR([Bad parameter value --with-stdc++lib=$with_stdc__lib!])
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    42
        fi
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    43
      ],
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    44
      [with_stdc__lib=default]
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    45
  )
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    46
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    47
  if test "x$OPENJDK_TARGET_OS" = xlinux; then
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    48
    # Test if -lstdc++ works.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    49
    AC_MSG_CHECKING([if dynamic link of stdc++ is possible])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    50
    AC_LANG_PUSH(C++)
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    51
    OLD_CXXFLAGS="$CXXFLAGS"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    52
    CXXFLAGS="$CXXFLAGS -lstdc++"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    53
    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    54
        [has_dynamic_libstdcxx=yes],
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    55
        [has_dynamic_libstdcxx=no])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    56
    CXXFLAGS="$OLD_CXXFLAGS"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    57
    AC_LANG_POP(C++)
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    58
    AC_MSG_RESULT([$has_dynamic_libstdcxx])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    59
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    60
    # Test if stdc++ can be linked statically.
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    61
    AC_MSG_CHECKING([if static link of stdc++ is possible])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    62
    STATIC_STDCXX_FLAGS="-Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    63
    AC_LANG_PUSH(C++)
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    64
    OLD_LIBS="$LIBS"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    65
    OLD_CXX="$CXX"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    66
    LIBS="$STATIC_STDCXX_FLAGS"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    67
    CXX="$CC"
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    68
    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    69
        [has_static_libstdcxx=yes],
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    70
        [has_static_libstdcxx=no])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    71
    LIBS="$OLD_LIBS"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    72
    CXX="$OLD_CXX"
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    73
    AC_LANG_POP(C++)
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    74
    AC_MSG_RESULT([$has_static_libstdcxx])
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    75
14459
6213b3f9e08d 8001875: build-infra: We must be able to force static linking of stdc++
tbell
parents: 14280
diff changeset
    76
    if test "x$has_static_libstdcxx" = xno && test "x$has_dynamic_libstdcxx" = xno; then
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    77
      AC_MSG_ERROR([Cannot link to stdc++, neither dynamically nor statically!])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    78
    fi
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    79
14459
6213b3f9e08d 8001875: build-infra: We must be able to force static linking of stdc++
tbell
parents: 14280
diff changeset
    80
    if test "x$with_stdc__lib" = xstatic && test "x$has_static_libstdcxx" = xno; then
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    81
      AC_MSG_ERROR([Static linking of libstdc++ was not possible!])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    82
    fi
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    83
14459
6213b3f9e08d 8001875: build-infra: We must be able to force static linking of stdc++
tbell
parents: 14280
diff changeset
    84
    if test "x$with_stdc__lib" = xdynamic && test "x$has_dynamic_libstdcxx" = xno; then
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    85
      AC_MSG_ERROR([Dynamic linking of libstdc++ was not possible!])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    86
    fi
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
    87
14459
6213b3f9e08d 8001875: build-infra: We must be able to force static linking of stdc++
tbell
parents: 14280
diff changeset
    88
    # If dynamic was requested, it's available since it would fail above otherwise.
6213b3f9e08d 8001875: build-infra: We must be able to force static linking of stdc++
tbell
parents: 14280
diff changeset
    89
    # If dynamic wasn't requested, go with static unless it isn't available.
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
    90
    AC_MSG_CHECKING([how to link with libstdc++])
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
    91
    if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    92
      LIBCXX="$LIBCXX -lstdc++"
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
    93
      # To help comparisons with old build, put stdc++ first in JVM_LIBS
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
    94
      JVM_LIBS="-lstdc++ $JVM_LIBS"
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
    95
      # Ideally, we should test stdc++ for the BUILD toolchain separately. For now
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
    96
      # just use the same setting as for the TARGET toolchain.
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
    97
      OPENJDK_BUILD_JVM_LIBS="-lstdc++ $OPENJDK_BUILD_JVM_LIBS"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    98
      LDCXX="$CXX"
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
    99
      STATIC_CXX_SETTING="STATIC_CXX=false"
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   100
      AC_MSG_RESULT([dynamic])
14459
6213b3f9e08d 8001875: build-infra: We must be able to force static linking of stdc++
tbell
parents: 14280
diff changeset
   101
    else
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   102
      LIBCXX="$LIBCXX $STATIC_STDCXX_FLAGS"
37402
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
   103
      JVM_LDFLAGS="$JVM_LDFLAGS -static-libgcc"
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
   104
      # To help comparisons with old build, put stdc++ first in JVM_LIBS
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
   105
      JVM_LIBS="-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic $JVM_LIBS"
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
   106
      # Ideally, we should test stdc++ for the BUILD toolchain separately. For now
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
   107
      # just use the same setting as for the TARGET toolchain.
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
   108
      OPENJDK_BUILD_JVM_LDFLAGS="$OPENJDK_BUILD_JVM_LDFLAGS -static-libgcc"
62b5f067032e 8152666: The new Hotspot Build System
erikj
parents: 32921
diff changeset
   109
      OPENJDK_BUILD_JVM_LIBS="-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic $OPENJDK_BUILD_JVM_LIBS"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   110
      LDCXX="$CC"
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   111
      STATIC_CXX_SETTING="STATIC_CXX=true"
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   112
      AC_MSG_RESULT([static])
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   113
    fi
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   114
  fi
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   115
  AC_SUBST(STATIC_CXX_SETTING)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   116
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   117
  # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so)
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22710
diff changeset
   118
  if test "x$TOOLCHAIN_TYPE" = xsolstudio && test "x$LIBCXX" = x; then
23428
3c8a05bf4656 8038340: Cleanup and fix sysroot and devkit handling on Linux and Solaris
erikj
parents: 23165
diff changeset
   119
    LIBCXX="${SYSROOT}/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   120
  fi
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   121
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   122
  # TODO better (platform agnostic) test
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22710
diff changeset
   123
  if test "x$OPENJDK_TARGET_OS" = xmacosx && test "x$LIBCXX" = x && test "x$TOOLCHAIN_TYPE" = xgcc; then
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   124
    LIBCXX="-lstdc++"
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 19524
diff changeset
   125
  fi
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   126
  AC_SUBST(LIBCXX)
13133
701e61c32ece 7182051: Update of latest build-infra Makefiles (missing files)
erikj
parents:
diff changeset
   127
32921
8e0250dfa145 8138761: Improved handling of libffi, and cleanup of libraries.m4
ihse
parents: 31327
diff changeset
   128
  # Setup Windows runtime dlls
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22710
diff changeset
   129
  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
28901
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
   130
    TOOLCHAIN_SETUP_VS_RUNTIME_DLLS
22721
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22710
diff changeset
   131
  fi
63761da45392 8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
ihse
parents: 22710
diff changeset
   132
])