Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 257657) +++ gcc/Makefile.in (working copy) @@ -1116,6 +1116,10 @@ endif LANG_MAKEFRAGS = @all_lang_makefrags@ +# Used by gcc/jit/Make-lang.in +LD_VERSION_SCRIPT_OPTION = @ld_version_script_option@ +LD_SONAME_OPTION = @ld_soname_option@ + # Flags to pass to recursive makes. # CC is set by configure. # ??? The choices here will need some experimenting with. Index: gcc/configure =================================================================== --- gcc/configure (revision 257657) +++ gcc/configure (working copy) @@ -680,6 +680,8 @@ zlibdir HOST_LIBS enable_default_ssp thin_archive_support +ld_soname_option +ld_version_script_option libgcc_visibility gcc_cv_readelf gcc_cv_objdump @@ -18446,7 +18448,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18449 "configure" +#line 18451 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18552,7 +18554,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18555 "configure" +#line 18557 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -24453,6 +24455,48 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_static_dynamic" >&5 $as_echo "$gcc_cv_ld_static_dynamic" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --version-script option" >&5 +$as_echo_n "checking linker --version-script option... " >&6; } +gcc_cv_ld_version_script=no +ld_version_script_option='' +if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then + gcc_cv_ld_version_script=yes + ld_version_script_option='--version-script' +elif test x$gcc_cv_ld != x; then + case "$target" in + # Solaris 2 ld always supports -M. It also supports a subset of + # --version-script since Solaris 11.4, but requires + # -z gnu-version-script-compat to activate. + *-*-solaris2*) + gcc_cv_ld_version_script=yes + ld_version_script_option='-M' + ;; + esac +fi +# Don't AC_DEFINE result, only used in jit/Make-lang.in so far. +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_version_script" >&5 +$as_echo "$gcc_cv_ld_version_script" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker soname option" >&5 +$as_echo_n "checking linker soname option... " >&6; } +gcc_cv_ld_soname=no +if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then + gcc_cv_ld_soname=yes + ld_soname_option='-soname' +elif test x$gcc_cv_ld != x; then + case "$target" in + *-*-darwin*) + gcc_cv_ld_soname=yes + ld_soname_option='-install_name' + ;; + esac +fi +# Don't AC_DEFINE result, only used in jit/Make-lang.in so far. +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_soname" >&5 +$as_echo "$gcc_cv_ld_soname" >&6; } + + if test x"$demangler_in_ld" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --demangle support" >&5 $as_echo_n "checking linker --demangle support... " >&6; } @@ -27870,6 +27914,7 @@ if test $gcc_cv_as_dwarf2_debug_view = y $as_echo "#define HAVE_AS_DWARF2_DEBUG_VIEW 1" >>confdefs.h fi + fi fi Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 257657) +++ gcc/configure.ac (working copy) @@ -3655,6 +3655,44 @@ if test x"$gcc_cv_ld_static_dynamic" = x fi AC_MSG_RESULT($gcc_cv_ld_static_dynamic) +AC_MSG_CHECKING(linker --version-script option) +gcc_cv_ld_version_script=no +ld_version_script_option='' +if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then + gcc_cv_ld_version_script=yes + ld_version_script_option='--version-script' +elif test x$gcc_cv_ld != x; then + case "$target" in + # Solaris 2 ld always supports -M. It also supports a subset of + # --version-script since Solaris 11.4, but requires + # -z gnu-version-script-compat to activate. + *-*-solaris2*) + gcc_cv_ld_version_script=yes + ld_version_script_option='-M' + ;; + esac +fi +# Don't AC_DEFINE result, only used in jit/Make-lang.in so far. +AC_MSG_RESULT($gcc_cv_ld_version_script) +AC_SUBST(ld_version_script_option) + +AC_MSG_CHECKING(linker soname option) +gcc_cv_ld_soname=no +if test $in_tree_ld = yes || test x"$gnu_ld" = xyes; then + gcc_cv_ld_soname=yes + ld_soname_option='-soname' +elif test x$gcc_cv_ld != x; then + case "$target" in + *-*-darwin*) + gcc_cv_ld_soname=yes + ld_soname_option='-install_name' + ;; + esac +fi +# Don't AC_DEFINE result, only used in jit/Make-lang.in so far. +AC_MSG_RESULT($gcc_cv_ld_soname) +AC_SUBST(ld_soname_option) + if test x"$demangler_in_ld" = xyes; then AC_MSG_CHECKING(linker --demangle support) gcc_cv_ld_demangle=no Index: gcc/jit/Make-lang.in =================================================================== --- gcc/jit/Make-lang.in (revision 257657) +++ gcc/jit/Make-lang.in (working copy) @@ -51,6 +51,19 @@ LIBGCCJIT_FILENAME = \ LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME) LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME) +# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and +# LD_SONAME_OPTION depending if configure found them, using $(if) +# We have to define a COMMA here, otherwise the commas in the "true" +# result are treated as separators by the $(if). +COMMA := , +LIBGCCJIT_VERSION_SCRIPT_OPTION = \ + $(if $(LD_VERSION_SCRIPT_OPTION),\ + -Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map) + +LIBGCCJIT_SONAME_OPTION = \ + $(if $(LD_SONAME_OPTION), \ + -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME)) + jit: $(LIBGCCJIT_FILENAME) \ $(LIBGCCJIT_SYMLINK) \ $(LIBGCCJIT_LINKER_NAME_SYMLINK) \ @@ -85,8 +98,8 @@ $(LIBGCCJIT_FILENAME): $(jit_OBJS) \ $(jit_OBJS) libbackend.a libcommon-target.a libcommon.a \ $(CPPLIB) $(LIBDECNUMBER) $(LIBS) $(BACKENDLIBS) \ $(EXTRA_GCC_OBJS) \ - -Wl,--version-script=$(srcdir)/jit/libgccjit.map \ - -Wl,-soname,$(LIBGCCJIT_SONAME) + $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \ + $(LIBGCCJIT_SONAME_OPTION) $(LIBGCCJIT_SONAME_SYMLINK): $(LIBGCCJIT_FILENAME) ln -sf $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)