Makefile: move stack-protector compiler breakage test earlier

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/2b8383927525d6281cbad1cc70a83d2319eeae47
Commit:     2b8383927525d6281cbad1cc70a83d2319eeae47
Parent:     4bf8ba811ac1102d7de6f73af3b9f323463e16c0
Refname:    refs/heads/master
Author:     Kees Cook <[email protected]>
AuthorDate: Tue Feb 6 15:37:38 2018 -0800
Committer:  Linus Torvalds <[email protected]>
CommitDate: Tue Feb 6 18:32:44 2018 -0800

    Makefile: move stack-protector compiler breakage test earlier
    
    In order to make stack-protector failures warn instead of unconditionally
    breaking the build, this moves the compiler output sanity-check earlier,
    and sets a flag for later testing.  Future patches can choose to warn or
    fail, depending on the flag value.
    
    Link: http://lkml.kernel.org/r/[email protected]
    Signed-off-by: Kees Cook <[email protected]>
    Tested-by: Laura Abbott <[email protected]>
    Cc: Masahiro Yamada <[email protected]>
    Cc: Arnd Bergmann <[email protected]>
    Cc: Josh Triplett <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>
---
 Makefile | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 0d49ff4022fb..20b1aa928d78 100644
--- a/Makefile
+++ b/Makefile
@@ -696,6 +696,12 @@ endif
 ifdef CONFIG_CC_STACKPROTECTOR
   stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh
   stackp-check := $(wildcard $(stackp-path))
+  # If the wildcard test matches a test script, run it to check functionality.
+  ifdef stackp-check
+    ifneq ($(shell $(CONFIG_SHELL) $(stackp-check) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
+      stackp-broken := y
+    endif
+  endif
 endif
 KBUILD_CFLAGS += $(stackp-flag)
 
@@ -1098,11 +1104,9 @@ ifdef stackp-name
   endif
 endif
 # Make sure compiler does not have buggy stack-protector support.
-ifdef stackp-check
-  ifneq ($(shell $(CONFIG_SHELL) $(stackp-check) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
+ifdef stackp-broken
 	@echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
                   $(stackp-flag) available but compiler is broken >&2 && exit 1
-  endif
 endif
 	@:
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.