From: Bruno Haible Date: Mon, 8 Jan 2024 17:10:28 +0000 (+0100) Subject: jit/cache tests: Avoid test failure on OpenBSD. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=139cd99afdbcb280554fadd8f37f76a619d59dbb;p=gnulib.git jit/cache tests: Avoid test failure on OpenBSD. * modules/jit/cache-tests (Files): Add m4/warnings.m4. (configure.ac): Set and substitute DISABLE_OPENBSD_RETGUARD. (Makefile.am): Set test_cache_CFLAGS. * tests/jit/test-cache.c (main): If the compiler defines _RET_PROTECTOR, skip the test. --- diff --git a/ChangeLog b/ChangeLog index 543a8000a7..2e11913f23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-01-08 Bruno Haible + + jit/cache tests: Avoid test failure on OpenBSD. + * modules/jit/cache-tests (Files): Add m4/warnings.m4. + (configure.ac): Set and substitute DISABLE_OPENBSD_RETGUARD. + (Makefile.am): Set test_cache_CFLAGS. + * tests/jit/test-cache.c (main): If the compiler defines _RET_PROTECTOR, + skip the test. + 2024-01-08 Bruno Haible jit/cache tests: Avoid test failure on CentOS, *BSD, macOS. diff --git a/modules/jit/cache-tests b/modules/jit/cache-tests index e4229476c8..d777684093 100644 --- a/modules/jit/cache-tests +++ b/modules/jit/cache-tests @@ -2,6 +2,7 @@ Files: tests/jit/test-cache.c tests/macros.h m4/mmap-anon.m4 +m4/warnings.m4 Status: unportable-test @@ -15,8 +16,14 @@ stdint configure.ac: AC_CHECK_HEADERS_ONCE([sys/mman.h]) gl_FUNC_MMAP_ANON +dnl Disable the OpenBSD "retguard" stack protector for this test. +gl_COMPILER_OPTION_IF([-fno-ret-protector], + [DISABLE_OPENBSD_RETGUARD='-fno-ret-protector'], + [DISABLE_OPENBSD_RETGUARD=]) +AC_SUBST([DISABLE_OPENBSD_RETGUARD]) Makefile.am: TESTS += test-cache check_PROGRAMS += test-cache test_cache_SOURCES = jit/test-cache.c +test_cache_CFLAGS = $(AM_CFLAGS) $(DISABLE_OPENBSD_RETGUARD) diff --git a/tests/jit/test-cache.c b/tests/jit/test-cache.c index 35d63b7842..1d77dadaa5 100644 --- a/tests/jit/test-cache.c +++ b/tests/jit/test-cache.c @@ -107,7 +107,14 @@ return2 (void) int main () { -#if !HAVE_SYS_MMAN_H +#if defined _RET_PROTECTOR + /* The OpenBSD "retguard" stack protector produces code for 'return1' and + 'return2' that is not position independent, and there is no clang + attribute for turning this instrumentation off for specific functions. + If this stack protector has not been disabled through a configure test, + we need to skip this unit test. */ + return 77; +#elif !HAVE_SYS_MMAN_H return 77; #else int const pagesize = getpagesize ();