Skip to content

Commit

Permalink
Fix processor core count calculation for Mac (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanoKobalamyne authored Oct 9, 2024
1 parent 1f708c2 commit 5b313f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion contrib/setup-bison.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ if [ ! -f "$DEPS/bison-$VERSION.tar.xz" ]; then
exit 1
fi

if [ "$(uname)" == "Darwin" ]; then
NUM_CORES=$(sysctl -n hw.logicalcpu)
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
NUM_CORES=$(nproc)
else
NUM_CORES=1
fi

cd $DEPS
tar -xf bison-$VERSION.tar.xz
rm bison-$VERSION.tar.xz
mv ./bison-$VERSION ./bison
cd bison
mkdir bison-install
./configure --prefix $DEPS/bison/bison-install --exec-prefix $DEPS/bison/bison-install
make -j$(nproc)
make -j$NUM_CORES
make install
cd $DIR

Expand Down
10 changes: 9 additions & 1 deletion contrib/setup-flex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ if [ ! -f "$DEPS/flex-2.6.4.tar.gz" ]; then
exit 1
fi

if [ "$(uname)" == "Darwin" ]; then
NUM_CORES=$(sysctl -n hw.logicalcpu)
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
NUM_CORES=$(nproc)
else
NUM_CORES=1
fi

# Set CFLAGS to work around compiler issue with building flex
export CFLAGS="$CFLAGS -D_GNU_SOURCE"
cd $DEPS
Expand All @@ -28,7 +36,7 @@ mv flex-2.6.4 flex
cd flex
mkdir flex-install
./configure --prefix $DEPS/flex/flex-install --exec-prefix $DEPS/flex/flex-install
make -j$(nproc)
make -j$NUM_CORES
make install
cd $DIR

Expand Down

0 comments on commit 5b313f4

Please sign in to comment.