public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: add -MP to CFLAGS
@ 2023-10-28 19:34 David Woodhouse
  2023-10-29 21:13 ` David Laight
  2023-11-30  1:44 ` Sean Christopherson
  0 siblings, 2 replies; 6+ messages in thread
From: David Woodhouse @ 2023-10-28 19:34 UTC (permalink / raw)
  To: kvm; +Cc: Paolo Bonzini, Shuah Khan, linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1153 bytes --]

From: David Woodhouse <dwmw@amazon.co.uk>

Using -MD without -MP causes build failures when a header file is deleted
or moved. With -MP, the compiler will emit phony targets for the header
files it lists as dependencies, and the Makefiles won't refuse to attempt
to rebuild a C unit which no longer includes the deleted header.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 tools/testing/selftests/kvm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index a3bb36fb3cfc..20ea549da570 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -211,7 +211,7 @@ else
 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
 endif
 CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
-	-Wno-gnu-variable-sized-type-not-at-end -MD\
+	-Wno-gnu-variable-sized-type-not-at-end -MD -MP \
 	-fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \
 	-fno-builtin-strnlen \
 	-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
-- 
2.41.0



[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH] KVM: selftests: add -MP to CFLAGS
  2023-10-28 19:34 [PATCH] KVM: selftests: add -MP to CFLAGS David Woodhouse
@ 2023-10-29 21:13 ` David Laight
  2023-10-30  9:45   ` David Woodhouse
  2023-11-30  1:44 ` Sean Christopherson
  1 sibling, 1 reply; 6+ messages in thread
From: David Laight @ 2023-10-29 21:13 UTC (permalink / raw)
  To: 'David Woodhouse', kvm@vger.kernel.org
  Cc: Paolo Bonzini, Shuah Khan, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org

From: David Woodhouse
> Sent: 28 October 2023 20:35
> 
> Using -MD without -MP causes build failures when a header file is deleted
> or moved. With -MP, the compiler will emit phony targets for the header
> files it lists as dependencies, and the Makefiles won't refuse to attempt
> to rebuild a C unit which no longer includes the deleted header.

Won't a phony target stop a header being built if there is
an actual rule to build it?

I usually add:

%.h:
	echo "Ignoring stale dependency for $@"

Which only applies if there isn't an explicit rule.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: selftests: add -MP to CFLAGS
  2023-10-29 21:13 ` David Laight
@ 2023-10-30  9:45   ` David Woodhouse
  2023-10-30 10:08     ` David Laight
  0 siblings, 1 reply; 6+ messages in thread
From: David Woodhouse @ 2023-10-30  9:45 UTC (permalink / raw)
  To: David Laight, kvm@vger.kernel.org
  Cc: Paolo Bonzini, Shuah Khan, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 666 bytes --]

On Sun, 2023-10-29 at 21:13 +0000, David Laight wrote:
> From: David Woodhouse
> > Sent: 28 October 2023 20:35
> > 
> > Using -MD without -MP causes build failures when a header file is deleted
> > or moved. With -MP, the compiler will emit phony targets for the header
> > files it lists as dependencies, and the Makefiles won't refuse to attempt
> > to rebuild a C unit which no longer includes the deleted header.
> 
> Won't a phony target stop a header being built if there is
> an actual rule to build it?

It probably would have taken you about the same time to find the answer
for yourself, as it took to write that email. Why don't you try it?

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] KVM: selftests: add -MP to CFLAGS
  2023-10-30  9:45   ` David Woodhouse
@ 2023-10-30 10:08     ` David Laight
  2023-10-30 10:22       ` David Woodhouse
  0 siblings, 1 reply; 6+ messages in thread
From: David Laight @ 2023-10-30 10:08 UTC (permalink / raw)
  To: 'David Woodhouse', kvm@vger.kernel.org
  Cc: Paolo Bonzini, Shuah Khan, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org

From: David Woodhouse
> Sent: 30 October 2023 09:46
> 
> On Sun, 2023-10-29 at 21:13 +0000, David Laight wrote:
> > From: David Woodhouse
> > > Sent: 28 October 2023 20:35
> > >
> > > Using -MD without -MP causes build failures when a header file is deleted
> > > or moved. With -MP, the compiler will emit phony targets for the header
> > > files it lists as dependencies, and the Makefiles won't refuse to attempt
> > > to rebuild a C unit which no longer includes the deleted header.
> >
> > Won't a phony target stop a header being built if there is
> > an actual rule to build it?
> 
> It probably would have taken you about the same time to find the answer
> for yourself, as it took to write that email. Why don't you try it?

I was sure that just adding

foo.h:

would generate a 'no rules to build' error.
Maybe that was BSD make or SYS-V make.

But calling the 'phony' is probably wrong.
PHONY has a very specific meaning to make - and these aren't PHONY.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: selftests: add -MP to CFLAGS
  2023-10-30 10:08     ` David Laight
@ 2023-10-30 10:22       ` David Woodhouse
  0 siblings, 0 replies; 6+ messages in thread
From: David Woodhouse @ 2023-10-30 10:22 UTC (permalink / raw)
  To: David Laight, kvm@vger.kernel.org
  Cc: Paolo Bonzini, Shuah Khan, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 1246 bytes --]

On Mon, 2023-10-30 at 10:08 +0000, David Laight wrote:
> From: David Woodhouse
> > Sent: 30 October 2023 09:46
> > 
> > On Sun, 2023-10-29 at 21:13 +0000, David Laight wrote:
> > > From: David Woodhouse
> > > > Sent: 28 October 2023 20:35
> > > > 
> > > > Using -MD without -MP causes build failures when a header file is deleted
> > > > or moved. With -MP, the compiler will emit phony targets for the header
> > > > files it lists as dependencies, and the Makefiles won't refuse to attempt
> > > > to rebuild a C unit which no longer includes the deleted header.
> > > 
> > > Won't a phony target stop a header being built if there is
> > > an actual rule to build it?
> > 
> > It probably would have taken you about the same time to find the answer
> > for yourself, as it took to write that email. Why don't you try it?
> 
> I was sure that just adding
> 
> foo.h:
> 
> would generate a 'no rules to build' error.
> Maybe that was BSD make or SYS-V make.
> 
> But calling the 'phony' is probably wrong.
> PHONY has a very specific meaning to make - and these aren't PHONY.

I recommend filing a bug against the GCC documentation then.

https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-MP



[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] KVM: selftests: add -MP to CFLAGS
  2023-10-28 19:34 [PATCH] KVM: selftests: add -MP to CFLAGS David Woodhouse
  2023-10-29 21:13 ` David Laight
@ 2023-11-30  1:44 ` Sean Christopherson
  1 sibling, 0 replies; 6+ messages in thread
From: Sean Christopherson @ 2023-11-30  1:44 UTC (permalink / raw)
  To: Sean Christopherson, kvm, David Woodhouse
  Cc: Paolo Bonzini, Shuah Khan, linux-kselftest, linux-kernel

On Sat, 28 Oct 2023 20:34:53 +0100, David Woodhouse wrote:
> Using -MD without -MP causes build failures when a header file is deleted
> or moved. With -MP, the compiler will emit phony targets for the header
> files it lists as dependencies, and the Makefiles won't refuse to attempt
> to rebuild a C unit which no longer includes the deleted header.
> 
> 

Applied to kvm-x86 selftests, thanks!

[1/1] KVM: selftests: add -MP to CFLAGS
      https://github.com/kvm-x86/linux/commit/fc6543bb55d4

--
https://github.com/kvm-x86/linux/tree/next

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-30  1:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-28 19:34 [PATCH] KVM: selftests: add -MP to CFLAGS David Woodhouse
2023-10-29 21:13 ` David Laight
2023-10-30  9:45   ` David Woodhouse
2023-10-30 10:08     ` David Laight
2023-10-30 10:22       ` David Woodhouse
2023-11-30  1:44 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox