Skip to content

Commit cdc0e6c

Browse files
authored
updated configuration for armv7l-linux-gnueabihf (#302)
Long story short: `ErlNapiSInt64` defined in `erl_drv_nif.h` becomes signed 32-bit integer when cross-compiling for an `armv7l` target on an `x86_64` host. The old but gold `printf` debugging: case SQLITE_INTEGER: { int64_t value = sqlite3_column_int64(statement, i); sqlite_int64 v = value; printf("sqlite3_column_int64: int64_t %lld\r\n", value); printf("sqlite3_column_int64: sqlite_int64 %lld\r\n", v); printf("sizeof(ErlNapiSInt64): %ld\r\n", sizeof(ErlNapiSInt64)); return enif_make_int64(env, v); } Output: sqlite3_column_int64: int64_t 20221010123504 sqlite3_column_int64: sqlite_int64 20221010123504 sizeof(ErlNapiSInt64): 4 Signed-off-by: Cocoa <[email protected]>
1 parent 67786df commit cdc0e6c

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

.github/workflows/linux-precompile.yml

+53-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,59 @@ permissions:
99
contents: write
1010

1111
jobs:
12+
armv7l-linux-gnueabihf:
13+
runs-on: ubuntu-latest
14+
env:
15+
ARCH: armv7l
16+
TARGET: armv7l-linux-gnueabihf
17+
strategy:
18+
matrix:
19+
job:
20+
- {otp: "27.1.1", elixir: "1.17"}
21+
- {otp: "25.3.2.14", elixir: "1.16"}
22+
23+
name: Linux armv7l - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- uses: erlef/setup-beam@v1
29+
with:
30+
otp-version: ${{ matrix.job.otp }}
31+
elixir-version: ${{ matrix.job.elixir }}
32+
33+
- name: Install system dependecies
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y \
37+
build-essential automake autoconf pkg-config \
38+
bc m4 unzip zip gcc g++
39+
40+
- name: Install armv7l specific deps
41+
run: sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
42+
43+
- name: Create precompiled ${{ env.ARCH }} library
44+
run: |
45+
ROOTDIR="$(pwd)"
46+
OTP_ROOTDIR="${ROOTDIR}/.tools/otp"
47+
mkdir -p "${OTP_ROOTDIR}"
48+
cd "${OTP_ROOTDIR}"
49+
curl -fSL "https://github.com/cocoa-xu/otp-build/releases/download/v${{ matrix.job.otp }}/otp-${{ env.TARGET }}.tar.gz" -o "otp-${{ env.TARGET }}.tar.gz"
50+
tar -xzf "otp-${{ env.TARGET }}.tar.gz"
51+
cd "${ROOTDIR}"
52+
53+
export PRECOMPILE_ERL_EI_INCLUDE_DIR="${OTP_ROOTDIR}/usr/local/lib/erlang/usr/include"
54+
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
55+
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
56+
mix deps.get
57+
mix elixir_make.precompile
58+
59+
- uses: softprops/action-gh-release@v1
60+
if: startsWith(github.ref, 'refs/tags/')
61+
with:
62+
files: |
63+
cache/*${{ env.TARGET }}*.tar.gz
64+
1265
precompile:
1366
runs-on: ubuntu-20.04
1467
env:
@@ -44,7 +97,6 @@ jobs:
4497
if: matrix.arch == 'x86_64'
4598
run: |
4699
sudo apt-get install -y gcc-i686-linux-gnu g++-i686-linux-gnu \
47-
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
48100
gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
49101
gcc-s390x-linux-gnu g++-s390x-linux-gnu
50102

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ ifneq ($(EXQLITE_SYSTEM_CFLAGS),)
115115
endif
116116

117117
# Set Erlang-specific compile flags
118-
ERL_CFLAGS ?= -I"$(ERL_EI_INCLUDE_DIR)"
118+
ifeq ($(CC_PRECOMPILER_CURRENT_TARGET),armv7l-linux-gnueabihf)
119+
ERL_CFLAGS ?= -I"$(PRECOMPILE_ERL_EI_INCLUDE_DIR)"
120+
else
121+
ERL_CFLAGS ?= -I"$(ERL_EI_INCLUDE_DIR)"
122+
endif
119123

120124
ifneq ($(STATIC_ERLANG_NIF),)
121125
CFLAGS += -DSTATIC_ERLANG_NIF=1

0 commit comments

Comments
 (0)