From patchwork Tue Mar 9 20:59:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Seo X-Patchwork-Id: 42408 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D07B3846416; Tue, 9 Mar 2021 20:59:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D07B3846416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1615323565; bh=KWegIwPCiAJ+esfn1qJ2Z8qkih92okgtFkPjSknbD2o=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fo7ldEQIu/48Sm4DwDXsx38Sa0Gsr0lgSVcovfnlTCVQfHyq/k0dpZHiMO+VeF+Vs 3T2a3Q37OSmfe/LY5+ZCPD/iaxb0qGW7HxXmfW5xkCqKMW5t9SClO2VaBM9KWnFz2x cFIG6mLxXhHT9m5JOL8+QoivOryWzYSeTSIe5nKU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by sourceware.org (Postfix) with ESMTPS id 955433858039 for ; Tue, 9 Mar 2021 20:59:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 955433858039 Received: by mail-qt1-x830.google.com with SMTP id l14so8598264qtr.10 for ; Tue, 09 Mar 2021 12:59:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=KWegIwPCiAJ+esfn1qJ2Z8qkih92okgtFkPjSknbD2o=; b=Ivby7njGfcZRXZy7RRn6dIfsmMJ7u9D/nGlVKZeppyAVYBXRBkr0k48ijMS/kdivOW i0ZXqFkVTeQ3MM1/6DCrmu3X1jGgVlEAeO/hLiduyNcuCF3AfnY5OmkiGhl+P5O0zn5m 6/3Qc/DnBq5Vp7SgK0E9UI6y9vbb7ugReDpB9CCeAzGJuz8Efd/JYmp47skl1I7pH6bd UqXzm4MSgNP/VLDNjbhYTNdmbRh5nY4k0uE8FOrUK7pgYlhBFGVBHxLyXwWxECX9eb9N XROWT0tbbw714OhJnhusz48EFPZDEs0E67PS/xjHo+zj0U+zHakNmxYVQCOQw73s6nWx jmJw== X-Gm-Message-State: AOAM5329M/1XsoUM0kWFlQkyDk1r6k8H87XF1g3T+zgqfCrkCnZPhM6Q aN95W3UljiN/BBUQ/vPWTc06tK0TkMWr/Nui X-Google-Smtp-Source: ABdhPJzva0iJQXJ1LXNFS6OabYKRgZcbFeAtC/XmeQwQkpiNIarCF5Vt1BzJuNSncIuJh1cYbeUhNg== X-Received: by 2002:aed:3165:: with SMTP id 92mr27152787qtg.233.1615323560671; Tue, 09 Mar 2021 12:59:20 -0800 (PST) Received: from localhost.localdomain ([2804:14c:31:80a8:4c0c:36bf:b6de:42dd]) by smtp.gmail.com with ESMTPSA id h8sm4452204qkk.116.2021.03.09.12.59.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 12:59:20 -0800 (PST) To: libc-alpha@sourceware.org Subject: [RFC] Fix static-only build of glibc [BZ #20845] Date: Tue, 9 Mar 2021 17:59:16 -0300 Message-Id: <20210309205916.74906-1-carlos.seo@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Carlos Eduardo Seo via Libc-alpha From: Carlos Seo Reply-To: Carlos Eduardo Seo Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The following patch fixes the build when configuring with '--disable-shared'. However, a second phase for properly fixing this will be required, as the tests need to be triaged (i.e. what should be running and what should not when building with --disable-shared). My proposal is to first fix the build (this patch) and then start looking at the tests and fixing those in subsequent patches. Does that sound reasonable? Thanks, Carlos --- >8 --- This fixes the build when configuring with --disable-shared. 'make' passes on x86_64-linux-gnu, aarch64-linux-gnu and powerpc64le-linux-gnu. --- Makeconfig | 5 +--- Makefile | 4 +++ Makerules | 8 +++--- include/shlib-compat.h | 34 +++++++++++++----------- nscd/nscd.c | 2 +- nss/nss_module.c | 3 +++ support/Makefile | 4 +++ sysdeps/unix/sysv/linux/aarch64/Makefile | 2 -- sysdeps/unix/sysv/linux/powerpc/Makefile | 2 -- 9 files changed, 37 insertions(+), 27 deletions(-) diff --git a/Makeconfig b/Makeconfig index 0a4811b5e5..b884de1d77 100644 --- a/Makeconfig +++ b/Makeconfig @@ -1092,8 +1092,6 @@ subdir-srcdirs = $(foreach dir,$(subdirs),\ sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T mv -f $@T $@ -ifeq (yes, $(build-shared)) - # To generate a header to support more than one ABI for different # architecture variants, the CPU/Makefile defines abi-variants to be a # list of names for those variants (e.g. 32 64), and, for each variant, @@ -1176,7 +1174,6 @@ endif # Generate version maps, but wait until sysdep-subdirs is known ifeq ($(sysd-sorted-done),t) -ifeq ($(build-shared),yes) -include $(common-objpfx)sysd-versions -include $(common-objpfx)Versions.mk $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions @@ -1226,12 +1223,12 @@ $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \ mv -f $(common-objpfx)sysd-versionsT $(common-objpfx)sysd-versions touch $@ endif # avoid-generated -endif # $(build-shared) = yes endif # sysd-sorted-done # The name under which the run-time dynamic linker is installed. # We are currently going for the convention that `/lib/ld.so.1' # names the SVR4/ELF ABI-compliant dynamic linker. +ifeq ($(build-shared),yes) ifndef rtld-installed-name ifdef ld.so-version rtld-installed-name = $(ld.so-version) diff --git a/Makefile b/Makefile index 50f99ca611..5cd7b01340 100644 --- a/Makefile +++ b/Makefile @@ -583,11 +583,15 @@ endef # (which we do not build) that GCC-compiled programs depend on. +ifeq (yes, $(build-shared)) ifeq (,$(CXX)) LINKS_DSO_PROGRAM = links-dso-program-c else LINKS_DSO_PROGRAM = links-dso-program endif +else +LINKS_DSO_PROGRAM = +endif $(tests-container) $(addsuffix /tests,$(subdirs)) : \ $(objpfx)testroot.pristine/install.stamp diff --git a/Makerules b/Makerules index ca9885436e..52e7357d76 100644 --- a/Makerules +++ b/Makerules @@ -93,7 +93,6 @@ before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\ $(before-compile)) # Even before that, we need abi-versions.h which is generated right here. -ifeq ($(build-shared),yes) ifndef avoid-generated before-compile := $(common-objpfx)abi-versions.h $(before-compile) $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \ @@ -113,7 +112,6 @@ before-compile := $(common-objpfx)first-versions.h \ $(common-objpfx)first-versions.h: $(common-objpfx)versions.stmp $(common-objpfx)ldbl-compat-choose.h: $(common-objpfx)versions.stmp endif # avoid-generated -endif # $(build-shared) = yes ifndef avoid-generated ifneq (,$(CXX)) @@ -280,6 +278,7 @@ $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.py \ vpath %.sym $(sysdirs) before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h) +ifeq (yes, $(build-shared)) tests-internal += $(gen-as-const-headers:%.sym=test-as-const-%) generated += $(gen-as-const-headers:%.sym=test-as-const-%.c) $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.py $(..)Makerules \ @@ -288,6 +287,7 @@ $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.py $(..)Makerules \ $(PYTHON) $< --test $(filter %.sym,$^)) > $@T mv -f $@T $@ endif +endif ifeq (yes,$(build-shared)) # Generate the header containing the names of all shared libraries. @@ -1049,6 +1049,7 @@ $(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@ endef endif +ifeq ($(build-shared),yes) ifdef libc.so-version # For a library specified to be version N, install three files: # libc.so -> libc.so.N (e.g. libc.so.6) @@ -1102,7 +1103,8 @@ else install: $(inst_slibdir)/libc.so $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force) $(do-install-program) -endif +endif # libc.so-version +endif # build-shared ifneq (,$(versioned)) # Produce three sets of rules as above for all the smaller versioned libraries. diff --git a/include/shlib-compat.h b/include/shlib-compat.h index 28baef1ea4..af8019e43a 100644 --- a/include/shlib-compat.h +++ b/include/shlib-compat.h @@ -104,21 +104,6 @@ _compat_symbol_unique (lib, name, _compat_symbol_unique_alias (name), \ version) -#else - -/* Not compiling ELF shared libraries at all, so never any old versions. */ -# define SHLIB_COMPAT(lib, introduced, obsoleted) 0 - -/* No versions to worry about, just make this the global definition. */ -# define versioned_symbol(lib, local, symbol, version) \ - weak_alias (local, symbol) - -/* This should not appear outside `#if SHLIB_COMPAT (...)'. */ -# define compat_symbol(lib, local, symbol, version) ... -# define compat_symbol_unique(lib, name, version) ... - -#endif - /* Use compat_symbol_reference for a reference *or* definition of a specific version of a symbol. Definitions are primarily used to ensure tests reference the exact compat symbol required, or define an @@ -146,4 +131,23 @@ (!(ABI_##lib##_##obsoleted - 0) \ || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))) +#else + +/* Not compiling ELF shared libraries at all, so never any old versions. */ +# define SHLIB_COMPAT(lib, introduced, obsoleted) 0 + +/* No versions to worry about, just make this the global definition. */ +# define versioned_symbol(lib, local, symbol, version) \ + weak_alias (local, symbol) + +/* This should not appear outside `#if SHLIB_COMPAT (...)'. */ +# define compat_symbol(lib, local, symbol, version) ... +# define compat_symbol_unique(lib, name, version) ... + +# define compat_symbol_reference(lib, local, symbol, version) + +# define TEST_COMPAT(lib, introduced, obsoleted) 0 + +#endif /* SHARED */ + #endif /* shlib-compat.h */ diff --git a/nscd/nscd.c b/nscd/nscd.c index 3ca7c522c2..359df91b4b 100644 --- a/nscd/nscd.c +++ b/nscd/nscd.c @@ -314,7 +314,7 @@ main (int argc, char **argv) # endif #endif -#ifdef USE_NSCD +#if defined SHARED && defined USE_NSCD /* Make sure we do not get recursive calls. */ __nss_disable_nscd (register_traced_file); #endif diff --git a/nss/nss_module.c b/nss/nss_module.c index 60c070c851..7bf0196f40 100644 --- a/nss/nss_module.c +++ b/nss/nss_module.c @@ -55,6 +55,9 @@ __libc_lock_define (static, nss_module_list_lock); static bool is_nscd; /* The callback passed to the init functions when nscd is used. */ static void (*nscd_init_cb) (size_t, struct traced_file *); +#else +# define is_nscd (0) +# define nscd_init_cb (NULL) #endif /* Allocate the service NAME with length NAME_LENGTH. If the service diff --git a/support/Makefile b/support/Makefile index 8d63fbd5da..b7079e5591 100644 --- a/support/Makefile +++ b/support/Makefile @@ -211,12 +211,16 @@ CFLAGS-support_paths.c = \ # -fexcess-precision=standard. CFLAGS-timespec.c += -fexcess-precision=standard +ifeq (yes, $(build-shared)) ifeq (,$(CXX)) LINKS_DSO_PROGRAM = links-dso-program-c else LINKS_DSO_PROGRAM = links-dso-program LDLIBS-links-dso-program = -lstdc++ -lgcc -lgcc_s $(libunwind) endif +else +LINKS_DSO_PROGRAM = +endif ifeq (yes,$(have-selinux)) LDLIBS-$(LINKS_DSO_PROGRAM) += -lselinux diff --git a/sysdeps/unix/sysv/linux/aarch64/Makefile b/sysdeps/unix/sysv/linux/aarch64/Makefile index 3f22f71bef..41b284df17 100644 --- a/sysdeps/unix/sysv/linux/aarch64/Makefile +++ b/sysdeps/unix/sysv/linux/aarch64/Makefile @@ -1,9 +1,7 @@ ifeq ($(subdir),elf) -ifeq ($(build-shared),yes) # This is needed for DSO loading from static binaries. sysdep-dl-routines += dl-static endif -endif ifeq ($(subdir),misc) sysdep_headers += sys/elf.h diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile index a093cda68b..c567d6782a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -13,10 +13,8 @@ gen-as-const-headers += ucontext_i.sym endif ifeq ($(subdir),elf) -ifeq ($(build-shared),yes) # This is needed for DSO loading from static binaries. sysdep-dl-routines += dl-static -endif # Otherwise tst-tls-dlinfo fails due to tst-tlsmod2.so using static tls. LDFLAGS-tst-tlsmod2.so += -Wl,--no-tls-get-addr-optimize endif