Use -fobjec-runtime=gcc for targetting the gnu/gcc runtime ABI

This commit is contained in:
Richard Frith-Macdonald 2018-07-10 10:46:40 +01:00
parent 789fa92246
commit 14a1d33b46
6 changed files with 70 additions and 45 deletions

View file

@ -1,3 +1,14 @@
2018-07-10 Richard Frith-Macdonald <rfm@gnu.org>
* config.make.in:
* configure:
* configure.ac:
* library-combo.make:
* target.make:
Change to use -fobjc-runtime=gcc when building with clang but
targetting the gnu/gcc runtime ABI. Suggested by David as the
correct way to tell clang what runtime it should be targetting.
2018-07-09 Richard Frith-Macdonald <rfm@gnu.org>
* Documentation/library-combo.7:

View file

@ -57,6 +57,8 @@ ifeq ($(CXX),)
CXX = @CXX@
endif
CLANG_CC = @CLANG_CC@
# TODO: Because of the following, OPTFLAG usually ends up being '-g
# -O2'. The '-g' is fairly harmless as you can always use strip=yes
# which will strip the object files upon installation; still, it's not

49
configure vendored
View file

@ -608,12 +608,12 @@ SOLARIS_SHARED
GCC_WITH_PRECOMPILED_HEADERS
AUTO_DEPENDENCIES
USE_OBJC_EXCEPTIONS
CLANG_CC
OBJ_MERGE_CMD_FLAG
USE_ARC
OBJCXX
ac_cv_objc_threaded
objc_threaded
CLANG_CC
OBJC_LIB_FLAG
cc_gnuruntime
GNUSTEP_INSTALL_LD_SO_CONF
@ -5542,8 +5542,8 @@ fi
# Special case for Apple systems: When compiling plain C source files that
# include Objective-C runtime headers we must make sure that the correct
# header files are used with a gnu-*-* combo. The -fgnu-runtime compiler
# option takes care of this when compiling Objective-C source files, but
# header files are used with a gnu-*-* combo. The -fobjc-runtime=gcc compiler
# option should take care of this when compiling Objective-C source files, but
# has no effect when compiling plain C (or C++) source files.
cc_gnuruntime=
case $target_os-$ac_cv_library_combo in
@ -5587,11 +5587,33 @@ fi
# But we need to compute, and print out, what flag we're using now.
OBJC_FINAL_LIB_FLAG="$OBJC_LIB_FLAG"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler is clang" >&5
$as_echo_n "checking whether the compiler is clang... " >&6; }
if test ! x"${GCC}" = x"yes" ; then
CLANG_CC=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else
if "${CC}" -v 2>&1 | grep -q 'clang version'; then
CLANG_CC=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
CLANG_CC=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
saved_CFLAGS="$CFLAGS"
saved_LIBS="$LIBS"
CFLAGS="$CFLAGS -x objective-c -I$srcdir $OBJC_CPPFLAGS $OBJC_LDFLAGS"
if test "$OBJC_RUNTIME_LIB" = "gnu"; then
CFLAGS="$CFLAGS -fgnu-runtime -DGNU_RUNTIME"
if test x"$CLANG_CC" = x"yes"; then
CFLAGS="$CFLAGS -fobjc-runtime=gcc"
fi
CFLAGS="$CFLAGS -DGNU_RUNTIME"
if test "$OBJC_FINAL_LIB_FLAG" = ""; then
OBJC_FINAL_LIB_FLAG=-lobjc
fi
@ -6158,25 +6180,6 @@ else
$as_echo "version: ${gs_cv_gcc_parsed_version}" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler is clang" >&5
$as_echo_n "checking whether the compiler is clang... " >&6; }
if test ! x"${GCC}" = x"yes" ; then
CLANG_CC=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else
if "${CC}" -v 2>&1 | grep -q 'clang version'; then
CLANG_CC=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
CLANG_CC=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
# Do not restore LIBS and CFLAGS yet as we need to test if the
# compiler supports native exceptions.

View file

@ -1175,8 +1175,8 @@ fi
# Special case for Apple systems: When compiling plain C source files that
# include Objective-C runtime headers we must make sure that the correct
# header files are used with a gnu-*-* combo. The -fgnu-runtime compiler
# option takes care of this when compiling Objective-C source files, but
# header files are used with a gnu-*-* combo. The -fobjc-runtime=gcc compiler
# option should take care of this when compiling Objective-C source files, but
# has no effect when compiling plain C (or C++) source files.
cc_gnuruntime=
case $target_os-$ac_cv_library_combo in
@ -1221,11 +1221,29 @@ AC_SUBST(OBJC_LIB_FLAG)
# But we need to compute, and print out, what flag we're using now.
OBJC_FINAL_LIB_FLAG="$OBJC_LIB_FLAG"
AC_MSG_CHECKING(whether the compiler is clang)
if test ! x"${GCC}" = x"yes" ; then
CLANG_CC=no
AC_MSG_RESULT(no)
else
if "${CC}" -v 2>&1 | grep -q 'clang version'; then
CLANG_CC=yes
AC_MSG_RESULT(yes)
else
CLANG_CC=no
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(CLANG_CC)
saved_CFLAGS="$CFLAGS"
saved_LIBS="$LIBS"
CFLAGS="$CFLAGS -x objective-c -I$srcdir $OBJC_CPPFLAGS $OBJC_LDFLAGS"
if test "$OBJC_RUNTIME_LIB" = "gnu"; then
CFLAGS="$CFLAGS -fgnu-runtime -DGNU_RUNTIME"
if test x"$CLANG_CC" = x"yes"; then
CFLAGS="$CFLAGS -fobjc-runtime=gcc"
fi
CFLAGS="$CFLAGS -DGNU_RUNTIME"
if test "$OBJC_FINAL_LIB_FLAG" = ""; then
OBJC_FINAL_LIB_FLAG=-lobjc
fi
@ -1533,21 +1551,6 @@ else
AC_MSG_RESULT(version: ${gs_cv_gcc_parsed_version})
fi
AC_MSG_CHECKING(whether the compiler is clang)
if test ! x"${GCC}" = x"yes" ; then
CLANG_CC=no
AC_MSG_RESULT(no)
else
if "${CC}" -v 2>&1 | grep -q 'clang version'; then
CLANG_CC=yes
AC_MSG_RESULT(yes)
else
CLANG_CC=no
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(CLANG_CC)
# Do not restore LIBS and CFLAGS yet as we need to test if the
# compiler supports native exceptions.

View file

@ -31,7 +31,11 @@ ifeq ($(OBJC_RUNTIME_LIB), gnu)
OBJC_LDFLAGS =
OBJC_LIB_DIR =
OBJC_LIBS = $(OBJC_LIB_FLAG)
RUNTIME_FLAG = -fgnu-runtime
ifeq ($(CLANG_CC), yes)
RUNTIME_FLAG = -fobjc-runtime=gcc
else
RUNTIME_FLAG =
endif
RUNTIME_DEFINE = -DGNU_RUNTIME=1
endif

View file

@ -249,7 +249,7 @@ ifeq ($(OBJC_RUNTIME_LIB), gnu)
# Make sure that the compiler includes the right Objective-C runtime headers
# when compiling plain C source files. When compiling Objective-C source files
# the necessary directory is implicitly added by the -fgnu-runtime option, but
# the necessary directory should be added by the -fobjc-runtime=gcc option, but
# this option is ignored when compiling plain C files.
ifneq ($(strip $(CC_GNURUNTIME)),)
INTERNAL_CFLAGS += -isystem $(CC_GNURUNTIME)
@ -280,8 +280,10 @@ SHARED_LIB_LINK_CMD = \
$(LN_S) $(LIB_LINK_VERSION_FILE) $(LIB_LINK_FILE))
BUNDLE_LD = $(LD)
BUNDLE_LDFLAGS += -fgnu-runtime -bundle
BUNDLE_LDFLAGS += -undefined dynamic_lookup
ifeq ($(CLANG_CC), yes)
BUNDLE_LDFLAGS += -fobjc-runtime=gcc
endif
BUNDLE_LDFLAGS += -bundle -undefined dynamic_lookup
else
# Apple runtime