kbuild: disable Android-specific compiler features
PATCH 1/1 kbuild: disable Android-specific compiler features
The Android compilers enable some non-standard features by default. While most Android build systems inject the needed "-mno-android" option via KCFLAGS, it happens too late (at least on x86_64), since KBUILD_CFLAGS gains KCFLAGS after running (and failing) many cc-option tests. (For example, the stack-protector tests happen after arch-specific KBUILD_CFLAGS are added but before the external KCFLAGS are added.) As such, we should notice this option and immediately turn it on as the first cc-option test we run.
--- Makefile | 4 ++++ 1 file changed, 4 insertions(+)
Makefile +4 -0
@@ -393,6 +393,10 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Wno-format-security \ -std=gnu89 +# We must turn off the Android-specific compiler options as early as possible +# otherwise cc-option calls below may erroneously fail. +KBUILD_CFLAGS += $(call cc-option,-mno-android,) + KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS := -D__ASSEMBLY__
Signature · 6 lines
2.6.3 -- Kees Cook Chrome OS & Brillo Security
Quoted 10 lines · Kees Cook
The Android compilers enable some non-standard features by default. While most Android build systems inject the needed "-mno-android" option via KCFLAGS, it happens too late (at least on
x86_64), sinceKBUILD_CFLAGSgains KCFLAGS after running (and failing) many cc-option tests. (For example, the stack-protector tests happen after arch-specificKBUILD_CFLAGSare added but before the external KCFLAGS are added.) As such, we should notice this option and immediately turn it on as the first cc-option test we run.Signed-off-by Kees Cook <[email protected]>
Michal, is this okay? I'd like to get it into -next soon if possible.
Thanks!
-Kees
Quoted 26 lines
--- Makefile | 4 ++++ 1 file changed, 4 insertions(+)Makefile +4
-1@@ -393,6 +393,10 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Wno-format-security \ -std=gnu89 +# We must turn off the Android-specific compiler options as early as possible +# otherwise cc-option calls below may erroneously fail. +KBUILD_CFLAGS += $(call cc-option,-mno-android,) + KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS := -D__ASSEMBLY__ --2.6.3
--
Kees Cook
Chrome OS & Brillo Security
Signature · 2 lines
Kees Cook Chrome OS & Brillo Security
Dne 18.2.2016 v 00:03 Kees Cook napsal(a):
Quoted 10 lines · Kees Cook
Quoted 9 lines
The Android compilers enable some non-standard features by default. While most Android build systems inject the needed "-mno-android" option via KCFLAGS, it happens too late (at least on
x86_64), sinceKBUILD_CFLAGSgains KCFLAGS after running (and failing) many cc-option tests. (For example, the stack-protector tests happen after arch-specificKBUILD_CFLAGSare added but before the external KCFLAGS are added.) As such, we should notice this option and immediately turn it on as the first cc-option test we run.
Quoted 3 lines
Quoted 1 line
Signed-off-by Kees Cook <[email protected]>Michal, is this okay? I'd like to get it into -next soon if possible.
Is there a way to detect these compilers and are there some canonical versions of these? I do not think it's a good idea to add workaround for each random gcc fork.
Michal
Quoted 11 lines · Michal Marek
Dne 18.2.2016 v 00:03 Kees Cook napsal(a):
Quoted 10 lines · Kees Cook
Quoted 9 lines
The Android compilers enable some non-standard features by default. While most Android build systems inject the needed "-mno-android" option via KCFLAGS, it happens too late (at least on
x86_64), sinceKBUILD_CFLAGSgains KCFLAGS after running (and failing) many cc-option tests. (For example, the stack-protector tests happen after arch-specificKBUILD_CFLAGSare added but before the external KCFLAGS are added.) As such, we should notice this option and immediately turn it on as the first cc-option test we run.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Kees Cook <[email protected]>Michal, is this okay? I'd like to get it into -next soon if possible.
Is there a way to detect these compilers and are there some canonical versions of these? I do not think it's a good idea to add workaround for each random gcc fork.
It's detectable by -mno-android being a valid option. It's not a random gcc fork, as it's part of the Android SDK gcc prebuilts that all Android vendors and hobbiests use to build their kernels.
-Kees
Signature · 2 lines
Kees Cook Chrome OS & Brillo Security