Commit graph android_kernel_sony_sdm845/Makefile
Message SHA1
kbuild: Add -Werror=unknown-warning-option to CLANG_FLAGS
[ Upstream commit 589834b3a0097a4908f4112eac0ca2feb486fa32 ]

In commit ebcc5928c5d9 ("arm64: Silence gcc warnings about arch ABI
drift"), the arm64 Makefile added -Wno-psabi to KBUILD_CFLAGS, which is
a GCC only option so clang rightfully complains:

warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]

https://clang.llvm.org/docs/DiagnosticsReference.html#wunknown-warning-option

However, by default, this is merely a warning so the build happily goes
on with a slew of these warnings in the process.

Commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to cc-option to
support clang") worked around this behavior in cc-option by adding
-Werror so that unknown flags cause an error. However, this all happens
silently and when an unknown flag is added to the build unconditionally
like -Wno-psabi, cc-option will always fail because there is always an
unknown flag in the list of flags. This manifested as link time failures
in the arm64 libstub because -fno-stack-protector didn't get added to
KBUILD_CFLAGS.

To avoid these weird cryptic failures in the future, make clang behave
like gcc and immediately error when it encounters an unknown flag by
adding -Werror=unknown-warning-option to CLANG_FLAGS. This can be added
unconditionally for clang because it is supported by at least 3.0.0,
according to godbolt [1] and 4.0.0, according to its documentation [2],
which is far earlier than we typically support.

[1]: https://godbolt.org/z/7F7rm3
[2]: https://releases.llvm.org/4.0.0/tools/clang/docs/DiagnosticsReference.html#wunknown-warning-option

Link: https://github.com/ClangBuiltLinux/linux/issues/511
Link: https://github.com/ClangBuiltLinux/linux/issues/517
Suggested-by: Peter Smith <peter.smith@linaro.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

Nathan Chancellor   authored and   Greg Kroah-Hartman   commited 2019-08-04 09:33:38 +02:00
7caebf6db7
Linux 4.9.186
Greg Kroah-Hartman   commited 2019-07-21 09:06:09 +02:00
35c308d782
Linux 4.9.185
Greg Kroah-Hartman   commited 2019-07-10 09:55:47 +02:00
9c51e1102c
gcc-9: silence 'address-of-packed-member' warning
commit 6f303d60534c46aa1a239f29c321f95c83dda748 upstream.

We already did this for clang, but now gcc has that warning too.  Yes,
yes, the address may be unaligned.  And that's kind of the point.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Linus Torvalds   authored and   Greg Kroah-Hartman   commited 2019-07-10 09:55:28 +02:00
7601d81506
Linux 4.9.184
Greg Kroah-Hartman   commited 2019-06-27 08:14:21 +08:00
09a7068360
Linux 4.9.183
Greg Kroah-Hartman   commited 2019-06-22 08:17:25 +02:00
72f67fd749
Linux 4.9.182
Greg Kroah-Hartman   commited 2019-06-17 19:53:33 +02:00
f4e2dd989e
Linux 4.9.181
Greg Kroah-Hartman   commited 2019-06-11 12:22:50 +02:00
3ffb2407c5
Linux 4.9.180
Greg Kroah-Hartman   commited 2019-05-31 06:48:32 -07:00
b16a5334ed
Linux 4.9.179
Greg Kroah-Hartman   commited 2019-05-25 18:26:58 +02:00
2584e66ffb
Linux 4.9.178
Greg Kroah-Hartman   commited 2019-05-21 18:49:01 +02:00
a5f56b52c8
Linux 4.9.177
Greg Kroah-Hartman   commited 2019-05-16 19:43:47 +02:00
8baec4ebdf
Linux 4.9.176
Greg Kroah-Hartman   commited 2019-05-14 19:19:42 +02:00
ffe8cffc8b
Linux 4.9.175
Greg Kroah-Hartman   commited 2019-05-10 17:52:11 +02:00
bb4f008d1e
Linux 4.9.174
Greg Kroah-Hartman   commited 2019-05-08 07:19:12 +02:00
d79b8577df
Linux 4.9.173
Greg Kroah-Hartman   commited 2019-05-04 08:49:10 +02:00
4b333b9c99
Linux 4.9.172
Greg Kroah-Hartman   commited 2019-05-02 09:32:07 +02:00
5383785aaa
Linux 4.9.171
Greg Kroah-Hartman   commited 2019-04-27 09:34:48 +02:00
6bff0bba46
Revert "kbuild: use -Oz instead of -Os when using clang"
commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream.

The clang option -Oz enables *aggressive* optimization for size,
which doesn't necessarily result in smaller images, but can have
negative impact on performance. Switch back to the less aggressive
-Os.

This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

Matthias Kaehlcke   authored and   Greg Kroah-Hartman   commited 2019-04-27 09:34:46 +02:00
6950577c4f
Linux 4.9.170
Greg Kroah-Hartman   commited 2019-04-20 09:07:54 +02:00
ad387ec4bc
Linux 4.9.169
Greg Kroah-Hartman   commited 2019-04-17 08:36:48 +02:00
df62169c33
kbuild: clang: choose GCC_TOOLCHAIN_DIR not on LD
commit ad15006cc78459d059af56729c4d9bed7c7fd860 upstream.

This causes an issue when trying to build with `make LD=ld.lld` if
ld.lld and the rest of your cross tools aren't in the same directory
(ex. /usr/local/bin) (as is the case for Android's build system), as the
GCC_TOOLCHAIN_DIR then gets set based on `which $(LD)` which will point
where LLVM tools are, not GCC/binutils tools are located.

Instead, select the GCC_TOOLCHAIN_DIR based on another tool provided by
binutils for which LLVM does not provide a substitute for, such as
elfedit.

Fixes: 785f11aa595b ("kbuild: Add better clang cross build support")
Link: https://github.com/ClangBuiltLinux/linux/issues/341
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

Nick Desaulniers   authored and   Greg Kroah-Hartman   commited 2019-04-17 08:36:38 +02:00
1347aa2a4d
Linux 4.9.168
Greg Kroah-Hartman   commited 2019-04-05 22:29:15 +02:00
e93d474911
Linux 4.9.167
Greg Kroah-Hartman   commited 2019-04-03 06:24:20 +02:00
21834d3e53
Linux 4.9.166
Greg Kroah-Hartman   commited 2019-03-27 14:13:05 +09:00
60771fc402
Linux 4.9.165
Greg Kroah-Hartman   commited 2019-03-23 13:19:54 +01:00
1c453afcda
Linux 4.9.164
Greg Kroah-Hartman   commited 2019-03-19 13:14:12 +01:00
f5fd34f057
Linux 4.9.163
Greg Kroah-Hartman   commited 2019-03-13 14:05:02 -07:00
b834331609
Linux 4.9.162
Greg Kroah-Hartman   commited 2019-03-05 17:57:07 +01:00
f422a02f86
Linux 4.9.161
Greg Kroah-Hartman   commited 2019-02-27 10:07:03 +01:00
5507839a72
kbuild: consolidate Clang compiler flags
commit 238bcbc4e07fad2fff99c5b157d0c37ccd4d093c upstream.

Collect basic Clang options such as --target, --prefix, --gcc-toolchain,
-no-integrated-as into a single variable CLANG_FLAGS so that it can be
easily reused in other parts of Makefile.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Masahiro Yamada   authored and   Greg Kroah-Hartman   commited 2019-02-27 10:07:03 +01:00
8ff3c2ecc1
kbuild: add -no-integrated-as Clang option unconditionally
commit dbe27a002ef8573168cb64e181458ea23a74e2b6 upstream.

We are still a way off the Clang's integrated assembler support for
the kernel. Hence, -no-integrated-as is mandatory to build the kernel
with Clang. If you had an ancient version of Clang that does not
recognize this option, you would not be able to compile the kernel
anyway.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Masahiro Yamada   authored and   Greg Kroah-Hartman   commited 2019-02-27 10:07:02 +01:00
c95a870d1c
kbuild: set no-integrated-as before incl. arch Makefile
commit 0f0e8de334c54c38818a4a5390a39aa09deff5bf upstream.

In order to make sure compiler flag detection for ARM works
correctly the no-integrated-as flags need to be set before
including the arch specific Makefile.

Fixes: cfe17c9bbe6a ("kbuild: move cc-option and cc-disable-warning after incl. arch Makefile")
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Backport to 4.9; adjust context due to a previous backport]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Stefan Agner   authored and   Greg Kroah-Hartman   commited 2019-02-27 10:07:02 +01:00
e1e7f343ea
kbuild: clang: disable unused variable warnings only when constant
commit 0a5f41767444cc3b4fc5573921ab914b4f78baaa upstream.

Currently, GCC disables -Wunused-const-variable, but not
-Wunused-variable, so warns unused variables if they are
non-constant.

While, Clang does not warn unused variables at all regardless of
the const qualifier because -Wno-unused-const-variable is implied
by the stronger option -Wno-unused-variable.

Disable -Wunused-const-variable instead of -Wunused-variable so that
GCC and Clang work in the same way.

Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Sodagudi Prasad   authored and   Greg Kroah-Hartman   commited 2019-02-27 10:07:02 +01:00
9362c0885a
kbuild: clang: remove crufty HOSTCFLAGS
commit df16aaac26e92e97ab7234d3f93c953466adc4b5 upstream.

When compiling with `make CC=clang HOSTCC=clang`, I was seeing warnings
that clang did not recognize -fno-delete-null-pointer-checks for HOSTCC
targets.  These were added in commit 61163efae0 ("kbuild: LLVMLinux:
Add Kbuild support for building kernel with Clang").

Clang does not support -fno-delete-null-pointer-checks, so adding it to
HOSTCFLAGS if HOSTCC is clang does not make sense.

It's not clear why the other warnings were disabled, and just for
HOSTCFLAGS, but I can remove them, add -Werror to HOSTCFLAGS and compile
with clang just fine.

Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Backport to 4.9; adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Nick Desaulniers   authored and   Greg Kroah-Hartman   commited 2019-02-27 10:07:02 +01:00
b018806f8a
kbuild: clang: fix build failures with sparse check
commit bb3f38c3c5b759163e09b9152629cc789731de47 upstream.

We should avoid using the space character when passing arguments to
clang, because static code analysis check tool such as sparse may
misinterpret the arguments followed by spaces as build targets hence
cause the build to fail.

Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Backport to 4.9; adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

David Lin   authored and   Greg Kroah-Hartman   commited 2019-02-27 10:07:02 +01:00
3f46fe4a39
kbuild: move cc-option and cc-disable-warning after incl. arch Makefile
commit cfe17c9bbe6a673fdafdab179c32b355ed447f66 upstream.

Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
incl. arch Makefile") broke cross-compilation using a cross-compiler
that supports less compiler options than the host compiler.

For example,

  cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"

This problem happens on architectures that setup CROSS_COMPILE in their
arch/*/Makefile.

Move the cc-option and cc-disable-warning back to the original position,
but keep the Clang target options untouched.

Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
[nc: Backport to 4.9; adjust context due to a previous backport]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Masahiro Yamada   authored and   Greg Kroah-Hartman   commited 2019-02-27 10:07:02 +01:00
b098b02285
Linux 4.9.160
Greg Kroah-Hartman   commited 2019-02-23 09:05:59 +01:00
badcc565e1
Linux 4.9.159
Greg Kroah-Hartman   commited 2019-02-20 10:18:35 +01:00
b9d7a53e4e
Linux 4.9.158
Greg Kroah-Hartman   commited 2019-02-15 09:07:33 +01:00
6ece8e403d
Linux 4.9.157
Greg Kroah-Hartman   commited 2019-02-15 08:07:39 +01:00
b7ec3f9121
Linux 4.9.156
Greg Kroah-Hartman   commited 2019-02-12 19:45:02 +01:00
8278355efb
Linux 4.9.155
Greg Kroah-Hartman   commited 2019-02-06 17:33:30 +01:00
6ebe34c1da
Linux 4.9.154
Greg Kroah-Hartman   commited 2019-01-31 08:12:37 +01:00
a4d0a0910e
Linux 4.9.153
Greg Kroah-Hartman   commited 2019-01-26 09:38:36 +01:00
189b75ad3f
Linux 4.9.152
Greg Kroah-Hartman   commited 2019-01-23 08:10:57 +01:00
ef50e3059a
Linux 4.9.151
Greg Kroah-Hartman   commited 2019-01-16 22:12:33 +01:00
008bfb9312
Linux 4.9.150
Greg Kroah-Hartman   commited 2019-01-13 10:03:55 +01:00
df6062688e
Linux 4.9.149
Greg Kroah-Hartman   commited 2019-01-09 16:16:45 +01:00
8a12358ba0
Linux 4.9.148
Greg Kroah-Hartman   commited 2018-12-29 13:40:16 +01:00
d99748864f