From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by sourceware.org (Postfix) with ESMTPS id F3FBB3858D39; Fri, 1 Jul 2022 08:41:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F3FBB3858D39 Received: by mail-qk1-x733.google.com with SMTP id b24so1367762qkn.4; Fri, 01 Jul 2022 01:41:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uw0GE8lcX9mu6Wo2clm3kqNqqOxHrj9oenyX6xnJHnY=; b=7j1zA/nyCKDdJsBBZtvYXve/J7Y7xX760jq4oZSM1myaI+7A01XhECGnIePLBiL/YX xku6D1TO8xibHDdUwPstzYe+S7OvfssGiL2S7ed2ppfwdAX//vd9hNdKbH9KSWZpZgOD HG1fJ9SfwCeL7BqpExEHwi68PXIOwyFZGs+7E6tbsU+6ZqICfDhpp1JlhII0L8Nh0CyK oEUmC7FKZNqnwQ8CjUBJS8+S1ZJHfpujOLdFhBtygzkR3GI1A42iy6uPpVPmeZwM7NzL PqHrLWNJTIZm3aBQAbbd2qK5jhcrjWY6Ctdtl+LHRjfbF3o/l8P9QtlGIFLudQdTfM4U DGwQ== X-Gm-Message-State: AJIora9XDRZVws3hPdmWyJCypnNVyVdiZYOshEiUTqWucU7UOvTlH4XV atBqeDhwTNLFRMkj2GCo4jsrSvBQg7JjDW4HJMc= X-Google-Smtp-Source: AGRyM1tI4Ns44gTwCfQsCMn6Px5uT8SlGQ7xTExh2mmjtL8EbIxlaNxhDc1aqPnPOha2HUcdX6qo9GMWiLpawdiDse0= X-Received: by 2002:a05:620a:4103:b0:6b1:43c9:467b with SMTP id j3-20020a05620a410300b006b143c9467bmr9318499qko.4.1656664879340; Fri, 01 Jul 2022 01:41:19 -0700 (PDT) MIME-Version: 1.0 References: <20220626152710.99667-1-iain@sandoe.co.uk> In-Reply-To: <20220626152710.99667-1-iain@sandoe.co.uk> From: Richard Biener Date: Fri, 1 Jul 2022 10:41:08 +0200 Message-ID: Subject: Re: [PATCH] configure: When host-shared, pass --with-pic to in-tree lib configs. To: Iain Sandoe Cc: GCC Patches , Iain Sandoe , Bruno Haible , Alexandre Oliva Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jul 2022 08:41:22 -0000 On Sun, Jun 26, 2022 at 5:28 PM Iain Sandoe via Gcc-patches wrote: > > If we are building PIC/PIE host executables, and we are building dependent > libs (e.g. GMP) in-tree those libs need to be configured to generate PIC code. > > At present, if an --enable-host-shared build is attempted on ELF platforms, > with in-tree dependents, the build will fail with incompatible relocations. > One can append --with-pic to the configure, but then that is applied everywhere > not just on the libraries that need it. > > Tested on x86_64-linux-gnu "--enable-host-shared" and compared with an > "--enable-host-shared --with-pic" version, > > OK for master? > comments? Looks reasonable to me, so go ahead (for trunk). Richard. > thanks > Iain > > Signed-off-by: Iain Sandoe > > ChangeLog: > > * Makefile.def: Pass host_libs_picflag to host dependent library > configures. > * Makefile.in: Regenerate. > * configure: Regenerate. > * configure.ac (host_libs_picflag): New configure variable set to > '--with-pic' when building 'host_shared'. > --- > Makefile.def | 15 +++--- > Makefile.in | 140 +++++++++++++++++++++++++-------------------------- > configure | 11 ++++ > configure.ac | 10 ++++ > 4 files changed, 99 insertions(+), 77 deletions(-) > > diff --git a/Makefile.def b/Makefile.def > index 72d58549645..92239aebb57 100644 > --- a/Makefile.def > +++ b/Makefile.def > @@ -50,7 +50,7 @@ host_modules= { module= gcc; bootstrap=true; > extra_make_flags="$(EXTRA_GCC_FLAGS)"; }; > host_modules= { module= gmp; lib_path=.libs; bootstrap=true; > // Work around in-tree gmp configure bug with missing flex. > - extra_configure_flags='--disable-shared LEX="touch lex.yy.c"'; > + extra_configure_flags='--disable-shared LEX="touch lex.yy.c" @host_libs_picflag@'; > extra_make_flags='AM_CFLAGS="-DNO_ASM"'; > no_install= true; > // none-*-* disables asm optimizations, bootstrap-testing > @@ -60,21 +60,22 @@ host_modules= { module= gmp; lib_path=.libs; bootstrap=true; > // different from host for target. > target="none-${host_vendor}-${host_os}"; }; > host_modules= { module= mpfr; lib_path=src/.libs; bootstrap=true; > - extra_configure_flags='--disable-shared @extra_mpfr_configure_flags@'; > + extra_configure_flags='--disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@'; > extra_make_flags='AM_CFLAGS="-DNO_ASM"'; > no_install= true; }; > host_modules= { module= mpc; lib_path=src/.libs; bootstrap=true; > - extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode'; > + extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ @host_libs_picflag@ --disable-maintainer-mode'; > no_install= true; }; > host_modules= { module= isl; lib_path=.libs; bootstrap=true; > - extra_configure_flags='--disable-shared @extra_isl_gmp_configure_flags@'; > + extra_configure_flags='--disable-shared @extra_isl_gmp_configure_flags@ @host_libs_picflag@'; > extra_make_flags='V=1'; > no_install= true; }; > host_modules= { module= libelf; lib_path=.libs; bootstrap=true; > - extra_configure_flags='--disable-shared'; > + extra_configure_flags='--disable-shared @host_libs_picflag@'; > no_install= true; }; > host_modules= { module= gold; bootstrap=true; }; > host_modules= { module= gprof; }; > +// intl acts on 'host_shared' directly, and does not support --with-pic. > host_modules= { module= intl; bootstrap=true; }; > host_modules= { module= tcl; > missing=mostlyclean; }; > @@ -110,7 +111,7 @@ host_modules= { module= libiberty-linker-plugin; bootstrap=true; > // We abuse missing to avoid installing anything for libiconv. > host_modules= { module= libiconv; > bootstrap=true; > - extra_configure_flags='--disable-shared'; > + extra_configure_flags='--disable-shared @host_libs_picflag@'; > no_install= true; > missing= pdf; > missing= html; > @@ -125,7 +126,7 @@ host_modules= { module= sim; }; > host_modules= { module= texinfo; no_install= true; }; > host_modules= { module= zlib; no_install=true; no_check=true; > bootstrap=true; > - extra_configure_flags='@extra_host_zlib_configure_flags@';}; > + extra_configure_flags='@extra_host_zlib_configure_flags@ @host_libs_picflag@';}; > host_modules= { module= gnulib; }; > host_modules= { module= gdbsupport; }; > host_modules= { module= gdbserver; }; > > diff --git a/configure.ac b/configure.ac > index dcea067759d..09958bd7782 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1928,8 +1928,18 @@ AC_ARG_ENABLE(host-shared, > x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;; > *) host_shared=no ;; > esac]) > + > AC_SUBST(host_shared) > > +# If we are building PIC/PIE host executables, and we are building dependent > +# libs (e.g. GMP) in-tree those libs need to be configured to generate PIC > +# code. > +host_libs_picflag= > +if test "$host_shared" = "yes";then > +host_libs_picflag='--with-pic' > +fi > +AC_SUBST(host_libs_picflag) > + > # By default, C and C++ are the only stage 1 languages. > stage1_languages=,c, > > -- > 2.24.3 (Apple Git-128) >