public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn@kernel.org>
To: Shuah Khan <shuah@kernel.org>, linux-kselftest@vger.kernel.org
Cc: "Björn Töpel" <bjorn@rivosinc.com>,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	"Alexey Dobriyan" <adobriyan@gmail.com>,
	linux-fsdevel@vger.kernel.org,
	"Anders Roxell" <anders.roxell@linaro.org>
Subject: [PATCH 1/2] selftests/openat2: Run-time check for -fsanitize=undefined
Date: Thu, 29 Jun 2023 18:22:59 +0200	[thread overview]
Message-ID: <20230629162301.1234157-2-bjorn@kernel.org> (raw)
In-Reply-To: <20230629162301.1234157-1-bjorn@kernel.org>

From: Björn Töpel <bjorn@rivosinc.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@rivosinc.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


  reply	other threads:[~2023-06-29 16:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 16:22 [PATCH 0/2] Two cross-compilation kselftest fixes Björn Töpel
2023-06-29 16:22 ` Björn Töpel [this message]
2023-06-29 16:23 ` [PATCH 2/2] selftests/proc: Do not build x86-64 tests on non-x86-64 builds Björn Töpel
2023-06-29 19:42   ` Alexey Dobriyan
2023-06-30 10:27     ` Björn Töpel
2023-07-03  6:36 ` [PATCH 0/2] Two cross-compilation kselftest fixes Björn Töpel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230629162301.1234157-2-bjorn@kernel.org \
    --to=bjorn@kernel.org \
    --cc=adobriyan@gmail.com \
    --cc=anders.roxell@linaro.org \
    --cc=bjorn@rivosinc.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox