Skip to content

Commit 558d008

Browse files
authored
Added precompilation support for musl targets (#244)
* add precompilation support for musl targets * using cc_precompiler v0.1.7
1 parent 105068e commit 558d008

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

.github/workflows/precompile.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,35 @@ jobs:
6060
if: matrix.os == 'ubuntu-20.04'
6161
run: |
6262
sudo apt-get update
63-
sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip \
63+
sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip wget \
6464
gcc g++ \
6565
gcc-i686-linux-gnu g++-i686-linux-gnu \
6666
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
6767
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
6868
gcc-riscv64-linux-gnu g++-riscv64-linux-gnu \
6969
gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
7070
gcc-s390x-linux-gnu g++-s390x-linux-gnu
71+
72+
- name: Get musl cross-compilers
73+
if: matrix.os == 'ubuntu-20.04'
74+
run: |
75+
for musl_arch in x86_64 aarch64 riscv64
76+
do
77+
wget "https://musl.cc/${musl_arch}-linux-musl-cross.tgz" -O "${musl_arch}-linux-musl-cross.tgz"
78+
tar -xf "${musl_arch}-linux-musl-cross.tgz"
79+
done
7180
7281
- name: Create precompiled library
7382
shell: bash
7483
run: |
7584
if [ "${{ matrix.os }}" = "macos-11" ]; then
7685
export ELIXIR_VER=1.14.3
7786
export PATH="${HOME}/.elixir/v${ELIXIR_VER}/bin:${PATH}"
87+
elif [ "${{ matrix.os }}" = "ubuntu-20.04" ]; then
88+
for musl_arch in x86_64 aarch64 riscv64
89+
do
90+
export PATH="$(pwd)/${musl_arch}-linux-musl-cross/bin:${PATH}"
91+
done
7892
fi
7993
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
8094
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"

mix.exs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule Exqlite.MixProject do
2121
versions: ["2.15", "2.16"],
2222
availability: &target_available_for_nif_version?/2
2323
],
24-
cc_precompiler: [cleanup: "clean"],
24+
cc_precompiler: cc_precompiler(),
2525
start_permanent: Mix.env() == :prod,
2626
aliases: aliases(),
2727
deps: deps(),
@@ -140,4 +140,24 @@ defmodule Exqlite.MixProject do
140140
plt_add_apps: ~w(table)a
141141
]
142142
end
143+
144+
defp cc_precompiler do
145+
[
146+
cleanup: "clean",
147+
compilers: %{
148+
{:unix, :linux} => %{
149+
:include_default_ones => true,
150+
"x86_64-linux-musl" => "x86_64-linux-musl-",
151+
"aarch64-linux-musl" => "aarch64-linux-musl-",
152+
"riscv64-linux-musl" => "riscv64-linux-musl-"
153+
},
154+
{:unix, :darwin} => %{
155+
:include_default_ones => true
156+
},
157+
{:win32, :nt} => %{
158+
:include_default_ones => true
159+
}
160+
}
161+
]
162+
end
143163
end

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%{
22
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
3-
"cc_precompiler": {:hex, :cc_precompiler, "0.1.5", "ac3ef86f31ab579b856192a948e956cc3e4bb5006e303c4ab4b24958108e218a", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "ee5b2e56eb03798231a3d322579fff509139a534ef54205d04c188e18cab1f57"},
3+
"cc_precompiler": {:hex, :cc_precompiler, "0.1.7", "77de20ac77f0e53f20ca82c563520af0237c301a1ec3ab3bc598e8a96c7ee5d9", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "2768b28bf3c2b4f788c995576b39b8cb5d47eb788526d93bd52206c1d8bf4b75"},
44
"connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
55
"credo": {:hex, :credo, "1.6.7", "323f5734350fd23a456f2688b9430e7d517afb313fbd38671b8a4449798a7854", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "41e110bfb007f7eda7f897c10bf019ceab9a0b269ce79f015d54b0dcf4fc7dd3"},
66
"db_connection": {:hex, :db_connection, "2.4.2", "f92e79aff2375299a16bcb069a14ee8615c3414863a6fef93156aee8e86c2ff3", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4fe53ca91b99f55ea249693a0229356a08f4d1a7931d8ffa79289b145fe83668"},

0 commit comments

Comments
 (0)