From 0e9986b6a3baec0bbb366d8d1c0f37b02e31ec95 Mon Sep 17 00:00:00 2001 From: Cocoa Date: Mon, 13 Mar 2023 18:32:34 +0000 Subject: [PATCH 1/5] add precompilation support for musl targets --- .github/workflows/precompile.yml | 15 +++++++++++- mix.exs | 39 +++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/.github/workflows/precompile.yml b/.github/workflows/precompile.yml index 26b85e8d..ffed569b 100644 --- a/.github/workflows/precompile.yml +++ b/.github/workflows/precompile.yml @@ -60,7 +60,7 @@ jobs: if: matrix.os == 'ubuntu-20.04' run: | sudo apt-get update - sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip \ + sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip wget \ gcc g++ \ gcc-i686-linux-gnu g++-i686-linux-gnu \ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ @@ -68,6 +68,15 @@ jobs: gcc-riscv64-linux-gnu g++-riscv64-linux-gnu \ gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \ gcc-s390x-linux-gnu g++-s390x-linux-gnu + + - name: Get musl cross-compilers + if: matrix.os == 'ubuntu-20.04' + run: | + for musl_arch in x86_64 aarch64 riscv64 + do + wget "https://musl.cc/${musl_arch}-linux-musl-cross.tgz" -O "${musl_arch}-linux-musl-cross.tgz" + tar -xf "${musl_arch}-linux-musl-cross.tgz" + done - name: Create precompiled library shell: bash @@ -75,6 +84,10 @@ jobs: if [ "${{ matrix.os }}" = "macos-11" ]; then export ELIXIR_VER=1.14.3 export PATH="${HOME}/.elixir/v${ELIXIR_VER}/bin:${PATH}" + elif [ "${{ matrix.os }}" = "ubuntu-20.04" ]; then + for musl_arch in x86_64 aarch64 riscv64 + export PATH="$(pwd)/${musl_arch}-linux-musl-cross/bin:${PATH}" + done fi export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache mkdir -p "${ELIXIR_MAKE_CACHE_DIR}" diff --git a/mix.exs b/mix.exs index 902e61c7..5d4eeb61 100644 --- a/mix.exs +++ b/mix.exs @@ -21,7 +21,7 @@ defmodule Exqlite.MixProject do versions: ["2.15", "2.16"], availability: &target_available_for_nif_version?/2 ], - cc_precompiler: [cleanup: "clean"], + cc_precompiler: cc_precompiler(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), @@ -140,4 +140,41 @@ defmodule Exqlite.MixProject do plt_add_apps: ~w(table)a ] end + + defp cc_precompiler do + [ + cleanup: "clean", + compilers: %{ + {:unix, :linux} => %{ + "x86_64-linux-gnu" => "x86_64-linux-gnu-", + "i686-linux-gnu" => "i686-linux-gnu-", + "aarch64-linux-gnu" => "aarch64-linux-gnu-", + "armv7l-linux-gnueabihf" => "arm-linux-gnueabihf-", + "riscv64-linux-gnu" => "riscv64-linux-gnu-", + "powerpc64le-linux-gnu" => "powerpc64le-linux-gnu-", + "s390x-linux-gnu" => "s390x-linux-gnu-", + "x86_64-linux-musl" => "x86_64-linux-musl-", + "aarch64-linux-musl" => "aarch64-linux-musl-", + "riscv64-linux-musl" => "riscv64-linux-musl-" + }, + {:unix, :darwin} => %{ + "x86_64-apple-darwin" => { + "gcc", + "g++", + "<%= cc %> -arch x86_64", + "<%= cxx %> -arch x86_64" + }, + "aarch64-apple-darwin" => { + "gcc", + "g++", + "<%= cc %> -arch arm64", + "<%= cxx %> -arch arm64" + } + }, + {:win32, :nt} => %{ + "x86_64-windows-msvc" => {"cl", "cl"} + } + } + ] + end end From d58cc4252e5e816fabc807a88083a333c3c42f85 Mon Sep 17 00:00:00 2001 From: Cocoa Date: Mon, 13 Mar 2023 18:50:46 +0000 Subject: [PATCH 2/5] add precompilation support for musl targets --- .github/workflows/precompile.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/precompile.yml b/.github/workflows/precompile.yml index ffed569b..bcb97480 100644 --- a/.github/workflows/precompile.yml +++ b/.github/workflows/precompile.yml @@ -86,6 +86,7 @@ jobs: export PATH="${HOME}/.elixir/v${ELIXIR_VER}/bin:${PATH}" elif [ "${{ matrix.os }}" = "ubuntu-20.04" ]; then for musl_arch in x86_64 aarch64 riscv64 + do export PATH="$(pwd)/${musl_arch}-linux-musl-cross/bin:${PATH}" done fi From e490893b6ca26bdf435967ed7fe856a75d2ccdda Mon Sep 17 00:00:00 2001 From: Cocoa Date: Mon, 13 Mar 2023 19:41:35 +0000 Subject: [PATCH 3/5] using cc_precompiler v0.1.7 --- mix.exs | 23 +++-------------------- mix.lock | 2 +- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/mix.exs b/mix.exs index 5d4eeb61..a6f19580 100644 --- a/mix.exs +++ b/mix.exs @@ -146,33 +146,16 @@ defmodule Exqlite.MixProject do cleanup: "clean", compilers: %{ {:unix, :linux} => %{ - "x86_64-linux-gnu" => "x86_64-linux-gnu-", - "i686-linux-gnu" => "i686-linux-gnu-", - "aarch64-linux-gnu" => "aarch64-linux-gnu-", - "armv7l-linux-gnueabihf" => "arm-linux-gnueabihf-", - "riscv64-linux-gnu" => "riscv64-linux-gnu-", - "powerpc64le-linux-gnu" => "powerpc64le-linux-gnu-", - "s390x-linux-gnu" => "s390x-linux-gnu-", + :include_default_ones => true, "x86_64-linux-musl" => "x86_64-linux-musl-", "aarch64-linux-musl" => "aarch64-linux-musl-", "riscv64-linux-musl" => "riscv64-linux-musl-" }, {:unix, :darwin} => %{ - "x86_64-apple-darwin" => { - "gcc", - "g++", - "<%= cc %> -arch x86_64", - "<%= cxx %> -arch x86_64" - }, - "aarch64-apple-darwin" => { - "gcc", - "g++", - "<%= cc %> -arch arm64", - "<%= cxx %> -arch arm64" - } + :include_default_ones => true, }, {:win32, :nt} => %{ - "x86_64-windows-msvc" => {"cl", "cl"} + :include_default_ones => true, } } ] diff --git a/mix.lock b/mix.lock index d4c963c3..07b8e577 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,6 @@ %{ "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, - "cc_precompiler": {:hex, :cc_precompiler, "0.1.5", "ac3ef86f31ab579b856192a948e956cc3e4bb5006e303c4ab4b24958108e218a", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "ee5b2e56eb03798231a3d322579fff509139a534ef54205d04c188e18cab1f57"}, + "cc_precompiler": {:hex, :cc_precompiler, "0.1.7", "5c059b12706b583436da20b275230265bcd5f499845a12dd1d123c14bb63c06c", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "ec1242323c47f8d5b1fbdd858ab4aabe898a6cbef3e90c837986508d139f25ed"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, "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"}, "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"}, From a3c0c9fbfc0d3dc7189e3b53228fe33db06df039 Mon Sep 17 00:00:00 2001 From: Cocoa Date: Mon, 13 Mar 2023 19:58:34 +0000 Subject: [PATCH 4/5] using cc_precompiler v0.1.7 --- mix.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.lock b/mix.lock index 07b8e577..0d1429e4 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,6 @@ %{ "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, - "cc_precompiler": {:hex, :cc_precompiler, "0.1.7", "5c059b12706b583436da20b275230265bcd5f499845a12dd1d123c14bb63c06c", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "ec1242323c47f8d5b1fbdd858ab4aabe898a6cbef3e90c837986508d139f25ed"}, + "cc_precompiler": {:hex, :cc_precompiler, "0.1.7", "77de20ac77f0e53f20ca82c563520af0237c301a1ec3ab3bc598e8a96c7ee5d9", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "2768b28bf3c2b4f788c995576b39b8cb5d47eb788526d93bd52206c1d8bf4b75"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, "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"}, "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"}, From 0641a849a048909bc781941ce79d10320b3a0100 Mon Sep 17 00:00:00 2001 From: Cocoa Date: Mon, 13 Mar 2023 20:00:24 +0000 Subject: [PATCH 5/5] mix format --- mix.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index a6f19580..3582ac4d 100644 --- a/mix.exs +++ b/mix.exs @@ -152,10 +152,10 @@ defmodule Exqlite.MixProject do "riscv64-linux-musl" => "riscv64-linux-musl-" }, {:unix, :darwin} => %{ - :include_default_ones => true, + :include_default_ones => true }, {:win32, :nt} => %{ - :include_default_ones => true, + :include_default_ones => true } } ]