From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 9E25B3858297; Sun, 26 Jun 2022 15:27:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9E25B3858297 Received: by mail-wm1-x32a.google.com with SMTP id n185so3945869wmn.4; Sun, 26 Jun 2022 08:27:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :mime-version:content-transfer-encoding; bh=gM5sfBOCchFArLUne+oQ79aiIgLqS2XTBg05+d7CTNc=; b=uSXLAE519TkoInJiw1hioywBZ3nAaRxm7y30NZJSr+Hra/sHhL7v0/zB0W9rFIcITW /hWpiBLhhe1Qe4ojf6zBWnbRdHVGw4+WdWZH8nXzegsx0546RstbzrlWGZ8/AU3os7Fx hBuTBZ78io5PQQ+tKWaVRd8TWhC2ISdNdkD+7P9klbZ2XpJalCZdqq54VByQ4S+yMm5m SlE750FDhHX1LFuG3W2Ox8TCJX5Dr3aQhcGlr6g3siRE+pnhfefD3z8vEowZfenCnfQf 8HwQS4gK3Un9UbF2DtvFaC2LeI7AUCJZ/ZKBsPwis6OBzeJ+UsAcFPDhtO+pnVEC8Y4R SfrA== X-Gm-Message-State: AJIora+gSRM8LQuuWLPTALzo9/NBnxcjWWKQRzbof7B1s4gpk/rNB0SG E8K/EJbgx1+ksoTlamJ461q667jwkNY= X-Google-Smtp-Source: AGRyM1uwWGR/L827Cann8sNPvVDExnj3nJ6K1SPoebnRW8iifCIajfCIvjCdlb/yaRyFLy8fYoxyCg== X-Received: by 2002:a05:600c:6020:b0:39c:96ec:5014 with SMTP id az32-20020a05600c602000b0039c96ec5014mr15413170wmb.57.1656257237307; Sun, 26 Jun 2022 08:27:17 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id i129-20020a1c3b87000000b0039c54bb28f2sm10019024wma.36.2022.06.26.08.27.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jun 2022 08:27:16 -0700 (PDT) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: aoliva@gcc.gnu.org, bruno@clisp.org Subject: [PATCH] configure: When host-shared, pass --with-pic to in-tree lib configs. Date: Sun, 26 Jun 2022 16:27:10 +0100 Message-Id: <20220626152710.99667-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) Reply-To: iain@sandoe.co.uk MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 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: Sun, 26 Jun 2022 15:27:22 -0000 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? 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)