Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_all.sh: building csources 5X faster thanks to make -j #13300

Merged
merged 5 commits into from
Jan 31, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /bin/sh

# build development version of the compiler; can be rerun safely
# build development version of the compiler; can be rerun safely.
# arguments can be passed, eg `--cpu i386`

set -u # error on undefined variables
set -e # exit on first error
Expand All @@ -10,14 +11,26 @@ echo_run(){
"$@"
}

[ -d csources ] || echo_run git clone --depth 1 https://github.com/nim-lang/csources.git
[ -d csources ] || echo_run git clone -q --depth 1 https://github.com/nim-lang/csources.git

nim_csources=bin/nim_csources
build_nim_csources(){
## avoid changing dir in case of failure
(
echo_run cd csources
echo_run sh build.sh $@
if [[ $# -ne 0 ]]; then
# some args were passed (eg: `--cpu i386`), need to call build.sh
echo_run cd csources
echo_run sh build.sh $@
else
# no args, use multhreaded (5X faster on 16 cores: 10s instead of 50s)
makeX=make
unamestr=$(uname)
if [ "$unamestr" = 'FreeBSD' ]; then
makeX=gmake
fi
# `-j` implies `-j $(sysctl -n hw.ncpu)`
Copy link
Contributor

@kubo39 kubo39 Jan 31, 2020

Choose a reason for hiding this comment

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

man --help says -j: infinite jobs with no arg, at least Linux.

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, fixed; I wish these things were more portable

echo_run $makeX -C csources -j
fi
)
# keep $nim_csources in case needed to investigate bootstrap issues
# without having to rebuild from csources
Expand Down