From patchwork Thu Nov 20 12:20:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 124828 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 B3720385AC1D for ; Thu, 20 Nov 2025 12:21:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3720385AC1D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=gTo/kmEt X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by sourceware.org (Postfix) with ESMTPS id 1EF083858C24 for ; Thu, 20 Nov 2025 12:20:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EF083858C24 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1EF083858C24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::641 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763641251; cv=none; b=UkwmGhywV1Fh9bdYJEOxE+vGYb4fdc4Krz4VnZG+ZGr+XIbzsAln+AhO0pk6qTiPr2swF/oE9SkWJOGWmfV+/tx/ECleLU2YwNr6I4zbwvgv6Xok3VqY3a3ai878oXW6r+qtcReJ6vTa3vOsieOmGFUdgit4ilX7PI+nkHG5b2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763641251; c=relaxed/simple; bh=GwtDpQOCfWYDAM5Y4+SMjlRknFH5G8zo6qdqCRsrvrQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=F2gjKdyMinqzyTdnrFTwQbIz6Cie5fJqaQCtu8+wFDrocP6ENkjLkoANRD/sTG9ImEE28qvjK4N9AgKYEvzOzK0YRsLQJWTSvo7pJp/zTpuXlYzP4tVLEqcQRTUt2aepDu9i+T589O7mbT5w7cHxdkkzHab5J7FdTMaU+pTpbhE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EF083858C24 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-29812589890so10333435ad.3 for ; Thu, 20 Nov 2025 04:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763641250; x=1764246050; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tKVKUmp87esWoyDPPae1UQJZRf5k7j90lBbSZVD6YP8=; b=gTo/kmEtYY9pz8O9auXLibLluUGYjNroKo67qjQLp2F8u/DTKGfdX/o6rDNp4B9htQ YBOixLrkfAHdeDb4k5bnhFwPemAf/A++LGGDAK+JAfOidvOvbdPLjDcQr0eJXCitsZry BDGoZ9kPm3ITvFZv71JrKLlAex4tQgx0xg0UAaCbotlxQZCueqAa5mecVy9jr3i8xXEW JA7YZtNU3yazd3/XIbs9Zb6vkv5dTFEzbL8NFZPyWoE264rt2xgBa/yp5QjwkAaOW+EV jxz1UiBbOAiGXbJLeJgGxkRspvUpcdHQ6OaHPPHGw/m/ry9cUKqsQwJA28h5Qxxif0od Wp+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763641250; x=1764246050; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tKVKUmp87esWoyDPPae1UQJZRf5k7j90lBb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2HYggbDfzjUsZ14A== X-Received: by 2002:a05:7022:f013:b0:119:e569:fbb3 with SMTP id a92af1059eb24-11c957bde19mr980388c88.34.1763641249482; Thu, 20 Nov 2025 04:20:49 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c3:9cd2:61e7:60a5:3e9e:15d4]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2a6fc3d0bb6sm12258797eec.2.2025.11.20.04.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 04:20:48 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James Subject: [PATCH] Check if linker supports -Wl,--undefined-version Date: Thu, 20 Nov 2025 09:20:41 -0300 Message-ID: <20251120122045.4095153-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 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 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Although binutils has supported --no-undefined-version for a long timei (319416359200 back in 2002), --undefined-version was only added more recently (27fb6a1a7fcd on 2.40). Reviewed-by: Sam James --- Makerules | 2 +- configure | 36 ++++++++++++++++++++++++++++++++++++ configure.ac | 6 ++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Makerules b/Makerules index caa1e43faa..89ef44d7c5 100644 --- a/Makerules +++ b/Makerules @@ -510,7 +510,7 @@ map-file = $(firstword $($(@F:.so=-map)) \ $(filter $(@F:.so=.map),$(version-maps)))) # The map version is created with multiple symbols that might not be # exported depending of the ABI. -load-map-file = $(map-file:%=-Wl,--version-script=%) -Wl,--undefined-version +load-map-file = $(map-file:%=-Wl,--version-script=%) $(have-undefined-version) endif # Compiler arguments to use to link a shared object with libc and diff --git a/configure b/configure index 1999d12f44..d5bd639586 100755 --- a/configure +++ b/configure @@ -9246,6 +9246,42 @@ printf "%s\n" "$libc_linker_feature" >&6; } config_vars="$config_vars have-ld-gcs = $libc_cv_ld_gcs" + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker that supports --undefined-version" >&5 +printf %s "checking for linker that supports --undefined-version... " >&6; } +libc_linker_feature=no +cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then + if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp -Wl,--undefined-version -nostdlib \ + -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \ + | grep "warning: --undefined-version ignored" > /dev/null 2>&1; then + true + else + libc_linker_feature=yes + fi +fi +rm -f conftest* +if test $libc_linker_feature = yes; then + libc_cv_ld_undefined_version=-Wl,--undefined-version +else + libc_cv_ld_undefined_version= +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5 +printf "%s\n" "$libc_linker_feature" >&6; } +config_vars="$config_vars +have-undefined-version = $libc_cv_ld_undefined_version" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can build programs as PIE" >&5 printf %s "checking if we can build programs as PIE... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext diff --git a/configure.ac b/configure.ac index 46a354dfbc..aaf686494a 100644 --- a/configure.ac +++ b/configure.ac @@ -2066,6 +2066,12 @@ LIBC_LINKER_FEATURE([-z gcs=always], [-Wl,-z,gcs=always], [libc_cv_ld_gcs=yes], [libc_cv_ld_gcs=no]) LIBC_CONFIG_VAR([have-ld-gcs], [$libc_cv_ld_gcs]) + +LIBC_LINKER_FEATURE([--undefined-version], [-Wl,--undefined-version], + [libc_cv_ld_undefined_version=-Wl,--undefined-version], + [libc_cv_ld_undefined_version=]) +LIBC_CONFIG_VAR([have-undefined-version], [$libc_cv_ld_undefined_version]) + AC_MSG_CHECKING(if we can build programs as PIE) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifdef PIE_UNSUPPORTED # error PIE is not supported