Skip to content

Commit

Permalink
tc_build: kernel: Disable -Werror configurations
Browse files Browse the repository at this point in the history
For now, we do this only for allmodconfig, as KCFLAGS=-Werror has worked
without any issues until this point.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
  • Loading branch information
nathanchance committed Jun 17, 2024
1 parent a6d85bc commit 2fc0ec6
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions tc_build/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path
import shutil
import subprocess
from tempfile import NamedTemporaryFile
import time

from tc_build.builder import Builder
Expand All @@ -23,7 +24,7 @@ def __init__(self, arch):

self.bolt_instrumentation = False
self.bolt_sampling_output = None
self.config_targets = None
self.config_targets = []
self.cross_compile = None
self.make_variables = {
'ARCH': arch,
Expand Down Expand Up @@ -60,6 +61,34 @@ def build(self):
self.make_variables['LLVM_IAS'] = '0'
self.make_variables['O'] = self.folders.build

self.clean_build_folder()

kconfig_allconfig = None
# allmodconfig enables CONFIG_WERROR and other subsystem specific
# -Werror configurations. Ensure all known configurations get disabled
# via KCONFIG_ALLCONFIG, as they may override KCFLAGS=-Werror.
if 'allmodconfig' in self.config_targets:
self.folders.build.mkdir(parents=True)

# Using a context manager for this would seriously convolute this
# code, as we need to use the name of the object in make_cmd but
# delete it after actually running the command so the rest of the
# code after this function would need another level of indent. We
# know that from this point forward, the function can only throw an
# exception when calling make_cmd, so we can just wrap that in a
# try: ... finally: ... statement to ensure that this file is
# always cleaned up.
# pylint: disable-next=consider-using-with
kconfig_allconfig = NamedTemporaryFile(dir=self.folders.build)

configs_to_disable = ['DRM_WERROR', 'WERROR']
kconfig_allconfig_text = ''.join(f"CONFIG_{val}=n\n"
for val in configs_to_disable).encode('utf-8')

kconfig_allconfig.write(kconfig_allconfig_text)
kconfig_allconfig.seek(0)
self.make_variables['KCONFIG_ALLCONFIG'] = kconfig_allconfig.name

make_cmd = []
if self.bolt_sampling_output:
make_cmd += [
Expand All @@ -77,9 +106,12 @@ def build(self):
# Ideally, the kernel would always clobber user flags via ':=' but we deal with reality.
os.environ.pop('CFLAGS', '')

self.clean_build_folder()
build_start = time.time()
self.run_cmd(make_cmd)
try:
self.run_cmd(make_cmd)
finally:
if kconfig_allconfig:
kconfig_allconfig.close()
tc_build.utils.print_info(f"Build duration: {tc_build.utils.get_duration(build_start)}")

def can_use_ias(self):
Expand Down

0 comments on commit 2fc0ec6

Please sign in to comment.