diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 615f96c03..90839dea5 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -44,24 +44,22 @@ include("ad.jl") import PrecompileTools -PrecompileTools.@compile_workload begin - for T in (Float32, Float64) - prob = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2)) - - precompile_algs = if VERSION ≥ v"1.7" - (NewtonRaphson(), TrustRegion(), LevenbergMarquardt()) - else - (NewtonRaphson(),) - end - - for alg in precompile_algs - solve(prob, alg, abstol = T(1e-2)) - end - - prob = NonlinearProblem{true}((du, u, p) -> du[1] = u[1] * u[1] - p[1], T[0.1], - T[2]) - for alg in precompile_algs - solve(prob, alg, abstol = T(1e-2)) +@static if VERSION >= v"1.10" + PrecompileTools.@compile_workload begin + for T in (Float32, Float64) + prob = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2)) + + precompile_algs = (NewtonRaphson(), TrustRegion(), LevenbergMarquardt()) + + for alg in precompile_algs + solve(prob, alg, abstol = T(1e-2)) + end + + prob = NonlinearProblem{true}((du, u, p) -> du[1] = u[1] * u[1] - p[1], T[0.1], + T[2]) + for alg in precompile_algs + solve(prob, alg, abstol = T(1e-2)) + end end end end