From patchwork Tue Feb 13 21:19:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 873178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-473208-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cmkm3jzf"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zgwK71d71z9t34 for ; Wed, 14 Feb 2018 08:14:32 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=XRzlUFuKD8ZEo1dqY5ZqvyD8FiA/PoF6HRgBKpBRWwIniOTETT99b NVKOiB7Lgghm/Pyh0Ke/sUI4CbKT/Hu0+2hX8tO+LfLL69jAT9WY9Yu489V/JLZ7 YxhU9NKbj1UxH3EVKAhy+PgsJOkHyN1nTNgGrZFkruusXnG9RWSAD4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=/TARfXE5rCIDdV2X4mzvwV1QDZg=; b=cmkm3jzftoSogTNPbVye dMnu5Ln0aA82POk0JQJEG5LdrALNvLsX8LR0wibLBcbPN9MhvUCtV8c42INk2t4h eEVezECo1vcmPN7pc6/XcwfWkvCKj7H0ol9y1oVOCrrM9RnvhwAPjFtSvfdRAA16 4NCV6A/XdnDEVrt3dVGnvX4= Received: (qmail 128229 invoked by alias); 13 Feb 2018 21:14:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 128206 invoked by uid 89); 13 Feb 2018 21:14:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=wl, Wl, Hx-languages-length:5931, lightly X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Feb 2018 21:14:17 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6A746E766; Tue, 13 Feb 2018 21:14:15 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-12.phx2.redhat.com [10.3.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64CAD5D9C5; Tue, 13 Feb 2018 21:14:14 +0000 (UTC) From: David Malcolm To: FX , Rainer Orth , gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] jit: fix link on OS X and Solaris (PR jit/64089 and PR jit/84288) Date: Tue, 13 Feb 2018 16:19:41 -0500 Message-Id: <1518556781-10049-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: <78D7B2DA-5677-4211-9C4E-F7B1B5AB51B5@gmail.com> References: <78D7B2DA-5677-4211-9C4E-F7B1B5AB51B5@gmail.com> X-IsSubscribed: yes 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)