Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Add support for linuxstatic armv7 binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer authored and jesec committed May 29, 2021
1 parent 7530a93 commit 27e00d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/build-linuxstatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ jobs:
fail-fast: false
matrix:
target-node: [10, 12, 14, 16]
target-arch: [x64, arm64]
target-arch: [x64, arm64, armv7]
include:
- target-arch: x64
target-toolchain: x86_64
target-triple: x86_64-linux-musl
host-arch: x86_64
- target-arch: arm64
target-toolchain: aarch64
target-triple: aarch64-linux-musl
host-arch: x86_64
- target-arch: armv7
target-triple: armv7l-linux-musleabihf
host-arch: i686

steps:
- uses: actions/checkout@v2
Expand All @@ -28,7 +33,8 @@ jobs:
uses: docker/build-push-action@v2
with:
build-args: |
TARGET_TOOLCHAIN_ARCH=${{ matrix.target-toolchain }}
HOST_ARCH=${{ matrix.host-arch }}
TARGET_TRIPLE=${{ matrix.target-triple }}
PKG_FETCH_OPTION_a=${{ matrix.target-arch }}
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
PKG_FETCH_OPTION_p=linuxstatic
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG TARGET_TOOLCHAIN_ARCH
ARG HOST_ARCH=x86_64
ARG TARGET_TRIPLE=aarch64-linux-musl

FROM muslcc/x86_64:$TARGET_TOOLCHAIN_ARCH-linux-musl
FROM muslcc/$HOST_ARCH:$TARGET_TRIPLE

ARG PKG_FETCH_OPTION_a
ARG PKG_FETCH_OPTION_n
Expand Down
9 changes: 9 additions & 0 deletions lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ async function compileOnUnix(
args.push('--dest-cpu', cpu);
}

if (targetArch === 'armv7') {
const { CFLAGS = '', CXXFLAGS = '' } = process.env;
process.env.CFLAGS = `${CFLAGS} -marm -mcpu=cortex-a7`;
process.env.CXXFLAGS = `${CXXFLAGS} -marm -mcpu=cortex-a7`;

args.push('--with-arm-float-abi=hard');
args.push('--with-arm-fpu=vfpv3');
}

if (hostArch !== targetArch) {
log.warn('Cross compiling!');
log.warn('You are responsible for appropriate env like CC, CC_host, etc.');
Expand Down

0 comments on commit 27e00d1

Please sign in to comment.