Precompile statement emitter sometimes emits invalid statements #28808
Comments
|
As already mentioned in #32574 I also stumbled upon this recently. As of now I am aware of three cases in which the output is not correct. Case 1Types with symbols as parameters which need to be escaped, e.g. contain a backslash (this is the case you mention) foo(::T) where T = 1
struct A{B} end
foo(A{Symbol("a\\b")})Output: I have already fixed this case in tehrengruber@0fed122 (will open a pull request at some point) Case 2Types with symbols as parameters generated via Output: Case 3Types with a Output: The origin of the problem is in Line 986 in faefe2a Char (4 bytes) is traversed bytewise in reverse order, hence resulting in 0x56000000 instead of 0x00000056. I have no clue whats the reason for this ordering. @JeffBezanson you wrote this piece of code, any reason for the ordering that I'm overlooking here?
Edit One thought further I recognized that the reason for the reverse byte ordering is endianess. |
…c_show_x_ (partially fixes JuliaLang#28808)
…c_show_x_ (partially fixes JuliaLang#28808)
…c_show_x_ (partially fixes JuliaLang#28808)
…c_show_x_ (partially fixes JuliaLang#28808)
For implementing special syntax it's useful for typed comprehension to lower to `collect(T, gen)`. This changes typed comprehensions to use the same lowering pattern as normal comprehensions. Needed to tweak the precompile workaround from #28808 Co-authored-by: Andy Ferris <ferris.andy@gmail.com>
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails.
…e_precompile file (JuliaLang#32910)
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails.
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails. (cherry picked from commit c0478d8)
|
We also sometimes generate code with invalid |
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails. (cherry picked from commit c0478d8)
|
Regarding
This is now addressable thanks to the cool So i think we just need to find whatever code is dumping the This would be a very similar exercise to that taken in #34888. |
|
I'm working on addressing It's fixed on that branch, and now i'm just following up with a couple other small improvements to |
|
Via the logging added to PackageCompiler in JuliaLang/PackageCompiler.jl#457, I've identified two more classes of failures. One of them might just need to be fixed in PackageCompiler, but I think the other one needs to be fixed in julia: Case 4 - Incorrectly emitting
|
|
For your case 4, these are likely due to partial inference (e.g., from being called by a But I do think Julia should not complain about precompiling that signature. |
|
Oh interesting, thanks!
Yeah, agreed! this seems like it might be a bug. I've checked, and these statements are emitted again when re-running my snoop file with the resulting sysimg, so I do not believe they are being statically compiled. Thanks for the context, @timholy |
|
Yeah, indeed I think |
|
(okay and indeed Case 5 was related to PackageCompiler; i've opened a PR here: JuliaLang/PackageCompiler.jl#463) |
|
Alright, and finally Class 6:
|
|
Could Case 6 be from invalidations or type piracy? Have you tried the "double sysimage" trick (JuliaLang/PackageCompiler.jl#429)? Basically, you compile a sysimage, and then using that sysimage as the base, you compile the sysimage again. At that point, all invalidations should have been resolved. |
|
Oh, wow! Thanks for the link; I hadn't seen that. That's very fascinating. Could it explain a very simple case like the one I show above, where we're literally just precompiling the one single function? Is the idea that i should then run PackageCompiler starting from the sysimg and compile a new sysimg? |
Yes, and use |
|
Hrmm no dice. :( I ran Thanks for the info though; i'll look into applying this to our build overall. (though currently static compilation takes about an hour, so running it twice is a tough pill to swallow... |
|
This is also an issue for printf statements. As @KristofferC helped me debug on slack: julia> precompile(Tuple{typeof(Printf.format), Base.TTY, Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Base.Val{Char(0x67000000)}}, Printf.Spec{Base.Val{Char(0x67000000)}}, Printf.Spec{Base.Val{Char(0x67000000)}}, Printf.Spec{Base.Val{Char(0x67000000)}}}}, Float64, Float64, Vararg{Float64, N} where N})
ERROR: Base.CodePointError{UInt32}(0x67000000)
Stacktrace:
[1] code_point_err(u::UInt32)
@ Base ./char.jl:86
[2] Char(u::UInt32)
@ Base ./char.jl:160
[3] top-level scope
@ REPL[3]:1 |
|
I think that is Case 3 in #28808 (comment). |
Our printing for precompile statements is not 100% reliable (JuliaLang#28808) and can fail. I introduced the extra `parse` call in the Varargs change, but because of JuliaLang#28808, it needs to go inside the try/catch.
Our printing for precompile statements is not 100% reliable (JuliaLang#28808) and can fail. I introduced the extra `parse` call in the Varargs change, but because of JuliaLang#28808, it needs to go inside the try/catch.


This is OK:
But running with
trace-compile=stderrwe can see the following precompile statement being generatedwhich contains an unescaped
\in theDateFormattype. Encountering such a type in precompilation gathering means it will fail.The text was updated successfully, but these errors were encountered: