[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230629162301.1234157-2-bjorn@kernel.org>
Date: Thu, 29 Jun 2023 18:22:59 +0200
From: Björn Töpel <bjorn@...nel.org>
To: Shuah Khan <shuah@...nel.org>, linux-kselftest@...r.kernel.org
Cc: Björn Töpel <bjorn@...osinc.com>,
linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
Alexey Dobriyan <adobriyan@...il.com>,
linux-fsdevel@...r.kernel.org,
Anders Roxell <anders.roxell@...aro.org>
Subject: [PATCH 1/2] selftests/openat2: Run-time check for -fsanitize=undefined
From: Björn Töpel <bjorn@...osinc.com>
Some architectures, e.g. riscv, does not have support for the GCC
option '-fsanitize=undefined'.
Check for '-fsanitize=undefined' support, and only add it to CFLAGS if
supported.
Signed-off-by: Björn Töpel <bjorn@...osinc.com>
---
tools/testing/selftests/openat2/Makefile | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/openat2/Makefile b/tools/testing/selftests/openat2/Makefile
index 843ba56d8e49..f13ad02a18ea 100644
--- a/tools/testing/selftests/openat2/Makefile
+++ b/tools/testing/selftests/openat2/Makefile
@@ -1,6 +1,13 @@
# SPDX-License-Identifier: GPL-2.0-or-later
-CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined
+# We need this for the "try-run" macro.
+include ../../../build/Build.include
+
+CFLAGS += -Wall -O2 -g -fsanitize=address
+CFLAGS += $(call try-run, \
+ echo 'int main() {}' | $(CC) -fsanitize=undefined -x c - -o /dev/null, \
+ -fsanitize=undefined,)
+
TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test
include ../lib.mk
--
2.39.2
Powered by blists - more mailing lists