Skip to content

Commit

Permalink
Don't build universal for macOS 10.14 or later if the developer alrea…
Browse files Browse the repository at this point in the history
…dy is using OPTIM.
  • Loading branch information
michaelrsweet committed Jun 18, 2023
1 parent 2e508c8 commit ae9b9d0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 9 deletions.
38 changes: 36 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5379,33 +5379,67 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
esac
CFLAGS="$OLDCFLAGS"

case "$host_os_name" in #(
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OS-specific compiler options" >&5
printf %s "checking for OS-specific compiler options... " >&6; }
case "$host_os_name" in #(
linux*) :

# Make sure we get the full set of Linux APIs from the headers...
CPPFLAGS="$CPPFLAGS -D__USE_MISC -D_GNU_SOURCE"

# Mark read-only sections as relocatable to random addresses...
LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now"

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -D__USE_MISC -D_GNU_SOURCE -Wl,-z,relro,-z,now" >&5
printf "%s\n" "-D__USE_MISC -D_GNU_SOURCE -Wl,-z,relro,-z,now" >&6; }
;; #(
darwin*) :

# When not building for debug, target macOS 10.14 or later, "universal"
# binaries when possible...
if test "$host_os_version" -ge 200 -a x$enable_debug != xyes
if echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-arch "
then :

# Don't add architecture/min-version flags if they are already present
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
printf "%s\n" "none" >&6; }

elif echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-mmacosx-version-"
then :

# Don't add architecture/min-version flags if they are already present
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
printf "%s\n" "none" >&6; }

elif test "$host_os_version" -ge 200 -a x$enable_debug != xyes
then :

# macOS 11.0 and higher support the Apple Silicon (arm64) CPUs
OPTIM="$OPTIM -mmacosx-version-min=10.14 -arch x86_64 -arch arm64"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -mmacosx-version-min=10.14 -arch x86_64 -arch arm64" >&5
printf "%s\n" "-mmacosx-version-min=10.14 -arch x86_64 -arch arm64" >&6; }

elif test x$enable_debug != xyes
then :

OPTIM="$OPTIM -mmacosx-version-min=10.14 -arch x86_64"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -mmacosx-version-min=10.14 -arch x86_64" >&5
printf "%s\n" "-mmacosx-version-min=10.14 -arch x86_64" >&6; }

else $as_nop

# Don't add architecture/min-version flags if debug enabled
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
printf "%s\n" "none" >&6; }

fi
;; #(
*) :

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
printf "%s\n" "none" >&6; }
;; #(
*) :
;;
esac

Expand Down
30 changes: 23 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ AS_IF([test -n "$GCC"], [
CFLAGS="$CFLAGS -Wno-$warning -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
AC_MSG_RESULT(yes)
AC_MSG_RESULT([yes])
WARNINGS="$WARNINGS -Wno-$warning"
], [
AC_MSG_RESULT(no)
AC_MSG_RESULT([no])
])
CFLAGS="$OLDCFLAGS"
Expand All @@ -523,38 +523,54 @@ AS_IF([test -n "$GCC"], [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[
OLDCFLAGS="-fPIC $OLDCFLAGS"
LDFLAGS="-fPIE -Wl,-pie $LDFLAGS"
AC_MSG_RESULT(yes)
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT(no)
AC_MSG_RESULT([no])
])
], [*], [
CFLAGS="$CFLAGS -fPIC -fPIE -pie"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[
OLDCFLAGS="-fPIC $OLDCFLAGS"
LDFLAGS="-fPIE -pie $LDFLAGS"
AC_MSG_RESULT(yes)
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT(no)
AC_MSG_RESULT([no])
])
])
CFLAGS="$OLDCFLAGS"
dnl OS-specific compiler options...
AC_MSG_CHECKING([for OS-specific compiler options])
AS_CASE(["$host_os_name"], [linux*], [
# Make sure we get the full set of Linux APIs from the headers...
CPPFLAGS="$CPPFLAGS -D__USE_MISC -D_GNU_SOURCE"
# Mark read-only sections as relocatable to random addresses...
LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now"
AC_MSG_RESULT([-D__USE_MISC -D_GNU_SOURCE -Wl,-z,relro,-z,now])
], [darwin*], [
# When not building for debug, target macOS 10.14 or later, "universal"
# binaries when possible...
AS_IF([test "$host_os_version" -ge 200 -a x$enable_debug != xyes], [
AS_IF([echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-arch "], [
# Don't add architecture/min-version flags if they are already present
AC_MSG_RESULT([none])
], [echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-mmacosx-version-"], [
# Don't add architecture/min-version flags if they are already present
AC_MSG_RESULT([none])
], [test "$host_os_version" -ge 200 -a x$enable_debug != xyes], [
# macOS 11.0 and higher support the Apple Silicon (arm64) CPUs
OPTIM="$OPTIM -mmacosx-version-min=10.14 -arch x86_64 -arch arm64"
AC_MSG_RESULT([-mmacosx-version-min=10.14 -arch x86_64 -arch arm64])
], [test x$enable_debug != xyes], [
OPTIM="$OPTIM -mmacosx-version-min=10.14 -arch x86_64"
AC_MSG_RESULT([-mmacosx-version-min=10.14 -arch x86_64])
], [
# Don't add architecture/min-version flags if debug enabled
AC_MSG_RESULT([none])
])
], [*], [
AC_MSG_RESULT([none])
])
])

Expand Down

0 comments on commit ae9b9d0

Please sign in to comment.