From: David Malcolm <dmalcolm@redhat.com>
To: FX <fxcoudert@gmail.com>,
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>,
gcc-patches@gcc.gnu.org, jit@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH] jit: fix link on OS X and Solaris (PR jit/64089 and PR jit/84288)
Date: Mon, 01 Jan 2018 00:00:00 -0000 [thread overview]
Message-ID: <1518556781-10049-1-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <78D7B2DA-5677-4211-9C4E-F7B1B5AB51B5@gmail.com>
libgccjit fails to link on OS X and Solaris due to jit/Make-lang.in,
due to the assumption there that the linker is GNU ld. Specifically,
jit/Make-lang.in hardcodes the use of two options: --version-script
and -soname.
* on Darwin, --version-script doesn't seem to exist in the linker, and
it uses -install_name rather than -soname.
* on Solaris, ld doesn't support --version-script. However, the version
script used for libgccjit.so doesn't use any gld extensions, so one can
just use -M instead.
This patch fixes these issues by using variables emitted by gcc's "configure"
rather than hardcoding the options in jit/Make-lang.in.
It's based on the first part of Rainer's patch for PR jit/84288, but I
made the following changes:
* the GNU ld case in configure.ac wasn't setting ld_version_script_option.
I set it to "--version-script" for that case.
* I moved the:
LD_VERSION_SCRIPT_OPTION = @ld_version_script_option@
from gcc/jit/Make-lang.in to gcc/Makefile.in, as the Make-lang.in files
aren't substituted, only the gcc/Makefile.in.
Rainer: how did this work for you?
* added LD_SONAME_OPTION, done in the same way
* conditionalized the usage of the options in Make-lang.in to cope with
empty LD_VERSION_SCRIPT_OPTION (as is presumably the case on OS X).
I used ($if condition,then-part[,else-part]) for this.
I had to add a $(COMMA) since the "then-part" contains commas, which
need to be treated as part of the "then-part", rather than separators
for the "else-part".
Hopefully this is compatible with every "make" implementation that we
support.
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
I lightly tested the not-recognized case by hacking up the configure.ac
(on x86_64-pc-linux-gnu) and verifying that it links, and that a
smoketest of jit.dg/test-factorial works.
Does this fix the jit linker issues on OS X and Solaris?
(I didn't include the autogenerate configure changes)
gcc/ChangeLog:
PR jit/64089
PR jit/84288
* Makefile.in (LD_VERSION_SCRIPT_OPTION, LD_SONAME_OPTION): New.
* configure: Regenerate.
* configure.ac ("linker --version-script option"): New.
("linker soname option"): New.
gcc/jit/ChangeLog:
PR jit/64089
PR jit/84288
* Make-lang.in (COMMA): New.
(LIBGCCJIT_VERSION_SCRIPT_OPTION): New.
(LIBGCCJIT_SONAME_OPTION): New.
(jit): Move --version-script and -soname linker options to the
above.
---
gcc/Makefile.in | 4 ++++
gcc/configure.ac | 38 ++++++++++++++++++++++++++++++++++++++
gcc/jit/Make-lang.in | 17 +++++++++++++++--
3 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 6c37e46..903da58 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -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.
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b7f9728..265920c 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3640,6 +3640,44 @@ if test x"$gcc_cv_ld_static_dynamic" = xyes; then
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='--version-script'
+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
diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index d4362a9..ba78f8e 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -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)
--
1.8.5.3
next parent reply other threads:[~2018-02-13 21:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <78D7B2DA-5677-4211-9C4E-F7B1B5AB51B5@gmail.com>
2018-01-01 0:00 ` David Malcolm [this message]
2018-01-01 0:00 ` Rainer Orth
2018-01-01 0:00 ` Rainer Orth
2018-01-01 0:00 ` FX
2018-01-01 0:00 ` FX
2018-01-01 0:00 ` Seeking Release Manager approval for: " David Malcolm
2018-01-01 0:00 ` Rainer Orth
2018-01-01 0:00 ` David Malcolm
2018-01-01 0:00 ` Rainer Orth
2018-01-01 0:00 ` David Malcolm
2018-01-01 0:00 ` Richard Biener
2018-01-01 0:00 ` Jakub Jelinek
2018-01-01 0:00 ` FX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1518556781-10049-1-git-send-email-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=fxcoudert@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jit@gcc.gnu.org \
--cc=ro@CeBiTec.Uni-Bielefeld.DE \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).