From 899a609bede22f783f7ffc143959891ec49bf0bb Mon Sep 17 00:00:00 2001 From: KristofferC Date: Fri, 2 Jul 2021 14:05:34 +0200 Subject: [PATCH 1/5] make failure to precompile a method a emit a debug log instead of a warn --- base/loading.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index 851ebf17cc3b9..5ed773d7affe2 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1928,7 +1928,7 @@ end function precompile(argt::Type) if ccall(:jl_compile_hint, Int32, (Any,), argt) == 0 - @warn "Inactive precompile statement" maxlog=100 form=argt _module=nothing _file=nothing _line=0 + @debug "Inactive precompile statement" form=argt _module=nothing _file=nothing _line=0 end true end From 2ee1fc4b59ca0a6e934531d0575d63c1918d1ca2 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 2 Jul 2021 16:26:31 +0200 Subject: [PATCH 2/5] Update base/loading.jl :shrug: I don't Co-authored-by: Jameson Nash --- base/loading.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index 5ed773d7affe2..bbcfd1da4b025 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1928,7 +1928,7 @@ end function precompile(argt::Type) if ccall(:jl_compile_hint, Int32, (Any,), argt) == 0 - @debug "Inactive precompile statement" form=argt _module=nothing _file=nothing _line=0 + @debug "Inactive precompile statement" maxlog=10 form=argt _module=nothing _file=nothing _line=0 end true end From 06a31a0c9ddb0fae4234c9c3359089eb1f4f665d Mon Sep 17 00:00:00 2001 From: KristofferC Date: Fri, 2 Jul 2021 16:31:00 +0200 Subject: [PATCH 3/5] fix return value of precompile --- base/loading.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index bbcfd1da4b025..bb2fe6015f359 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1927,10 +1927,11 @@ function precompile(@nospecialize(f), args::Tuple) end function precompile(argt::Type) - if ccall(:jl_compile_hint, Int32, (Any,), argt) == 0 + success = ccall(:jl_compile_hint, Int32, (Any,), argt) != 0 + if !success @debug "Inactive precompile statement" maxlog=10 form=argt _module=nothing _file=nothing _line=0 end - true + return success end precompile(include_package_for_output, (PkgId, String, Vector{String}, Vector{String}, Vector{String}, typeof(_concrete_dependencies), Nothing)) From f64aecdd86a91a241adb437fa80de501e7ea3fe0 Mon Sep 17 00:00:00 2001 From: KristofferC Date: Tue, 10 Aug 2021 10:10:06 +0200 Subject: [PATCH 4/5] go back to 1.6 version of precompile --- base/loading.jl | 8 +------- test/ambiguous.jl | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index bb2fe6015f359..2c6d9f5ea60bc 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1926,13 +1926,7 @@ function precompile(@nospecialize(f), args::Tuple) precompile(Tuple{Core.Typeof(f), args...}) end -function precompile(argt::Type) - success = ccall(:jl_compile_hint, Int32, (Any,), argt) != 0 - if !success - @debug "Inactive precompile statement" maxlog=10 form=argt _module=nothing _file=nothing _line=0 - end - return success -end +precompile(argt::Type) = ccall(:jl_compile_hint, Int32, (Any,), argt) != 0 precompile(include_package_for_output, (PkgId, String, Vector{String}, Vector{String}, Vector{String}, typeof(_concrete_dependencies), Nothing)) precompile(include_package_for_output, (PkgId, String, Vector{String}, Vector{String}, Vector{String}, typeof(_concrete_dependencies), String)) diff --git a/test/ambiguous.jl b/test/ambiguous.jl index 265d97776c053..0516d9a74e436 100644 --- a/test/ambiguous.jl +++ b/test/ambiguous.jl @@ -66,7 +66,7 @@ end ## Other ways of accessing functions # Test that non-ambiguous cases work let io = IOBuffer() - @test @test_logs precompile(ambig, (Int, Int)) + @test precompile(ambig, (Int, Int)) cf = @eval @cfunction(ambig, Int, (Int, Int)) @test ccall(cf, Int, (Int, Int), 1, 2) == 4 @test length(code_lowered(ambig, (Int, Int))) == 1 @@ -75,7 +75,7 @@ end # Test that ambiguous cases fail appropriately let io = IOBuffer() - @test @test_logs (:warn,) precompile(ambig, (UInt8, Int)) + @test !precompile(ambig, (UInt8, Int)) cf = @eval @cfunction(ambig, Int, (UInt8, Int)) # test for a crash (doesn't throw an error) @test_throws(MethodError(ambig, (UInt8(1), Int(2)), get_world_counter()), ccall(cf, Int, (UInt8, Int), 1, 2)) From deaeec762ba2fe86dda89aa4741772e4870e9c66 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Tue, 31 Aug 2021 10:28:54 +0200 Subject: [PATCH 5/5] Update base/loading.jl Co-authored-by: Tim Holy --- base/loading.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index 2c6d9f5ea60bc..8b3a64944e083 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1926,7 +1926,14 @@ function precompile(@nospecialize(f), args::Tuple) precompile(Tuple{Core.Typeof(f), args...}) end -precompile(argt::Type) = ccall(:jl_compile_hint, Int32, (Any,), argt) != 0 +const ENABLE_PRECOMPILE_WARNINGS = Ref(false) +function precompile(argt::Type) + ret = ccall(:jl_compile_hint, Int32, (Any,), argt) != 0 + if !ret && ENABLE_PRECOMPILE_WARNINGS[] + @warn "Inactive precompile statement" maxlog=100 form=argt _module=nothing _file=nothing _line=0 + end + return ret +end precompile(include_package_for_output, (PkgId, String, Vector{String}, Vector{String}, Vector{String}, typeof(_concrete_dependencies), Nothing)) precompile(include_package_for_output, (PkgId, String, Vector{String}, Vector{String}, Vector{String}, typeof(_concrete_dependencies), String))