Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752131AbeAPLAs (ORCPT + 1 other); Tue, 16 Jan 2018 06:00:48 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:41839 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750827AbeAPLAq (ORCPT ); Tue, 16 Jan 2018 06:00:46 -0500 X-Google-Smtp-Source: ACJfBouTxDTGdqUqPSatYegzkGVsApIP1s5t/Kg2dT1X9URFjsbrDK/O5YNV+Ed98ZuI50faaCIAMDUfjAi5B4vIR4k= MIME-Version: 1.0 In-Reply-To: <7273d0ce-3548-60f7-c331-bdf9bd9a3ec2@kernel.org> References: <20180105163323.22920-1-anders.roxell@linaro.org> <7273d0ce-3548-60f7-c331-bdf9bd9a3ec2@kernel.org> From: Anders Roxell Date: Tue, 16 Jan 2018 12:00:45 +0100 Message-ID: Subject: Re: [PATCH] selftests: sync: missing CFLAGS while compiling To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, tglx@linutronix.de, Kate Stewart , Philippe Ombredanne , Lei.Yang@windriver.com, Shuah Khan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 10 January 2018 at 01:05, Shuah Khan wrote: > On 01/05/2018 09:33 AM, Anders Roxell wrote: >> Based on patch: https://patchwork.kernel.org/patch/10042045/ >> >> arch64-linux-gnu-gcc -c sync.c -o sync/sync.o >> sync.c:42:29: fatal error: linux/sync_file.h: No such file or directory >> #include >> ^ >> CFLAGS is not used during the compile step, so the system instead of >> kernel headers are used. Fix this by using lib.mk's compile rules and >> remove CFLAGS from the linking step. > > Hmm. The changes don't match the change log. It odes more than just > removing LDFLAGS from compile step, oh, you are correct. I'm sorry. I will re-spin the patch and make the changelog reflect the actual change next time. > >> >> Reported-by: Lei Yang >> Signed-off-by: Anders Roxell >> --- >> tools/testing/selftests/sync/Makefile | 8 +------- >> 1 file changed, 1 insertion(+), 7 deletions(-) >> >> diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile >> index b3c8ba3cb668..58b9336d6c84 100644 >> --- a/tools/testing/selftests/sync/Makefile >> +++ b/tools/testing/selftests/sync/Makefile >> @@ -27,12 +27,6 @@ OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS)) >> TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS)) >> >> $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS) >> - $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS) > > So why not just delete $(LDFLAGS)?? > $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) > >> - >> -$(OBJS): $(OUTPUT)/%.o: %.c >> - $(CC) -c $^ -o $@ >> - >> -$(TESTS): $(OUTPUT)/%.o: %.c >> - $(CC) -c $^ -o $@ >> + $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(LDFLAGS) >> >> EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) >> > > I can't take this patch the way it is. It breaks the following > use-case: > > make O=/tmp/kselftest TARGETS=sync kselftest Oh, I've missed that use-case. Will fix that in the re-spin of the patch. To fix this build issue when cross compiling --- a/tools/testing/selftests/sync/Makefile +++ b/tools/testing/selftests/sync/Makefile @@ -30,7 +30,7 @@ $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS) $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS) $(OBJS): $(OUTPUT)/%.o: %.c - $(CC) -c $^ -o $@ + $(CC) -c $^ -o $@ $(CFLAGS) $(TESTS): $(OUTPUT)/%.o: %.c $(CC) -c $^ -o $@ The other issue that needs to be addressed somehow would be make the build system do headers_install or if that should be a prerequisite. I've seen ways to install the headers: "make -C ../../../.. headers_install" if the headers aren't there, in tools/testing/selftests/gpio/Makefile tools/testing/selftests/vm/Makefile Is that the preferred way or should an update in Documentation/dev-tools/kselftest.rst be done to say do "make headers_install" before building kselftests? Cheers, Anders > > thanks, > -- Shuah