-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Build for darwin-arm64 (Apple M1)
- `liblzma-config.sh`: If configure fails, run autogen.sh / autoconf (*) - refactor `build` action in `bindings.gyp` so that config and build scripts output is shown, making troubleshooting easier - `build` action refactored into `build` and `configure` actions with dependencies between them - since `configure` is a separate action instead of a command that runs as part of the 'input' key, it is free to output anything - script output is made less verbose and more clear, so it's not necessary to send to log file - this essentially means that configure & build could be the same script (configure is not run as part of configure stage of gyp) - for reference, add link to XZ library used to README.md (*) The drawback of this is that the fallback to autoconf requires a full autoconf type build environment, but it is a last resort fallback.
- Loading branch information
Showing
5 changed files
with
65 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.log | ||
build/ | ||
binding*/ | ||
node_modules/ | ||
|
@@ -8,3 +9,4 @@ README.md.xz | |
.nyc_output | ||
/.idea/ | ||
prebuilds/ | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
#!/bin/sh | ||
|
||
echo | ||
echo "--- liblzma-build.sh $*" | ||
echo "--- CWD = $PWD" | ||
echo | ||
|
||
set -e | ||
|
||
case $(uname | tr '[:upper:]' '[:lower:]') in | ||
*bsd) alias make='gmake';; | ||
*) | ||
esac | ||
|
||
cd "$1/liblzma" | ||
set -x | ||
cd "$1" && cd liblzma | ||
make | ||
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,57 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo | ||
echo "--- liblzma-config.sh $*" | ||
echo "--- CWD = $PWD" | ||
echo | ||
|
||
SRC_TARBALL="$2" | ||
TARGET_DIR="$1/liblzma" | ||
|
||
mkdir -p "$TARGET_DIR" | ||
|
||
tar xjf "$SRC_TARBALL" -C "$TARGET_DIR" || exit 1 | ||
|
||
cd "$TARGET_DIR" | ||
TARGET_DIR="$(pwd)" # ensure absolute since --prefix needs it | ||
|
||
function autoconf() { | ||
( cd xz-* ; sh ./autogen.sh --no-po4a ) | ||
return $? | ||
} | ||
|
||
tar xvjf "$SRC_TARBALL" >node_liblzma_config.log 2>&1 | ||
function configure() { | ||
sh xz-*/configure \ | ||
--quiet --enable-silent-rules \ | ||
--prefix="$TARGET_DIR/build" \ | ||
CFLAGS="-fPIC $CFLAGS" \ | ||
--enable-static \ | ||
--disable-xz \ | ||
--disable-xzdec \ | ||
--disable-lzmadec \ | ||
--disable-lzmainfo \ | ||
--disable-lzma-links \ | ||
--disable-rpath \ | ||
--disable-shared \ | ||
--disable-scripts | ||
return $? | ||
} | ||
|
||
export CFLAGS="-fPIC $CFLAGS" | ||
set -x | ||
|
||
# Fix build on Apple Silicon | ||
# FIXME: Remove after XZ 5.3 is released | ||
if [ $(uname) = "Darwin" -a $(uname -m) = "arm64" ]; then | ||
XZ_SRC_DIR=$(ls | grep xz-*) | ||
sed -i '' 's/\tnone)/\tarm64-*)\n\t\tbasic_machine=$(echo $basic_machine | sed "s\/arm64\/aarch64\/")\n\t\t;;\n\t\tnone)/g' $XZ_SRC_DIR/build-aux/config.sub | ||
echo "--- Patching config.sub for Apple Silicon" | ||
sed -i \ | ||
's/\tnone)/\tarm64-*)\n\t\tbasic_machine=$(echo $basic_machine | sed "s\/arm64\/aarch64\/")\n\t\t;;\n\t\tnone)/g' \ | ||
xz-*/build-aux/config.sub | ||
echo | ||
fi | ||
|
||
sh xz-*/configure --enable-static --disable-shared --disable-scripts --disable-lzmainfo \ | ||
--disable-lzma-links --disable-lzmadec --disable-xzdec --disable-xz --disable-rpath \ | ||
--prefix="$TARGET_DIR/build" CFLAGS="$CFLAGS" >>node_liblzma_config.log 2>&1 | ||
configure # || exit 1 # uncomment to disable use of autoconf | ||
if [ $? -ne 0 ] ; then | ||
echo | ||
echo "--- ./configure failed => trying to run autoconf first" | ||
echo "--- NOTE: This requires a full autoconf build environment, and so may also fail" | ||
echo | ||
autoconf && configure | ||
fi |