Skip to content
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

small changes to make Base more statically compileable #53778

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

JeffBezanson
Copy link
Member

We (@gbaraldi @topolarity @vtjnash and I) have been seeing how far we can push static typing from applications (or library entry points) through Base, in order to do whole-program compilation where you don't need the JIT or IR or any unused code (similar to StaticCompiler.jl but with the full runtime available). Fortunately many of the barriers to this are just small changes to Base where we are doing silly things. This PR collects several of them.

The only thing here that's even slightly interesting is the changed definition of is_root_module. The problem here was that some fairly low-level printing and reflection functions call it, but it's not defined until loading.jl. When we try to infer it before then, the global is not defined so we infer it as Any. The new definition is much simpler. Maybe I'm missing something, but AFAICT it always gives the same answer.

These changes are from gb/small-image2.

@JeffBezanson
Copy link
Member Author

Do we know why the compileall test failed here?

@gbaraldi
Copy link
Member

It's failing everywhere, I'm trying to dig into it, probably a wrong GC_POP somewhere c.f #53770

@JeffBezanson JeffBezanson merged commit e0bb95a into master Mar 20, 2024
5 of 7 checks passed
@JeffBezanson JeffBezanson deleted the jb/morecompileable branch March 20, 2024 00:38
@IanButterworth
Copy link
Member

This appears to have introduced a Windows failure that failed on this PR


2024-03-19 12:22:54 EDT | Test Failed at C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:651
-- | --
  | 2024-03-19 12:22:54 EDT | Expression: begin
  | 2024-03-19 12:22:54 EDT | #= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:652 =#
  | 2024-03-19 12:22:54 EDT | exc = try
  | 2024-03-19 12:22:54 EDT | #= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:652 =#
  | 2024-03-19 12:22:54 EDT | include("./notarealfile.jl")
  | 2024-03-19 12:22:54 EDT | #= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:652 =#
  | 2024-03-19 12:22:54 EDT | "unexpectedly reached!"
  | 2024-03-19 12:22:54 EDT | catch exc
  | 2024-03-19 12:22:54 EDT | #= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:652 =#
  | 2024-03-19 12:22:54 EDT | exc
  | 2024-03-19 12:22:54 EDT | end
  | 2024-03-19 12:22:54 EDT | #= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:653 =#
  | 2024-03-19 12:22:54 EDT | #= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:653 =# @test exc isa SystemError
  | 2024-03-19 12:22:54 EDT | #= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:654 =#
  | 2024-03-19 12:22:54 EDT | exc.prefix
  | 2024-03-19 12:22:54 EDT | end == "opening file $(repr(joinpath(#= C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:655 =# @__DIR__(), "notarealfile.jl")))"
  | 2024-03-19 12:22:54 EDT | Evaluated: "opening file \"C:\\buildkite-agent\\builds\\win2k22-amdci6-1\\julialang\\julia-master\\julia-15a7f96d8d\\share\\julia\\test\\notarealfile.jl\"" == "opening file \"C:\\\\buildkite-agent\\\\builds\\\\win2k22-amdci6-1\\\\julialang\\\\julia-master\\\\julia-15a7f96d8d\\\\share\\\\julia\\\\test\\\\notarealfile.jl\""
  | 2024-03-19 12:22:54 EDT |  
  | 2024-03-19 12:22:54 EDT | Test Failed at C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:1545
  | 2024-03-19 12:22:54 EDT | Expression: include(file)
  | 2024-03-19 12:22:54 EDT | Expected: SystemError("opening file \"C:\\\\Users\\\\julia\\\\AppData\\\\Local\\\\Temp\\\\jl_oDwGXa\\\\dev\\\\non-existent.jl\"", 2, nothing)
  | 2024-03-19 12:22:54 EDT | Thrown: SystemError("opening file \"C:\\Users\\julia\\AppData\\Local\\Temp\\jl_oDwGXa\\dev\\non-existent.jl\"", 2, nothing)
  | 2024-03-19 12:22:54 EDT | SystemError: opening file "C:\Users\julia\AppData\Local\Temp\jl_oDwGXa\dev\non-existent.jl": No such file or directory
  | 2024-03-19 12:22:54 EDT | Stacktrace:
  | 2024-03-19 12:22:54 EDT | [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
  | 2024-03-19 12:22:54 EDT | @ Base .\error.jl:176
  | 2024-03-19 12:22:54 EDT | [2] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing)
  | 2024-03-19 12:22:54 EDT | @ Base .\iostream.jl:298
  | 2024-03-19 12:22:54 EDT | [3] open
  | 2024-03-19 12:22:54 EDT | @ .\iostream.jl:277 [inlined]
  | 2024-03-19 12:22:54 EDT | [4] open(f::Base.var"#474#475"{String}, args::String; kwargs::@Kwargs{})
  | 2024-03-19 12:22:54 EDT | @ Base .\io.jl:408
  | 2024-03-19 12:22:54 EDT | [5] open
  | 2024-03-19 12:22:54 EDT | @ .\io.jl:407 [inlined]
  | 2024-03-19 12:22:54 EDT | [6] read
  | 2024-03-19 12:22:54 EDT | @ .\io.jl:507 [inlined]
  | 2024-03-19 12:22:54 EDT | [7] _include(mapexpr::Function, mod::Module, _path::String)
  | 2024-03-19 12:22:54 EDT | @ Base .\loading.jl:2556
  | 2024-03-19 12:22:54 EDT | [8] include(mod::Module, _path::String)
  | 2024-03-19 12:22:54 EDT | @ Base .\Base.jl:559
  | 2024-03-19 12:22:54 EDT | [9] include
  | 2024-03-19 12:22:54 EDT | @ C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\testdefs.jl:16 [inlined]
  | 2024-03-19 12:22:54 EDT | [10] macro expansion
  | 2024-03-19 12:22:54 EDT | @ C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:9 [inlined]
  | 2024-03-19 12:22:54 EDT | [11] macro expansion
  | 2024-03-19 12:22:54 EDT | @ C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\stdlib\v1.12\Test\src\Test.jl:5 [inlined]
  | 2024-03-19 12:22:54 EDT | [12] (::Main.Test71Main_loading.var"#141#144")(depot::String)
  | 2024-03-19 12:22:54 EDT | @ Main.Test71Main_loading C:\buildkite-agent\builds\win2k22-amdci6-1\julialang\julia-master\julia-15a7f96d8d\share\julia\test\loading.jl:1545

IanButterworth added a commit that referenced this pull request Mar 21, 2024
Keno added a commit that referenced this pull request Mar 22, 2024
I considered changing the error message back, but I actually think
non-escaped filenames make more sense here, so I just adjusted
the test. We can do either though.
Keno added a commit that referenced this pull request Mar 22, 2024
I considered changing the error message back, but I actually think
non-escaped filenames make more sense here, so I just adjusted
the test. We can do either though.
IanButterworth added a commit that referenced this pull request Mar 22, 2024
IanButterworth added a commit that referenced this pull request Mar 22, 2024
Reverts #53778 which appears to have introduced a windows
failure

See
#53778 (comment)
@IanButterworth
Copy link
Member

This has been reverted #53808

JeffBezanson added a commit that referenced this pull request Mar 22, 2024
This makes it easier to fully-statically-type Base and init methods.
The changes are from gb/small-image2.
JeffBezanson added a commit that referenced this pull request Mar 22, 2024
This makes it easier to fully-statically-type Base and init methods.
The changes are from gb/small-image2.
Keno pushed a commit that referenced this pull request Mar 23, 2024
…" (#53820)

This makes it easier to fully-statically-type Base and init methods. The
changes are from gb/small-image2.
KristofferC pushed a commit to JuliaLang/LinearAlgebra.jl that referenced this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants