This repository has been archived by the owner on Mar 7, 2021. It is now read-only.
kernel-cflags-finder: Set CONFIG_CC_IS_CLANG=y #227
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some of the things in the kernel's Makefile check whether
${CC} --version
is clang, which is affected by setting CC. Some look atCONFIG_CC_IS_CLANG, which was set at configuration time when our kernel
was built. We need to override the latter to get clang-compatible flags.
This causes the kernel to no longer set -W / -Wno flags that aren't
valid for clang, so we can get rid of
-Wno-unknown-warning-option
.One problem with the previous approach is that the kernel's Makefile
does feature detection to see what options are accepted by the current
compiler, and it doesn't accept custom CFLAGS early enough for them to
take effect during feature detection. Because the kernel sets
-Werror=unknown-warning-option
for clang (by checking the version of${CC}
, unfortunately), all attempts at feature detection would failwith an unrelated error. This causes Makefile to wrongly conclude that
the compiler doesn't support
-mfentry
and use mcount instead even ifthe compiled kernel expects fentry - i.e., this commit fixes #174.
We might eventually need to set CONFIG_CLANG_VERSION and perhaps unset
CONFIG_CC_IS_GCC, but this seems to work well enough for now.