mirror of
https://github.com/torvalds/linux.git
synced 2026-04-19 23:34:00 -04:00
The signal Makefile rules pass all the dependencies for each executable, including headers, to the compiler which GCC is happy enough with but clang rejects: clang --target=aarch64-none-linux-gnu -fintegrated-as -Wall -O2 -g -I/home/broonie/git/linux/tools/testing/selftests/ -isystem /home/broonie/git/linux/usr/include -D_GNU_SOURCE -std=gnu99 -I. test_signals.c test_signals_utils.c testcases/testcases.c signals.S testcases/fake_sigreturn_bad_magic.c test_signals.h test_signals_utils.h testcases/testcases.h -o testcases/fake_sigreturn_bad_magic clang: error: cannot specify -o when generating multiple output files This happens because clang gets confused about what to do with the header files, failing to identify them as source. This is not amazing behaviour on clang's part and should ideally be fixed but even if that happens we'd still need a new clang release so let's instead rework the Makefile so we use variables for the lists of header and source files, allowing us to only pass the source files to the compiler and keep clang happy. As a bonus the resulting Makefile is a bit easier to read. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Link: https://lore.kernel.org/r/20230111-arm64-kselftest-clang-v1-3-89c69d377727@kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
32 lines
1.1 KiB
Makefile
32 lines
1.1 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (C) 2019 ARM Limited
|
|
|
|
# Additional include paths needed by kselftest.h and local headers
|
|
CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
|
|
|
|
SRCS := $(filter-out testcases/testcases.c,$(wildcard testcases/*.c))
|
|
PROGS := $(patsubst %.c,%,$(SRCS))
|
|
|
|
# Generated binaries to be installed by top KSFT script
|
|
TEST_GEN_PROGS := $(notdir $(PROGS))
|
|
|
|
# Get Kernel headers installed and use them.
|
|
|
|
# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list
|
|
# to account for any OUTPUT target-dirs optionally provided by
|
|
# the toplevel makefile
|
|
include ../../lib.mk
|
|
|
|
$(TEST_GEN_PROGS): $(PROGS)
|
|
cp $(PROGS) $(OUTPUT)/
|
|
|
|
# Common test-unit targets to build common-layout test-cases executables
|
|
# Needs secondary expansion to properly include the testcase c-file in pre-reqs
|
|
COMMON_SOURCES := test_signals.c test_signals_utils.c testcases/testcases.c \
|
|
signals.S
|
|
COMMON_HEADERS := test_signals.h test_signals_utils.h testcases/testcases.h
|
|
|
|
.SECONDEXPANSION:
|
|
$(PROGS): $$@.c ${COMMON_SOURCES} ${COMMON_HEADERS}
|
|
$(CC) $(CFLAGS) ${@}.c ${COMMON_SOURCES} -o $@
|