From patchwork Wed Jul 4 09:35:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 939212 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=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-93956-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="t93HBIzo"; 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 41LG8l35r2z9s1b for ; Wed, 4 Jul 2018 19:36:39 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= ElTkhd/Lq8f1CdysaokYb+Amx/Jm2qQgpiR5cvRCuWz+Aesx/baVJ1PVk/ZfnVdZ kD/f++EAPO/E3WgmUpda3WNIcpEmBs0O0z69K1Jj0wdTfp4J9ASEV4zmwLku9//3 jt5hzR+ZfTHfxknRxvZ5/p0FGO9CaesUmpxjlDRGZYA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=p/6VXj h+d/DKbvKeBABY6m1uSnY=; b=t93HBIzoIOuISq/a/AYVSyRSaRzrKiBZeFoXdY D7UKxz48ENCMG6wYQkH81jF3Dkx4pR6rIsyP9u94RP4oKo/7wfyyANTIhnl9ZhfS apD3wG9HacfedqEvfdJ5JC5mi05XV3CmvCaDma1gvN7BIMTFv6qkgvY5UhG9wzP+ L3DJE= Received: (qmail 14754 invoked by alias); 4 Jul 2018 09:36:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 14526 invoked by uid 89); 4 Jul 2018 09:36:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=ar, influential, 33366, 3336, 6 X-HELO: mx1.redhat.com Date: Wed, 04 Jul 2018 11:35:57 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] Add --with-nonshared-cflags option to configure User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20180704093557.3723F43994575@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2018-07-04 Florian Weimer * configure.ac: Add --with-nonshared-cflags option. * config.make.in (extra-nonshared-cflags): Set variable. * Makeconfig (CFLAGS-.oS): Use it. * manual/install.texi (Configuring and compiling): Document --with-nonshared-cflags. * configure: Regenerate. * INSTALL: Likewise. Reviewed-by: Carlos O'Donell diff --git a/INSTALL b/INSTALL index 0a22aa7d01..0f80d9d615 100644 --- a/INSTALL +++ b/INSTALL @@ -90,6 +90,15 @@ if 'CFLAGS' is specified it must enable optimization. For example: library will still be usable, but functionality may be lost--for example, you can't build a shared libc with old binutils. +'--with-nonshared-cflags=CFLAGS' + Use additional compiler flags CFLAGS to build the parts of the + library which are always statically linked into applications and + libraries even with shared linking (that is, the object files + contained in 'lib*_nonshared.a' libraries). The build process will + automatically use the appropriate flags, but this option can be + used to set additional flags required for building applications and + libraries, to match local policy. + '--disable-shared' Don't build shared libraries even if it is possible. Not all systems support shared libraries; you need ELF support and diff --git a/Makeconfig b/Makeconfig index 608ffe648c..b0b27f0113 100644 --- a/Makeconfig +++ b/Makeconfig @@ -1038,7 +1038,7 @@ object-suffixes-for-libc += .oS # Must build the routines as PIC, though, because they can end up in (users') # shared objects. We don't want to use CFLAGS-os because users may, for # example, make that processor-specific. -CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) +CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags) CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1 libtype.oS = lib%_nonshared.a endif diff --git a/config.make.in b/config.make.in index d9891b2cd8..a6fe48d31f 100644 --- a/config.make.in +++ b/config.make.in @@ -110,6 +110,7 @@ BUILD_CC = @BUILD_CC@ CFLAGS = @CFLAGS@ CPPFLAGS-config = @CPPFLAGS@ CPPUNDEFS = @CPPUNDEFS@ +extra-nonshared-cflags = @extra_nonshared_cflags@ ASFLAGS-config = @ASFLAGS_config@ AR = @AR@ NM = @NM@ diff --git a/configure b/configure index ef18302215..fec0efff82 100755 --- a/configure +++ b/configure @@ -684,6 +684,7 @@ force_install bindnow hardcoded_path_in_tests enable_timezone_tools +extra_nonshared_cflags use_default_link sysheaders ac_ct_CXX @@ -762,6 +763,7 @@ with_binutils with_selinux with_headers with_default_link +with_nonshared_cflags enable_sanity_checks enable_shared enable_profile @@ -1479,6 +1481,8 @@ Optional Packages: --with-headers=PATH location of system headers to use (for example /usr/src/linux/include) [default=compiler default] --with-default-link do not use explicit linker scripts + --with-nonshared-cflags=FLAGS + build nonshared libraries with additional FLAGS --with-cpu=CPU select code for CPU variant Some influential environment variables: @@ -3336,6 +3340,16 @@ else fi + +# Check whether --with-nonshared-cflags was given. +if test "${with_nonshared_cflags+set}" = set; then : + withval=$with_nonshared_cflags; extra_nonshared_cflags=$withval +else + extra_nonshared_cflags= +fi + + + # Check whether --enable-sanity-checks was given. if test "${enable_sanity_checks+set}" = set; then : enableval=$enable_sanity_checks; enable_sanity=$enableval diff --git a/configure.ac b/configure.ac index dc517017f5..154185d70d 100644 --- a/configure.ac +++ b/configure.ac @@ -154,6 +154,14 @@ AC_ARG_WITH([default-link], [use_default_link=$withval], [use_default_link=default]) +dnl Additional build flags injection. +AC_ARG_WITH([nonshared-cflags], + AC_HELP_STRING([--with-nonshared-cflags=FLAGS], + [build nonshared libraries with additional FLAGS]), + [extra_nonshared_cflags=$withval], + [extra_nonshared_cflags=]) +AC_SUBST(extra_nonshared_cflags) + AC_ARG_ENABLE([sanity-checks], AC_HELP_STRING([--disable-sanity-checks], [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]), diff --git a/manual/install.texi b/manual/install.texi index 422da1447e..eaf0cd09e7 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -117,6 +117,15 @@ problem and suppress these constructs, so that the library will still be usable, but functionality may be lost---for example, you can't build a shared libc with old binutils. +@item --with-nonshared-cflags=@var{cflags} +Use additional compiler flags @var{cflags} to build the parts of the +library which are always statically linked into applications and +libraries even with shared linking (that is, the object files contained +in @file{lib*_nonshared.a} libraries). The build process will +automatically use the appropriate flags, but this option can be used to +set additional flags required for building applications and libraries, +to match local policy. + @c disable static doesn't work currently @c @item --disable-static @c Don't build static libraries. Static libraries aren't that useful these