public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2024-04-17 20:13 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:13 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3be1ab1ff9a6e9e8115702c4dd6c8cb6e207a36d

commit 3be1ab1ff9a6e9e8115702c4dd6c8cb6e207a36d
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index b1459a27ed..3cf894479a 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index 37af7ce6a2..d5ce50849a 100755
--- a/configure
+++ b/configure
@@ -6927,6 +6927,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index b501ddd439..5f75b25105 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1254,6 +1254,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2024-04-02 15:59 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 15:59 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b37295d084d381a5f3595f6a8379739231c0ed20

commit b37295d084d381a5f3595f6a8379739231c0ed20
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index acde47e99c..ce19406b88 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index 37af7ce6a2..d5ce50849a 100755
--- a/configure
+++ b/configure
@@ -6927,6 +6927,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index b501ddd439..5f75b25105 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1254,6 +1254,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2024-02-09 17:38 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:38 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=077a8b67db6299bb096314a85a2f62db8ec49ac4

commit 077a8b67db6299bb096314a85a2f62db8ec49ac4
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index acde47e99c..ce19406b88 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index db058a78b5..9c577b2bbf 100755
--- a/configure
+++ b/configure
@@ -6924,6 +6924,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index d8b1843593..f0ef446df3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1251,6 +1251,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2024-02-07 14:13 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:13 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4be2bf2ea45d2ae01f42f74cab64d5f701d01649

commit 4be2bf2ea45d2ae01f42f74cab64d5f701d01649
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index acde47e99c..ce19406b88 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index db058a78b5..9c577b2bbf 100755
--- a/configure
+++ b/configure
@@ -6924,6 +6924,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index d8b1843593..f0ef446df3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1251,6 +1251,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2024-01-29 18:03 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2024-01-29 18:03 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7a94b19de524f6775ee28dc91fd11efa36a572b8

commit 7a94b19de524f6775ee28dc91fd11efa36a572b8
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index acde47e99c..ce19406b88 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index db058a78b5..9c577b2bbf 100755
--- a/configure
+++ b/configure
@@ -6924,6 +6924,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index d8b1843593..f0ef446df3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1251,6 +1251,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2023-12-21 19:00 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2023-12-21 19:00 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a7d85e239873c3c4d0834cd1e4447054167a3fb9

commit a7d85e239873c3c4d0834cd1e4447054167a3fb9
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index f9cf222e17..cb607752d8 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index 49448ab05c..04cefde3d3 100755
--- a/configure
+++ b/configure
@@ -6923,6 +6923,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index d8b1843593..f0ef446df3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1251,6 +1251,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2023-09-28 17:58 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2023-09-28 17:58 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f30faf85fcf0b8084f4901e44f34c292cb5dc492

commit f30faf85fcf0b8084f4901e44f34c292cb5dc492
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index a908d3e19d..bf6d610a55 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index 4caa40ce8b..bdfae97469 100755
--- a/configure
+++ b/configure
@@ -7049,6 +7049,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index 9302467750..b1d8461368 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1316,6 +1316,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2023-08-30 12:42 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2023-08-30 12:42 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f1432adaccce08aa67bec2434f75a0956b94319c

commit f1432adaccce08aa67bec2434f75a0956b94319c
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  9 ++++++++
 configure    | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index a908d3e19d..bf6d610a55 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,15 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-rtld += $(config-ldflags-undefined-version)
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index 965c28a776..f593aeb9fe 100755
--- a/configure
+++ b/configure
@@ -7049,6 +7049,74 @@ printf "%s\n" "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+printf %s "checking whether to suppress unused version in version script... " >&6; }
+if test ${libc_cv_undefined_version+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { 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 <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+printf "%s\n" "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+printf "%s\n" "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 printf %s "checking for -static-pie... " >&6; }
 if test ${libc_cv_static_pie+y}
diff --git a/configure.ac b/configure.ac
index 6e9b133110..8782cf8729 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1316,6 +1316,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it
@ 2023-02-09 19:54 Adhemerval Zanella
  0 siblings, 0 replies; 9+ messages in thread
From: Adhemerval Zanella @ 2023-02-09 19:54 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dbe213c564a4c0755f6b106c2b596ff46c7bf75e

commit dbe213c564a4c0755f6b106c2b596ff46c7bf75e
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Jan 4 13:46:38 2023 -0300

    Use -Wl,--undefined-version if linker requires it
    
    The lld might set --no-undefined-version as default, which triggers
    a lot of error since the Versions files may contain entries not
    exported by all ABI.
    
    The  -Wl,--undefined-version can not be set by default, since binutils
    ld does not support (although gold does).  So it requires to be checked
    at configure if linker requires and enabled it conditionally.

Diff:
---
 Makeconfig   |  8 ++++++++
 configure    | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac | 27 ++++++++++++++++++++++++
 3 files changed, 102 insertions(+)

diff --git a/Makeconfig b/Makeconfig
index a4a6f247d0..120385a3eb 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -424,6 +424,14 @@ ifndef after-link
 after-link =
 endif
 
+# The Versions file may contain entries not exported by all ABI, which
+# trigger errors if the linker defaults to --no-undefined-version.  The
+# configure checks whether it is the case and adds --undefined-version
+# if required.
+LDFLAGS-lib.so += $(config-ldflags-undefined-version)
+LDFLAGS.so += $(config-ldflags-undefined-version)
+link-extra-flags += $(config-ldflags-undefined-version)
+
 # Additional libraries to link into every test.
 link-extra-libs-tests = $(libsupport)
 
diff --git a/configure b/configure
index 7b2c5a23af..e90610563e 100755
--- a/configure
+++ b/configure
@@ -5854,6 +5854,73 @@ $as_echo "$libc_linker_feature" >&6; }
 config_vars="$config_vars
 have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to suppress unused version in version script" >&5
+$as_echo_n "checking whether to suppress unused version in version script... " >&6; }
+if ${libc_cv_undefined_version+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! { ac_try='${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; };
+then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker that supports --undefined-version" >&5
+$as_echo_n "checking for linker that supports --undefined-version... " >&6; }
+libc_linker_feature=no
+cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+		  -Wl,--undefined-version -nostdlib -nostartfiles
+		  -fPIC -shared -o conftest.so conftest.c
+		  1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$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_support_undefined_version=yes
+else
+  libc_cv_support_undefined_version=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+$as_echo "$libc_linker_feature" >&6; }
+  if test "$libc_cv_support_undefined_version" = no; then
+    as_fn_error $? "support for -Wl,--undefined-version required" "$LINENO" 5
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_undefined_version" >&5
+$as_echo "$libc_cv_undefined_version" >&6; }
+config_vars="$config_vars
+config-ldflags-undefined-version = $libc_cv_undefined_version"
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -static-pie" >&5
 $as_echo_n "checking for -static-pie... " >&6; }
 if ${libc_cv_static_pie+:} false; then :
diff --git a/configure.ac b/configure.ac
index eed7732eb5..dd89cdb0a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1332,6 +1332,33 @@ LIBC_LINKER_FEATURE([--no-dynamic-linker],
 		    [libc_cv_no_dynamic_linker=no])
 LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
 
+AC_CACHE_CHECK(whether to suppress unused version in version script,
+	       libc_cv_undefined_version, [dnl
+cat > conftest.c <<EOF
+void foo (void) { }
+EOF
+cat > conftest.map <<EOF
+VER_1.0 {
+  global:
+    bar;
+};
+EOF
+libc_cv_undefined_version=""
+if ! AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared -Wl,--version-script=conftest.map conftest.c -o conftest.so]);
+then
+  LIBC_LINKER_FEATURE([--undefined-version],
+		      [-Wl,--undefined-version],
+		      [libc_cv_support_undefined_version=yes],
+		      [libc_cv_support_undefined_version=no])
+  if test "$libc_cv_support_undefined_version" = no; then
+    AC_MSG_ERROR([support for -Wl,--undefined-version required])
+  fi
+  libc_cv_undefined_version="-Wl,--undefined-version"
+fi
+rm -f conftest.*t])
+LIBC_CONFIG_VAR([config-ldflags-undefined-version],[$libc_cv_undefined_version])
+
+
 AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
 LIBC_TRY_CC_OPTION([-static-pie],
 		   [libc_cv_static_pie=yes],

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-17 20:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 20:13 [glibc/azanella/clang] Use -Wl, --undefined-version if linker requires it Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2024-04-02 15:59 Adhemerval Zanella
2024-02-09 17:38 Adhemerval Zanella
2024-02-07 14:13 Adhemerval Zanella
2024-01-29 18:03 Adhemerval Zanella
2023-12-21 19:00 Adhemerval Zanella
2023-09-28 17:58 Adhemerval Zanella
2023-08-30 12:42 Adhemerval Zanella
2023-02-09 19:54 Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).