diff mbox series

[2/2] selftests/vm: fix incorrect gcc invocation in some cases

Message ID 20200915012901.1655280-3-jhubbard@nvidia.com
State Accepted
Commit 34d109131f485eccd3f7e3050581eb73bffa3520
Headers show
Series [1/2] selftests/vm: fix false build success on the second and later attempts | expand

Commit Message

John Hubbard Sept. 15, 2020, 1:29 a.m. UTC
Avoid accidental wrong builds, due to built-in rules working just a
little bit too well--but not quite as well as required for our situation
here.

In other words, "make userfaultfd" (for example) is supposed to fail to
build at all, because this Makefile only supports either "make" (all),
or "make /full/path". However,  the built-in rules, if not suppressed,
will pick up CFLAGS and the initial LDLIBS (but not the target-specific
LDLIBS, because those are only set for the full path target!). This
causes it to get pretty far into building things despite using incorrect
values such as an *occasionally* incomplete LDLIBS value.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 tools/testing/selftests/vm/Makefile | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jason Gunthorpe Sept. 15, 2020, 5:25 p.m. UTC | #1
On Mon, Sep 14, 2020 at 06:29:01PM -0700, John Hubbard wrote:
> Avoid accidental wrong builds, due to built-in rules working just a

> little bit too well--but not quite as well as required for our situation

> here.

> 

> In other words, "make userfaultfd" (for example) is supposed to fail to

> build at all, because this Makefile only supports either "make" (all),

> or "make /full/path". However,  the built-in rules, if not suppressed,

> will pick up CFLAGS and the initial LDLIBS (but not the target-specific

> LDLIBS, because those are only set for the full path target!). This

> causes it to get pretty far into building things despite using incorrect

> values such as an *occasionally* incomplete LDLIBS value.

> 

> Signed-off-by: John Hubbard <jhubbard@nvidia.com>

> ---

>  tools/testing/selftests/vm/Makefile | 12 ++++++++++++

>  1 file changed, 12 insertions(+)


I hit this too when fiddling with the hmm tests! Would be happy to see
better errors

Jason
diff mbox series

Patch

diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 9f2625bebf07..30873b19d04b 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -8,6 +8,18 @@  MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/')
 # make invocations:
 .DELETE_ON_ERROR:
 
+# Avoid accidental wrong builds, due to built-in rules working just a little
+# bit too well--but not quite as well as required for our situation here.
+#
+# In other words, "make userfaultfd" is supposed to fail to build at all,
+# because this Makefile only supports either "make" (all), or "make /full/path".
+# However,  the built-in rules, if not suppressed, will pick up CFLAGS and the
+# initial LDLIBS (but not the target-specific LDLIBS, because those are only
+# set for the full path target!). This causes it to get pretty far into building
+# things despite using incorrect values such as an *occasionally* incomplete
+# LDLIBS.
+MAKEFLAGS += --no-builtin-rules
+
 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
 LDLIBS = -lrt
 TEST_GEN_FILES = compaction_test