Skip to content

Commit

Permalink
Use non-const libraries only on Musl systems with Julia v1.6
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
giordano committed May 8, 2021
1 parent dd045e0 commit 4b1523b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- "1.3"
- "1.4"
- "1.5"
- "^1.6.0-0"
- "1.6"
- "nightly"
os:
- ubuntu-latest
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/JLLWrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/products/library_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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)
end
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
Expand All @@ -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
Expand Down

0 comments on commit 4b1523b

Please sign in to comment.