From 4b1523bf44451e473b50ee31d08b10228dc6f250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sat, 8 May 2021 16:11:13 +0100 Subject: [PATCH] Use non-`const` libraries only on Musl systems with Julia v1.6 The non-`const` library variable generates worse code because of the presence of a trampoline, but the non-`const` is really needed only for Musl-based systems. --- .github/workflows/ci.yml | 4 ++-- Project.toml | 2 +- src/JLLWrappers.jl | 1 + src/products/library_generators.jl | 6 ++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e9e740..12f9b3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - "1.3" - "1.4" - "1.5" - - "^1.6.0-0" + - "1.6" - "nightly" os: - ubuntu-latest @@ -38,7 +38,7 @@ jobs: version: ${{ matrix.julia-version }} arch: ${{ matrix.julia-arch }} - name: Cache artifacts - uses: actions/cache@v1 + uses: actions/cache@v2 env: cache-name: cache-artifacts with: diff --git a/Project.toml b/Project.toml index 659bc1f..1c537b6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JLLWrappers" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" authors = ["Mosè Giordano", "Elliot Saba"] -version = "1.3.0" +version = "1.4.0" [deps] Preferences = "21216c6a-2e73-6563-6e65-726566657250" diff --git a/src/JLLWrappers.jl b/src/JLLWrappers.jl index d885b77..36ba913 100644 --- a/src/JLLWrappers.jl +++ b/src/JLLWrappers.jl @@ -6,6 +6,7 @@ end if VERSION >= v"1.6.0-DEV" using Preferences + using Base.BinaryPlatforms end # We need to glue expressions together a lot diff --git a/src/products/library_generators.jl b/src/products/library_generators.jl index 4603c06..a05e9bf 100644 --- a/src/products/library_generators.jl +++ b/src/products/library_generators.jl @@ -2,7 +2,7 @@ macro declare_library_product(product_name, product_soname) handle_name = Symbol(string(product_name, "_handle")) get_path_name = Symbol(string("get_", product_name, "_path")) path_name = Symbol(string(product_name, "_path")) - @static if VERSION < v"1.6.0-DEV" + @static if VERSION < v"1.6.0-DEV" || libc(HostPlatform()) != "musl" lib_declaration = quote # On Julia 1.5-, this must be `const` and must be the SONAME const $(product_name) = $(product_soname) @@ -10,6 +10,7 @@ macro declare_library_product(product_name, product_soname) else lib_declaration = quote # On Julia 1.6+, this doesn't have to be `const`! Thanks Jeff! + # But this is needed only for Musl-based platforms. $(product_name) = "" end end @@ -28,11 +29,12 @@ macro declare_library_product(product_name, product_soname) end function init_new_library_product(product_name) - @static if VERSION < v"1.6.0-DEV" + @static if VERSION < v"1.6.0-DEV" || libc(HostPlatform()) != "musl" return nothing else return quote # Initialize non-const variable export with the path to this product + # for Musl-based platforms. global $(product_name) = $(Symbol(string(product_name, "_path"))) end end