Skip to content

Conversation

@eastWillow
Copy link
Contributor

@eastWillow eastWillow commented Oct 28, 2025

Why

I Live in slow and bad network environments, recursive variable assignments (=) in the Makefile can cause shell commands, such as wget for LINUX_DATA, to execute multiple times, significantly slowing down the build process.

How

By using simple assignment (:=), wget is executed only once during Makefile parsing. This reduces redundant network requests and improves overall Makefile execution speed.

How to Debug

make check SHELL="/bin/bash -x -e -o pipefail"

Before

Terminal Output
+ uname -s
+ uname -m
+ which sha1sum
+ which sha256sum
+ cc --version
+ grep emcc
+ head -n 1
+ cc --version
+ grep clang
+ head -n 1
+ cc --version
+ grep 'Free Software Foundation'
+ uname -m
+ which sdl2-config
+ pkg-config --exists SDL2_mixer
+ echo 0
+ mktemp
+ mktemp
+ mkdir -p /tmp/linux
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ sort -V
+ tail -n 1
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ sort -V
+ tail -n 1
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ sort -V
+ tail -n 1
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ sort -V
+ tail -n 1
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc
+ awk '{print $1}'
+ grep linux-6.1.157.tar.gz
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ sort -V
+ tail -n 1
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ sort -V
+ tail -n 1
+ mkdir -p /home/eastwillow/Documents/RISC-V/rv32emu/build/linux-x86-softfp /home/eastwillow/Documents/RISC-V/rv32emu/build/riscv32 /home/eastwillow/Documents/RISC-V/rv32emu/build/linux-image
+ echo '\033[33mPrebuilt benchmark is found. Skipping downloading.\033[0m\n'
\033[33mPrebuilt benchmark is found. Skipping downloading.\033[0m\n
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ sort -V
+ tail -n 1

After

Terminal Output
+ uname -s
+ uname -m
+ which sha1sum
+ which sha256sum
+ cc --version
+ head -n 1
+ grep emcc
+ cc --version
+ grep clang
+ head -n 1
+ cc --version
+ grep 'Free Software Foundation'
+ uname -m
+ which sdl2-config
+ pkg-config --exists SDL2_mixer
+ echo 0
+ mktemp
+ mktemp
+ mkdir -p /tmp/linux
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x
+ sort -V
+ grep -o 'linux-6.1.[0-9]\+\.tar.gz'
+ tail -n 1
+ wget -q -O- https://cdn.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc
+ grep linux-6.1.157.tar.gz
+ awk '{print $1}'
+ mkdir -p /home/eastwillow/Documents/RISC-V/rv32emu/build/linux-x86-softfp /home/eastwillow/Documents/RISC-V/rv32emu/build/riscv32 /home/eastwillow/Documents/RISC-V/rv32emu/build/linux-image
+ echo '\033[33mPrebuilt benchmark is found. Skipping downloading.\033[0m\n'

References


Summary by cubic

Switch LINUX_DATA and LINUX_DATA_SHA to simple assignment (:=) so wget runs once at parse time. This prevents repeated downloads and speeds up builds, especially on slow networks.

In slow network environments, recursive variable assignments (`=`)
in the Makefile can cause shell commands, such as `wget` for
`LINUX_DATA`, to execute multiple times,
significantly slowing down the build process.

By using simple assignment (`:=`), `wget` is executed only once
during Makefile parsing. This reduces redundant network requests
and improves overall Makefile execution speed.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@jserv
Copy link
Contributor

jserv commented Oct 28, 2025

Avoid inserting screenshots that contain only plain text, as visually impaired individuals may be unable to perceive or understand their content.

@jserv jserv merged commit a8a5b61 into sysprog21:master Oct 29, 2025
9 of 11 checks passed
@jserv
Copy link
Contributor

jserv commented Oct 29, 2025

Thank @eastWillow for contributing!

@eastWillow
Copy link
Contributor Author

Avoid inserting screenshots that contain only plain text, as visually impaired individuals may be unable to perceive or understand their content.

OK, I will modify the content.

@eastWillow eastWillow deleted the improve-makefile-speed branch October 29, 2025 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants