Skip to content

Commit

Permalink
Don't lose the return value of kernel build
Browse files Browse the repository at this point in the history
Let's avoid using `tee` for saving the kernel build log.
It swallows the return value from `make` that runs in Docker container.
Let's instead save the build log from outside.

That fixes the issue #3 and makes build logs more verbose.
  • Loading branch information
a13xp0p0v committed Sep 14, 2020
1 parent 5746e0b commit 598d56a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ Output subdirectory doesn't exist, create it
Copy kconfig to output subdirectory as ".config"
Going to save build log to "build_log.txt" in output subdirectory
Create additional arguments for cross-compilation: ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Run the container: bash ./run_container.sh gcc-8 /home/a13x/linux/linux /home/a13x/linux/build_out/experiment__aarch64__gcc-8 make O=~/out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j5 2>&1 | tee ~/out/build_log.txt
Run the container: bash ./run_container.sh gcc-8 /home/a13x/linux/linux /home/a13x/linux/build_out/experiment__aarch64__gcc-8 make O=~/out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j5 2>&1
Hey, we gonna use sudo for running docker
Starting "kernel-build-container:gcc-8"
Source code directory "/home/a13x/linux/linux" is mounted at "~/src"
Build output directory "/home/a13x/linux/build_out/experiment__aarch64__gcc-8" is mounted at "~/out"
Gonna run "make O=~/out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j5 2>&1 | tee ~/out/build_log.txt"
Gonna run "make O=~/out/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j5 2>&1"
make[1]: Entering directory '/home/a13x/out'
GEN Makefile
Expand Down
11 changes: 7 additions & 4 deletions make_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def build_kernel(arch, kconfig, src, out, compiler, make_args):
print('Copy kconfig to output subdirectory as ".config"')
shutil.copyfile(kconfig, out_subdir + '/.config')

build_log = 'build_log.txt'
print('Going to save build log to "{}" in output subdirectory'.format(build_log))
build_log = out_subdir + '/build_log.txt'
print('Going to save build log to "build_log.txt" in output subdirectory')
build_log_fd = open(build_log, "w")

run_container_cmd = ['bash', './run_container.sh', compiler, src, out_subdir, '-n', 'make', 'O=~/out/']

Expand All @@ -55,16 +56,18 @@ def build_kernel(arch, kconfig, src, out, compiler, make_args):

run_container_cmd.extend(make_args)

run_container_cmd.extend(['2>&1', '|', 'tee', '~/out/' + build_log])
run_container_cmd.extend(['2>&1'])

print('Run the container: {}'.format(' '.join(run_container_cmd)))
with subprocess.Popen(run_container_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True, bufsize=1) as process:
for line in process.stdout:
print(' {}'.format(line), end='\r')
build_log_fd.write(line)
return_code = process.wait()
print('Running the container returned {}'.format(return_code))
print('See build log: {}'.format(out_subdir + '/' + build_log))
print('See build log: {}'.format(build_log))
build_log_fd.close()


def build_kernels(arch, kconfig, src, out, compilers, make_args):
Expand Down

0 comments on commit 598d56a

Please sign in to comment.