public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2024-04-17 20:10 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:10 UTC (permalink / raw)
  To: glibc-cvs

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

commit 6272e416053443fcb4b2220f4c8779286d6c60fe
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 252b4373c0..1ff91a6810 100755
--- a/configure
+++ b/configure
@@ -7454,6 +7454,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 2f90025a1a..99a0ea1bbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1526,6 +1526,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index ec1516ca3d..42450f9453 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -537,7 +537,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -628,7 +628,7 @@ $(objpfx)tst-rtld-does-not-exist.out: tst-rtld-does-not-exist.sh $(objpfx)ld.so
 	$(SHELL) $< $(objpfx)ld.so > $@; \
 	$(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -992,7 +992,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1041,7 +1041,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1833,7 +1833,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b3f8af2e1c..a13a8ea455 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -466,7 +466,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack-threads
 endif
 endif
@@ -475,7 +475,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-threads-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -486,6 +485,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-threads-mod \
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2024-04-02 15:56 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 15:56 UTC (permalink / raw)
  To: glibc-cvs

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

commit 17539fa209560f8b1fb84ff2ebd90917b9444a19
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 252b4373c0..1ff91a6810 100755
--- a/configure
+++ b/configure
@@ -7454,6 +7454,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 2f90025a1a..99a0ea1bbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1526,6 +1526,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 4f1903391a..711f79084d 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -536,7 +536,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -621,7 +621,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test \
 		'$(valgrind-suppressions-tst-valgrind-smoke)' > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -985,7 +985,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1034,7 +1034,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1825,7 +1825,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index bf09603e7b..7f62dec2fa 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -465,7 +465,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack-threads
 endif
 endif
@@ -474,7 +474,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-threads-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -485,6 +484,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-threads-mod \
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2024-02-09 17:34 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:34 UTC (permalink / raw)
  To: glibc-cvs

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

commit e8e2cf13a917ad7975bf7f0a6841fba1b939c514
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 5cf3e1d8fa..c148a663f3 100755
--- a/configure
+++ b/configure
@@ -7451,6 +7451,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index a6e05cf585..24fb4adb7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1523,6 +1523,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 5d78b659ce..2716cfbec3 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -534,7 +534,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -618,7 +618,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -979,7 +979,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1028,7 +1028,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1819,7 +1819,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index bf09603e7b..7f62dec2fa 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -465,7 +465,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack-threads
 endif
 endif
@@ -474,7 +474,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-threads-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -485,6 +484,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-threads-mod \
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2024-02-07 14:10 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:10 UTC (permalink / raw)
  To: glibc-cvs

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

commit c39c835f3d968aca7b2837f9f7c08730bdd58702
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 5cf3e1d8fa..c148a663f3 100755
--- a/configure
+++ b/configure
@@ -7451,6 +7451,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index a6e05cf585..24fb4adb7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1523,6 +1523,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 5d78b659ce..2716cfbec3 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -534,7 +534,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -618,7 +618,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -979,7 +979,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1028,7 +1028,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1819,7 +1819,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index bf09603e7b..7f62dec2fa 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -465,7 +465,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack-threads
 endif
 endif
@@ -474,7 +474,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-threads-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -485,6 +484,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-threads-mod \
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2024-01-29 18:00 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-01-29 18:00 UTC (permalink / raw)
  To: glibc-cvs

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

commit 72d95b1a8310f14ab468a86c5a52bda05529cc51
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 5cf3e1d8fa..c148a663f3 100755
--- a/configure
+++ b/configure
@@ -7451,6 +7451,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index a6e05cf585..24fb4adb7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1523,6 +1523,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 5d78b659ce..2716cfbec3 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -534,7 +534,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -618,7 +618,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -979,7 +979,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1028,7 +1028,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1819,7 +1819,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index bf09603e7b..7f62dec2fa 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -465,7 +465,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack-threads
 endif
 endif
@@ -474,7 +474,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-threads-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -485,6 +484,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-threads-mod \
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2023-12-21 18:56 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-12-21 18:56 UTC (permalink / raw)
  To: glibc-cvs

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

commit b2e7d3f3db6cc0596a9c115144b1b23bbebc91cb
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 3075261273..019d306c48 100755
--- a/configure
+++ b/configure
@@ -7450,6 +7450,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index a6e05cf585..24fb4adb7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1523,6 +1523,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index ba7b71035c..229646e4d5 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -534,7 +534,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -618,7 +618,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -979,7 +979,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1028,7 +1028,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1819,7 +1819,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index 067b01ea8e..455fe6e84a 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -465,7 +465,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack-threads
 endif
 endif
@@ -474,7 +474,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-threads-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -485,6 +484,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-threads-mod \
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2023-09-28 17:55 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-09-28 17:55 UTC (permalink / raw)
  To: glibc-cvs

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

commit 3fc760aaca630876f44cdc6368f359c96f8de4ba
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 7605653d58..289d1efdaa 100755
--- a/configure
+++ b/configure
@@ -7576,6 +7576,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 188aa8749f..b7ae62ce6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1588,6 +1588,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 9176cbf1e3..a8d933ef43 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -523,7 +523,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -607,7 +607,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -962,7 +962,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1011,7 +1011,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1816,7 +1816,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index ffa5722e48..d0b1510e63 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -465,7 +465,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -474,7 +474,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -485,6 +484,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-mod
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2023-08-30 12:39 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-08-30 12:39 UTC (permalink / raw)
  To: glibc-cvs

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

commit 30e92adbfc71550363a817f54249271dc027baf2
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 33 +++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  8 ++++++--
 4 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 5c1ea0cd91..49c39abcd3 100755
--- a/configure
+++ b/configure
@@ -7552,6 +7552,39 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+printf %s "checking if $CC has support for trampolines... " >&6; }
+if test ${libc_cv_cc_trampoline+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+printf "%s\n" "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 printf %s "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index f10b8869d7..934e9e0c9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1580,6 +1580,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 9176cbf1e3..a8d933ef43 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -523,7 +523,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -607,7 +607,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -962,7 +962,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1011,7 +1011,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1816,7 +1816,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index ffa5722e48..d0b1510e63 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -465,7 +465,7 @@ tests-internal += \
   tst-tls3-malloc \
   tst-tls5 \
   # tests-internal
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -474,7 +474,6 @@ modules-names = \
   tst-audit-threads-mod1 \
   tst-audit-threads-mod2 \
   tst-compat-forwarder-mod \
-  tst-execstack-mod \
   tst-stack4mod \
   tst-tls3mod \
   tst-tls5mod \
@@ -485,6 +484,11 @@ modules-names = \
   tst-tls5mode \
   tst-tls5modf \
   # modules-names
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += \
+  tst-execstack-mod
+  # modules-names
+endif
 extra-test-objs += \
   $(addsuffix .os,$(strip $(modules-names))) \
   tst-cleanup4aux.o \

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2023-02-09 19:51 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-02-09 19:51 UTC (permalink / raw)
  To: glibc-cvs

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

commit c99051a7015c4ed96fdd8eb9c83bc54ee0e3d52b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 6b1632f06b..b9ba9958c2 100755
--- a/configure
+++ b/configure
@@ -6330,6 +6330,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index ce402e09b9..6f97d8d4b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1596,6 +1596,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 3ae023ec9e..a1b42509af 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -523,7 +523,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -607,7 +607,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -955,7 +955,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1004,7 +1004,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1789,7 +1789,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index 8cec6faee3..6e4bf7e942 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -385,7 +385,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -393,9 +393,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-10-28 17:44 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-10-28 17:44 UTC (permalink / raw)
  To: glibc-cvs

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

commit a519068663701bbcf59ccac9b1212c56a074bf92
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 8a71df6568..9b3f3ffa5d 100755
--- a/configure
+++ b/configure
@@ -6549,6 +6549,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index d28ac6ed1e..fbc24f9119 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1606,6 +1606,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 86c960cf8a..cbd449fdcf 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -524,7 +524,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -625,7 +625,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -972,7 +972,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1021,7 +1021,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1808,7 +1808,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index 3d2ce8af8a..6f1ce4e394 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -386,7 +386,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -394,9 +394,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-10-04 13:02 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-10-04 13:02 UTC (permalink / raw)
  To: glibc-cvs

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

commit c6b3daa8575250058cdb5257ecd472e54662fa8b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 8a71df6568..9b3f3ffa5d 100755
--- a/configure
+++ b/configure
@@ -6549,6 +6549,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index d28ac6ed1e..fbc24f9119 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1606,6 +1606,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index b915ea8f02..396e84becc 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -523,7 +523,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -624,7 +624,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -971,7 +971,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1020,7 +1020,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1807,7 +1807,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index 3d2ce8af8a..6f1ce4e394 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -386,7 +386,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -394,9 +394,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux

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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-06-09 21:23 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 21:23 UTC (permalink / raw)
  To: glibc-cvs

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

commit 418ec1178fa235a5db7aa4528e8b54fe4805f480
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index c8ec3471d4..709a572377 100755
--- a/configure
+++ b/configure
@@ -6595,6 +6595,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 996d674399..8c9c70fca3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,6 +1589,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 2b646a91e0..a1d2b3b518 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -525,7 +525,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -626,7 +626,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -968,7 +968,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1032,7 +1032,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1818,7 +1818,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-06-09 13:19 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 13:19 UTC (permalink / raw)
  To: glibc-cvs

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

commit 418ec1178fa235a5db7aa4528e8b54fe4805f480
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index c8ec3471d4..709a572377 100755
--- a/configure
+++ b/configure
@@ -6595,6 +6595,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 996d674399..8c9c70fca3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,6 +1589,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index 2b646a91e0..a1d2b3b518 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -525,7 +525,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -626,7 +626,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -968,7 +968,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1032,7 +1032,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1818,7 +1818,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-06-03 14:08 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-06-03 14:08 UTC (permalink / raw)
  To: glibc-cvs

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

commit a4fb161f5a4e63727cc193e009e83b79baa87b2a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index c8ec3471d4..709a572377 100755
--- a/configure
+++ b/configure
@@ -6595,6 +6595,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 996d674399..8c9c70fca3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,6 +1589,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index bfc9179fc5..7feedb6f6a 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -525,7 +525,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -626,7 +626,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -968,7 +968,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1032,7 +1032,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1818,7 +1818,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-05-13 14:22 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-05-13 14:22 UTC (permalink / raw)
  To: glibc-cvs

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

commit 20c426d5144f1e097ddb69af592ac9180a7586f2
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index c8ec3471d4..709a572377 100755
--- a/configure
+++ b/configure
@@ -6595,6 +6595,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 996d674399..8c9c70fca3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,6 +1589,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index fc9860edee..0aafe43056 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -520,7 +520,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -621,7 +621,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -962,7 +962,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1026,7 +1026,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1803,7 +1803,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-05-12 19:36 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 19:36 UTC (permalink / raw)
  To: glibc-cvs

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

commit b2e3db301a3b18c37cf422812dda46cf532b35bb
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index c8ec3471d4..709a572377 100755
--- a/configure
+++ b/configure
@@ -6595,6 +6595,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 996d674399..8c9c70fca3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,6 +1589,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index fc9860edee..0aafe43056 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -520,7 +520,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -621,7 +621,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -962,7 +962,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1026,7 +1026,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1803,7 +1803,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-05-10 18:27 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-05-10 18:27 UTC (permalink / raw)
  To: glibc-cvs

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

commit 615670e54669d81cdc3496386762bc335d3b58d2
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index c8ec3471d4..709a572377 100755
--- a/configure
+++ b/configure
@@ -6595,6 +6595,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 996d674399..8c9c70fca3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,6 +1589,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index fc9860edee..0aafe43056 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -520,7 +520,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -621,7 +621,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -962,7 +962,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1026,7 +1026,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1803,7 +1803,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-04-29 14:06 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-04-29 14:06 UTC (permalink / raw)
  To: glibc-cvs

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

commit d4fc4c42147aa78777f2f9bb71ffc90c7fb4c930
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 6e3500d2fd..688ded0da9 100755
--- a/configure
+++ b/configure
@@ -6623,6 +6623,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 76fadafbe0..3cff0b801f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1605,6 +1605,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index fc9860edee..0aafe43056 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -520,7 +520,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -621,7 +621,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -962,7 +962,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -1026,7 +1026,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1803,7 +1803,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-04-04 12:57 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-04-04 12:57 UTC (permalink / raw)
  To: glibc-cvs

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

commit b7ec2e4111920bbf5bf9f6e5e1f760df65b41d3c
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 2b17c9cabd..2f60e8dc66 100755
--- a/configure
+++ b/configure
@@ -6750,6 +6750,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 62e44967c1..966e12af76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1721,6 +1721,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index c96924e9c2..320d4c778a 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -519,7 +519,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -550,7 +550,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -880,7 +880,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -944,7 +944,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1701,7 +1701,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-03-31 19:09 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-03-31 19:09 UTC (permalink / raw)
  To: glibc-cvs

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

commit e594e925c7069dc6eae79bc2b0e17a4f080bdaad
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 2b17c9cabd..2f60e8dc66 100755
--- a/configure
+++ b/configure
@@ -6750,6 +6750,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 62e44967c1..966e12af76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1721,6 +1721,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index c96924e9c2..320d4c778a 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -519,7 +519,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -550,7 +550,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -880,7 +880,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -944,7 +944,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1701,7 +1701,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..dbbe0ae737 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+modules-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

* [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it
@ 2022-03-29 20:32 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-03-29 20:32 UTC (permalink / raw)
  To: glibc-cvs

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

commit c2b5381a7dbec0e9d6085a1e9e8fdefeb81e394a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 08:58:03 2022 -0300

    Use check tests with trampolines iff compiler supports it

Diff:
---
 configure     | 32 ++++++++++++++++++++++++++++++++
 configure.ac  | 20 ++++++++++++++++++++
 elf/Makefile  | 10 +++++-----
 nptl/Makefile |  6 ++++--
 4 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 2b17c9cabd..2f60e8dc66 100755
--- a/configure
+++ b/configure
@@ -6750,6 +6750,38 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC has support for trampolines" >&5
+$as_echo_n "checking if $CC has support for trampolines... " >&6; }
+if ${libc_cv_cc_trampoline+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { 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
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_trampoline" >&5
+$as_echo "$libc_cv_cc_trampoline" >&6; }
+config_vars="$config_vars
+have-cc-trampoline = $libc_cv_cc_trampoline"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5
 $as_echo_n "checking for libgd... " >&6; }
 if test "$with_gd" != "no"; then
diff --git a/configure.ac b/configure.ac
index 62e44967c1..966e12af76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1721,6 +1721,26 @@ if test $libc_cv_cc_loop_to_function = yes; then
 fi
 AC_SUBST(libc_cv_cc_loop_to_function)
 
+AC_CACHE_CHECK(if $CC has support for trampolines, libc_cv_cc_trampoline, [dnl
+cat > conftest.c <<EOF
+void bar (void (*callback) (void));
+int foo (void)
+{
+  int var = 0;
+  void callback (void) { var = 1; }
+  bar (callback);
+  return var;
+}
+EOF
+libc_cv_cc_trampoline=no
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_cc_trampoline=yes
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([have-cc-trampoline],
+		[$libc_cv_cc_trampoline])
+
 dnl Check whether we have the gd library available.
 AC_MSG_CHECKING(for libgd)
 if test "$with_gd" != "no"; then
diff --git a/elf/Makefile b/elf/Makefile
index c96924e9c2..320d4c778a 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -519,7 +519,7 @@ endif
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
 
 ifneq ($(selinux-enabled),1)
-tests-execstack-yes = \
+tests-execstack-yesyes = \
   tst-execstack \
   tst-execstack-needed \
   tst-execstack-prog \
@@ -550,7 +550,7 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v
 	$(SHELL) $< $(objpfx)ld.so  $(rtlddir)/$(rtld-installed-name) '$(test-wrapper-env)' \
 		'$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test > $@; $(evaluate-test)
 
-tests += $(tests-execstack-$(have-z-execstack))
+tests += $(tests-execstack-$(have-z-execstack)$(have-cc-trampoline))
 ifeq ($(run-built-tests),yes)
 tests-special += \
   $(objpfx)noload-mem.out \
@@ -880,7 +880,7 @@ modules-names-cxx = \
 
 modules-names += \
   $(if $(CXX),$(modules-names-cxx)) \
-  $(modules-execstack-$(have-z-execstack)) \
+  $(modules-execstack-$(have-z-execstack)$(have-cc-trampoline)) \
   $(tlsmod17a-modules) \
   $(tlsmod18a-modules) \
   $(tst-tls-many-dynamic-modules) \
@@ -944,7 +944,7 @@ tests-pie += vismain
 CFLAGS-vismain.c += $(PIE-ccflag)
 endif
 endif
-modules-execstack-yes = tst-execstack-mod
+modules-execstack-yesyes = tst-execstack-mod
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
 
 # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special
@@ -1701,7 +1701,7 @@ $(objpfx)unload8.out: $(objpfx)unload8mod1.so $(objpfx)unload8mod1x.so
 
 $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so
 
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
 CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0
 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
diff --git a/nptl/Makefile b/nptl/Makefile
index b585663974..9b281ec0cc 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -387,7 +387,7 @@ tests += tst-cancelx7 tst-cancelx17
 ifeq ($(build-shared),yes)
 tests += tst-compat-forwarder tst-audit-threads
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
-ifeq ($(have-z-execstack),yes)
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
 tests += tst-execstack
 endif
 endif
@@ -395,9 +395,11 @@ endif
 modules-names = tst-tls3mod \
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
-		tst-execstack-mod \
 		tst-compat-forwarder-mod tst-audit-threads-mod1 \
 		tst-audit-threads-mod2
+ifeq ($(have-z-execstack)$(have-cc-trampoline),yesyes)
+module-names += tst-execstack-mod
+endif
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
 test-extras += tst-cleanup4aux tst-cleanupx4aux


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

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

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 20:10 [glibc/azanella/clang] Use check tests with trampolines iff compiler supports it Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2024-04-02 15:56 Adhemerval Zanella
2024-02-09 17:34 Adhemerval Zanella
2024-02-07 14:10 Adhemerval Zanella
2024-01-29 18:00 Adhemerval Zanella
2023-12-21 18:56 Adhemerval Zanella
2023-09-28 17:55 Adhemerval Zanella
2023-08-30 12:39 Adhemerval Zanella
2023-02-09 19:51 Adhemerval Zanella
2022-10-28 17:44 Adhemerval Zanella
2022-10-04 13:02 Adhemerval Zanella
2022-06-09 21:23 Adhemerval Zanella
2022-06-09 13:19 Adhemerval Zanella
2022-06-03 14:08 Adhemerval Zanella
2022-05-13 14:22 Adhemerval Zanella
2022-05-12 19:36 Adhemerval Zanella
2022-05-10 18:27 Adhemerval Zanella
2022-04-29 14:06 Adhemerval Zanella
2022-04-04 12:57 Adhemerval Zanella
2022-03-31 19:09 Adhemerval Zanella
2022-03-29 20:32 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).