mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-09-20 15:21:42 +01:00
Makefile: enable Thread Safety Analysis
Now that all locking code has been properly annotated, enable clang's Thread Safety Analysis. Two flags are available, -Wthread-safety, and the more recent -Wthread-safety-pointer. The former was introduced before clang gained RISC-V support, so it is guaranteed to be available. The latter was introduced in clang 21, so check if the provided compiler supports it before enabling it. Signed-off-by: Carlos López <carlos.lopezr4096@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260909162322.29778-16-carlos.lopezr4096@gmail.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -209,6 +209,9 @@ CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdl
|
||||
# Check whether the assembler and the compiler support the Vector extension
|
||||
CC_SUPPORT_VECTOR := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)gv -dM -E -x c /dev/null 2>&1 | grep -q riscv.*vector && echo y || echo n)
|
||||
|
||||
# Check whether the compiler supports -Wthread-safety-pointer (clang >= 22)
|
||||
CC_SUPPORT_WTHREAD_SAFETY_POINTER := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -Wthread-safety-pointer -x c /dev/null -o /dev/null 2>&1 | grep -q "unknown warning" && echo n || echo y)
|
||||
|
||||
ifneq ($(OPENSBI_LD_PIE),y)
|
||||
$(error Your linker does not support creating PIEs, opensbi requires this.)
|
||||
endif
|
||||
@@ -359,6 +362,10 @@ endif
|
||||
ifeq ($(CC_IS_CLANG),y)
|
||||
GENFLAGS += $(CLANG_TARGET)
|
||||
GENFLAGS += -Wno-unused-command-line-argument
|
||||
GENFLAGS += -Wthread-safety
|
||||
ifeq ($(CC_SUPPORT_WTHREAD_SAFETY_POINTER),y)
|
||||
GENFLAGS += -Wthread-safety-pointer
|
||||
endif
|
||||
endif
|
||||
GENFLAGS += -I$(platform_src_dir)/include
|
||||
GENFLAGS += -I$(include_dir)
|
||||
|
||||
Reference in New Issue
Block a user