Skip to content

Commit fb33678

Browse files
committed
Add more cross-compilation options
- arm64-darwin from x86_64-darwin (also added to CI) - x86_64-darwin from arm64-darwin - x86_64-linux from aarch64-linux
1 parent 2cb523d commit fb33678

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ jobs:
7373
matrix:
7474
platform:
7575
- x86_64
76-
# arm64
76+
- arm64
7777
name: Build (darwin)
7878
outputs:
7979
GEM_VERSION: ${{ steps.set-metadata.outputs.GEM_VERSION }}
8080
runs-on: macos-12
81+
env:
82+
TARGET_PLATFORM: ${{ matrix.platform }}-darwin
83+
RUBY_TARGET_PLATFORM: ${{ matrix.platform }}-darwin
8184
steps:
8285
- name: Checkout
8386
uses: actions/checkout@v2

libexec/build-libv8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ eval "$("${libexec}/platform")"
2929
echo "configure: ${configure_flags}"
3030
echo "compilers: CC='${CC}' CXX='${CXX}' CC_host='${CC_host:-}' CXX_host='${CXX_host:-}'"
3131

32-
"${CC}" -v
33-
"${CXX}" -v
32+
${CC} -v
33+
${CXX} -v
3434

3535
# shellcheck disable=SC2086
3636
"${PYTHON}" configure ${configure_flags}

libexec/platform

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fi
1616

1717
STRIP="${STRIP:-strip}"
1818

19-
triple=$("${CC}" -dumpmachine)
19+
triple=$(${CC} -dumpmachine)
2020
host_platform="${triple}"
2121
target_platform="${TARGET_PLATFORM:-${1:-}}"
2222
target_platform="${target_platform:-${host_platform}}"
@@ -42,14 +42,17 @@ case "${target_platform}" in
4242
;;
4343
x86_64*-darwin*)
4444
# not for cross compilation
45-
RUBY_TARGET_PLATFORM="$(ruby -e 'puts Gem::Platform.local.to_s.gsub(/-darwin-?\d+/, "-darwin")')"
45+
RUBY_TARGET_PLATFORM='x86_64-darwin'
4646
;;
4747
arm64*-darwin*)
4848
# not for cross compilation
49-
RUBY_TARGET_PLATFORM="$(ruby -e 'puts Gem::Platform.local.to_s.gsub(/-darwin-?\d+/, "-darwin")')"
49+
RUBY_TARGET_PLATFORM='arm64-darwin'
5050
;;
5151
*)
52-
# not for cross compilation
52+
if [ "${host_platform}" != "${target_platform}" ]; then
53+
echo 'cross compilation not supported'
54+
exit 1
55+
fi
5356
RUBY_TARGET_PLATFORM="$(ruby -e 'puts Gem::Platform.local.to_s')"
5457
;;
5558
esac
@@ -81,6 +84,30 @@ if [ "${host_platform}" != "${target_platform}" ]; then
8184
STRIP='arm-linux-gnueabihf-strip'
8285
configure_flags='--dest-cpu=arm --cross-compiling --dest-os=linux --with-arm-float-abi=hard --with-arm-fpu=neon'
8386
;;
87+
x86_64-*linux*)
88+
CC='x86_64-linux-gnu-gcc'
89+
CXX='x86_64-linux-gnu-g++'
90+
CC_host='gcc'
91+
CXX_host='g++'
92+
STRIP='x86_64-linux-gnu-strip'
93+
configure_flags='--dest-cpu=x86_64 --cross-compiling --dest-os=linux'
94+
;;
95+
x86_64*-darwin*)
96+
CC='clang -arch x86_64'
97+
CXX='clang++ -arch x86_64'
98+
CC_host='clang'
99+
CXX_host='clang++'
100+
STRIP='strip'
101+
configure_flags='--dest-cpu=x86_64 --cross-compiling --dest-os=mac'
102+
;;
103+
arm64*-darwin*)
104+
CC='clang -arch arm64'
105+
CXX='clang++ -arch arm64'
106+
CC_host='clang'
107+
CXX_host='clang++'
108+
STRIP='strip'
109+
configure_flags='--dest-cpu=arm64 --cross-compiling --dest-os=mac'
110+
;;
84111
*)
85112
configure_flags=''
86113
;;

0 commit comments

Comments
 (0)