Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/JLLWrappers.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
module JLLWrappers

if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@compiler_options"))
@eval Base.Experimental.@compiler_options compile=min optimize=0 infer=false
@static if VERSION >= v"1.6.0-DEV"
using Preferences
end

if VERSION >= v"1.6.0-DEV"
using Preferences
@static if VERSION >= v"1.6.0-DEV"
const disable_optimization = @load_preference("disable_optimization", true)
else
const disable_optimization = true
end

@static if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@compiler_options"))
if disable_optimization
@eval Base.Experimental.@compiler_options compile=min optimize=0 infer=false
end
end

const global_typeassert_available = VERSION >= v"1.9.0-"
Expand Down
5 changes: 4 additions & 1 deletion src/toplevel_generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ end
generate_compiler_options(src_name)

Because JLL packages do not contain code that benefits much from compiler optimizations,
we disable them for a sizable boost in first load time.
we disable them for a sizable boost in first load time. This can be opted out of by
setting the `disable_optimization` JLLWrappers preference to `false`.
"""
function generate_compiler_options(src_name)
JLLWrappers.disable_optimization || return nothing

# Newer Julias have `@compiler_options` that can enable interpreted mode
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@compiler_options"))
return quote
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ end; end

module TestJLL end
@testset "JLLWrappers.jl" begin
@test JLLWrappers.disable_optimization === true
mktempdir() do dir
Pkg.activate(dir)

Expand Down
Loading