Skip to content

Warn, not error, on precompile failures #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
35 changes: 23 additions & 12 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
macro warnpcfail(ex::Expr)
modl = __module__
file = __source__.file === nothing ? "?" : String(__source__.file)
line = __source__.line
quote
$(esc(ex)) || @warn """precompile directive
$($(Expr(:quote, ex)))
failed. Please report an issue in $($modl) (after checking for duplicates) or remove this directive.""" _file=$file _line=$line
end
end

function _precompile_()
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
normedtypes = (N0f8, N0f16) # precompiled Normed types
realtypes = (Float16, Float32, Float64, Int) # types for mixed Normed/Real operations
for T in normedtypes
for f in (+, -, abs, eps, rand) # unary operations
@assert precompile(Tuple{typeof(f),T})
@warnpcfail precompile(Tuple{typeof(f),T})
end
@assert precompile(Tuple{typeof(rand),T,Tuple{Int}})
@assert precompile(Tuple{typeof(rand),T,Tuple{Int,Int}})
@warnpcfail precompile(Tuple{typeof(rand),T,Tuple{Int}})
@warnpcfail precompile(Tuple{typeof(rand),T,Tuple{Int,Int}})
for f in (trunc, floor, ceil, round) # rounding operations
@assert precompile(Tuple{typeof(f),T})
@assert precompile(Tuple{typeof(f),Type{Int},T})
@warnpcfail precompile(Tuple{typeof(f),T})
@warnpcfail precompile(Tuple{typeof(f),Type{Int},T})
end
for f in (+, -, *, /, <, <=, ==) # binary operations
@assert precompile(Tuple{typeof(f),T,T})
@warnpcfail precompile(Tuple{typeof(f),T,T})
for S in realtypes
@assert precompile(Tuple{typeof(f),T,S})
@assert precompile(Tuple{typeof(f),S,T})
@warnpcfail precompile(Tuple{typeof(f),T,S})
@warnpcfail precompile(Tuple{typeof(f),S,T})
end
end
# conversions
for S in realtypes
@assert precompile(Tuple{Type{T},S})
@assert precompile(Tuple{Type{S},T})
@assert precompile(Tuple{typeof(convert),Type{T},S})
@assert precompile(Tuple{typeof(convert),Type{S},T})
@warnpcfail precompile(Tuple{Type{T},S})
@warnpcfail precompile(Tuple{Type{S},T})
@warnpcfail precompile(Tuple{typeof(convert),Type{T},S})
@warnpcfail precompile(Tuple{typeof(convert),Type{S},T})
end
end
end