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

Backport support for Alpine musl #7

Merged
merged 5 commits into from
Oct 8, 2021
Merged
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
1 change: 1 addition & 0 deletions make/ReleaseFile.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ define create-info-file
$(call info-file-item, "JAVA_VERSION_DATE", "$(VERSION_DATE)")
$(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
$(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
$(call info-file-item, "LIBC", "$(RELEASE_FILE_LIBC)")
endef

# Param 1 - The file containing the MODULES list
Expand Down
11 changes: 11 additions & 0 deletions make/autoconf/build-aux/config.guess
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ if test $? = 0; then
OUT=$REAL_CPU`echo $OUT | sed -e 's/[^-]*//'`
fi

# Detect C library.
# Use '-gnu' suffix on systems that use glibc.
# Use '-musl' suffix on systems that use the musl libc.
echo $OUT | grep -- -linux- > /dev/null 2> /dev/null
if test $? = 0; then
libc_vendor=`ldd --version 2>&1 | sed -n '1s/.*\(musl\).*/\1/p'`
if [ x"${libc_vendor}" = x"musl" ]; then
OUT=`echo $OUT | sed 's/-gnu/-musl/'`
fi
fi

# Test and fix cygwin on x86_64
echo $OUT | grep 86-pc-cygwin > /dev/null 2> /dev/null
if test $? != 0; then
Expand Down
5 changes: 5 additions & 0 deletions make/autoconf/build-aux/config.sub
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

DIR=`dirname $0`

if echo $* | grep linux-musl >/dev/null ; then
echo $*
exit
fi

# First, filter out everything that doesn't begin with "aarch64-"
if ! echo $* | grep '^aarch64-' >/dev/null ; then
. $DIR/autoconf-config.sub "$@"
Expand Down
3 changes: 3 additions & 0 deletions make/autoconf/buildjdk-spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ IMAGES_OUTPUTDIR := $(patsubst $(OUTPUTDIR)%,$(BUILDJDK_OUTPUTDIR)%,$(IMAGES_OUT

OPENJDK_BUILD_CPU_LEGACY := @OPENJDK_BUILD_CPU_LEGACY@
OPENJDK_BUILD_CPU_LEGACY_LIB := @OPENJDK_BUILD_CPU_LEGACY_LIB@
OPENJDK_BUILD_LIBC := @OPENJDK_BUILD_LIBC@
OPENJDK_TARGET_CPU := @OPENJDK_BUILD_CPU@
OPENJDK_TARGET_CPU_ARCH := @OPENJDK_BUILD_CPU_ARCH@
OPENJDK_TARGET_CPU_BITS := @OPENJDK_BUILD_CPU_BITS@
OPENJDK_TARGET_CPU_ENDIAN := @OPENJDK_BUILD_CPU_ENDIAN@
OPENJDK_TARGET_CPU_LEGACY := @OPENJDK_BUILD_CPU_LEGACY@
OPENJDK_TARGET_LIBC := @OPENJDK_BUILD_LIBC@
OPENJDK_TARGET_OS_INCLUDE_SUBDIR := @OPENJDK_BUILD_OS_INCLUDE_SUBDIR@

HOTSPOT_TARGET_OS := @HOTSPOT_BUILD_OS@
HOTSPOT_TARGET_OS_TYPE := @HOTSPOT_BUILD_OS_TYPE@
HOTSPOT_TARGET_CPU := @HOTSPOT_BUILD_CPU@
HOTSPOT_TARGET_CPU_ARCH := @HOTSPOT_BUILD_CPU_ARCH@
HOTSPOT_TARGET_CPU_DEFINE := @HOTSPOT_BUILD_CPU_DEFINE@
HOTSPOT_TARGET_LIBC := @HOTSPOT_BUILD_LIBC@

CFLAGS_JDKLIB := @OPENJDK_BUILD_CFLAGS_JDKLIB@
CXXFLAGS_JDKLIB := @OPENJDK_BUILD_CXXFLAGS_JDKLIB@
Expand Down
5 changes: 5 additions & 0 deletions make/autoconf/flags-cflags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
fi
fi

OS_CFLAGS="$OS_CFLAGS -DLIBC=$OPENJDK_TARGET_LIBC"
if test "x$OPENJDK_TARGET_LIBC" = xmusl; then
OS_CFLAGS="$OS_CFLAGS -DMUSL_LIBC"
fi

# Where does this really belong??
if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
PICFLAG="-fPIC"
Expand Down
51 changes: 48 additions & 3 deletions make/autoconf/platform.m4
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS],
esac
])

# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
# Converts autoconf style OS name to OpenJDK style, into
# VAR_LIBC.
AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_LIBC],
[
case "$1" in
*linux*-musl)
VAR_LIBC=musl
;;
*linux*-gnu)
VAR_LIBC=gnu
;;
*)
VAR_LIBC=default
;;
esac
])

# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD.
# Converts autoconf style OS name to OpenJDK style, into
# VAR_ABI.
Expand Down Expand Up @@ -240,9 +258,10 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME)
AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME)

# Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
# Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU/LIBC variables.
PLATFORM_EXTRACT_VARS_FROM_OS($build_os)
PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu)
PLATFORM_EXTRACT_VARS_FROM_LIBC($build_os)
PLATFORM_EXTRACT_VARS_FROM_ABI($build_os)
# ..and setup our own variables. (Do this explicitly to facilitate searching)
OPENJDK_BUILD_OS="$VAR_OS"
Expand All @@ -261,6 +280,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS"
OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN"
OPENJDK_BUILD_CPU_AUTOCONF="$build_cpu"
OPENJDK_BUILD_LIBC="$VAR_LIBC"
OPENJDK_BUILD_ABI="$VAR_ABI"
AC_SUBST(OPENJDK_BUILD_OS)
AC_SUBST(OPENJDK_BUILD_OS_TYPE)
Expand All @@ -270,14 +290,21 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
AC_SUBST(OPENJDK_BUILD_CPU_BITS)
AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN)
AC_SUBST(OPENJDK_BUILD_CPU_AUTOCONF)
AC_SUBST(OPENJDK_BUILD_LIBC)
AC_SUBST(OPENJDK_BUILD_ABI)

AC_MSG_CHECKING([openjdk-build os-cpu])
AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU])

# Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables.
if test "x$OPENJDK_BUILD_OS" = "xlinux"; then
AC_MSG_CHECKING([openjdk-build C library])
AC_MSG_RESULT([$OPENJDK_BUILD_LIBC])
fi

# Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU/LIBC variables.
PLATFORM_EXTRACT_VARS_FROM_OS($host_os)
PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu)
PLATFORM_EXTRACT_VARS_FROM_LIBC($host_os)
PLATFORM_EXTRACT_VARS_FROM_ABI($host_os)
# ... and setup our own variables. (Do this explicitly to facilitate searching)
OPENJDK_TARGET_OS="$VAR_OS"
Expand All @@ -297,6 +324,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN"
OPENJDK_TARGET_CPU_AUTOCONF="$host_cpu"
OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
OPENJDK_TARGET_LIBC="$VAR_LIBC"
OPENJDK_TARGET_ABI="$VAR_ABI"

AC_SUBST(OPENJDK_TARGET_OS)
Expand All @@ -308,10 +336,16 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD],
AC_SUBST(OPENJDK_TARGET_CPU_BITS)
AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN)
AC_SUBST(OPENJDK_TARGET_CPU_AUTOCONF)
AC_SUBST(OPENJDK_TARGET_LIBC)
AC_SUBST(OPENJDK_TARGET_ABI)

AC_MSG_CHECKING([openjdk-target os-cpu])
AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])

if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
AC_MSG_CHECKING([openjdk-target C library])
AC_MSG_RESULT([$OPENJDK_TARGET_LIBC])
fi
])

# Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour
Expand Down Expand Up @@ -446,7 +480,13 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
else
OPENJDK_$1_CPU_BUNDLE="$OPENJDK_$1_CPU"
fi
OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}"

OPENJDK_$1_LIBC_BUNDLE=""
if test "x$OPENJDK_$1_LIBC" = "xmusl"; then
OPENJDK_$1_LIBC_BUNDLE="-$OPENJDK_$1_LIBC"
fi

OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}${OPENJDK_$1_LIBC_BUNDLE}"
AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM)

if test "x$COMPILE_TYPE" = "xcross"; then
Expand Down Expand Up @@ -515,6 +555,9 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
fi
AC_SUBST(HOTSPOT_$1_CPU_DEFINE)

HOTSPOT_$1_LIBC=$OPENJDK_$1_LIBC
AC_SUBST(HOTSPOT_$1_LIBC)

# For historical reasons, the OS include directories have odd names.
OPENJDK_$1_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS"
if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
Expand Down Expand Up @@ -543,9 +586,11 @@ AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
RELEASE_FILE_OS_NAME="AIX"
fi
RELEASE_FILE_OS_ARCH=${OPENJDK_TARGET_CPU}
RELEASE_FILE_LIBC=${OPENJDK_TARGET_LIBC}

AC_SUBST(RELEASE_FILE_OS_NAME)
AC_SUBST(RELEASE_FILE_OS_ARCH)
AC_SUBST(RELEASE_FILE_LIBC)
])

AC_DEFUN([PLATFORM_SET_MODULE_TARGET_OS_VALUES],
Expand Down
7 changes: 7 additions & 0 deletions make/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ OPENJDK_TARGET_CPU_ARCH:=@OPENJDK_TARGET_CPU_ARCH@
OPENJDK_TARGET_CPU_BITS:=@OPENJDK_TARGET_CPU_BITS@
OPENJDK_TARGET_CPU_ENDIAN:=@OPENJDK_TARGET_CPU_ENDIAN@

OPENJDK_TARGET_LIBC:=@OPENJDK_TARGET_LIBC@

COMPILE_TYPE:=@COMPILE_TYPE@

# Legacy support
Expand All @@ -88,6 +90,8 @@ HOTSPOT_TARGET_CPU := @HOTSPOT_TARGET_CPU@
HOTSPOT_TARGET_CPU_ARCH := @HOTSPOT_TARGET_CPU_ARCH@
HOTSPOT_TARGET_CPU_DEFINE := @HOTSPOT_TARGET_CPU_DEFINE@

HOTSPOT_TARGET_LIBC := @HOTSPOT_TARGET_LIBC@

OPENJDK_TARGET_BUNDLE_PLATFORM:=@OPENJDK_TARGET_BUNDLE_PLATFORM@
JDK_ARCH_ABI_PROP_NAME := @JDK_ARCH_ABI_PROP_NAME@

Expand All @@ -102,6 +106,8 @@ OPENJDK_BUILD_CPU_ARCH:=@OPENJDK_BUILD_CPU_ARCH@
OPENJDK_BUILD_CPU_BITS:=@OPENJDK_BUILD_CPU_BITS@
OPENJDK_BUILD_CPU_ENDIAN:=@OPENJDK_BUILD_CPU_ENDIAN@

OPENJDK_BUILD_LIBC:=@OPENJDK_BUILD_LIBC@

OPENJDK_BUILD_OS_INCLUDE_SUBDIR:=@OPENJDK_TARGET_OS_INCLUDE_SUBDIR@

# Target platform value in ModuleTarget class file attribute.
Expand All @@ -110,6 +116,7 @@ OPENJDK_MODULE_TARGET_PLATFORM:=@OPENJDK_MODULE_TARGET_PLATFORM@
# OS_* properties in release file
RELEASE_FILE_OS_NAME:=@RELEASE_FILE_OS_NAME@
RELEASE_FILE_OS_ARCH:=@RELEASE_FILE_OS_ARCH@
RELEASE_FILE_LIBC:=@RELEASE_FILE_LIBC@

LIBM:=@LIBM@
LIBDL:=@LIBDL@
Expand Down
Loading