Skip to content

Commit d68a04e

Browse files
Revert "small changes to make Base more statically compileable" (#53808)
Reverts #53778 which appears to have introduced a windows failure See #53778 (comment)
1 parent 9291845 commit d68a04e

File tree

13 files changed

+28
-34
lines changed

13 files changed

+28
-34
lines changed

base/boot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ function is_top_bit_set(x::Union{Int8,UInt8})
769769
end
770770

771771
# n.b. This function exists for CUDA to overload to configure error behavior (see #48097)
772-
throw_inexacterror(func::Symbol, to, val) = throw(InexactError(func, to, val))
772+
throw_inexacterror(args...) = throw(InexactError(args...))
773773

774774
function check_sign_bit(::Type{To}, x) where {To}
775775
@inline

base/compiler/utilities.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ end
498498
# options #
499499
###########
500500

501+
is_root_module(m::Module) = false
502+
501503
inlining_enabled() = (JLOptions().can_inline == 1)
502504

503505
function coverage_enabled(m::Module)

base/error.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ macro assert(ex, msgs...)
228228
msg = Main.Base.string(msg)
229229
else
230230
# string() might not be defined during bootstrap
231-
msg = :(_assert_tostring($(Expr(:quote,msg))))
231+
msg = quote
232+
msg = $(Expr(:quote,msg))
233+
isdefined(Main, :Base) ? Main.Base.string(msg) :
234+
(Core.println(msg); "Error during bootstrap. See stdout.")
235+
end
232236
end
233237
return :($(esc(ex)) ? $(nothing) : throw(AssertionError($msg)))
234238
end
235239

236-
# this may be overridden in contexts where `string(::Expr)` doesn't work
237-
_assert_tostring(msg) = isdefined(Main, :Base) ? Main.Base.string(msg) :
238-
(Core.println(msg); "Error during bootstrap. See stdout.")
239-
240240
struct ExponentialBackOff
241241
n::Int
242242
first_delay::Float64

base/errorshow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ end
400400

401401
#Show an error by directly calling jl_printf.
402402
#Useful in Base submodule __init__ functions where stderr isn't defined yet.
403-
function showerror_nostdio(@nospecialize(err), msg::AbstractString)
403+
function showerror_nostdio(err, msg::AbstractString)
404404
stderr_stream = ccall(:jl_stderr_stream, Ptr{Cvoid}, ())
405405
ccall(:jl_printf, Cint, (Ptr{Cvoid},Cstring), stderr_stream, msg)
406406
ccall(:jl_printf, Cint, (Ptr{Cvoid},Cstring), stderr_stream, ":\n")

base/initdefs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A string containing the script name passed to Julia from the command line. Note
99
script name remains unchanged from within included files. Alternatively see
1010
[`@__FILE__`](@ref).
1111
"""
12-
global PROGRAM_FILE::String = ""
12+
global PROGRAM_FILE = ""
1313

1414
"""
1515
ARGS
@@ -480,7 +480,7 @@ end
480480

481481
## hook for disabling threaded libraries ##
482482

483-
library_threading_enabled::Bool = true
483+
library_threading_enabled = true
484484
const disable_library_threading_hooks = []
485485

486486
function at_disable_library_threading(f)

base/iostream.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,12 @@ function open(fname::String; lock = true,
292292
if !lock
293293
s._dolock = false
294294
end
295-
if ccall(:ios_file, Ptr{Cvoid},
296-
(Ptr{UInt8}, Cstring, Cint, Cint, Cint, Cint),
297-
s.ios, fname, flags.read, flags.write, flags.create, flags.truncate) == C_NULL
298-
systemerror("opening file \"$fname\"")
299-
end
295+
systemerror("opening file $(repr(fname))",
296+
ccall(:ios_file, Ptr{Cvoid},
297+
(Ptr{UInt8}, Cstring, Cint, Cint, Cint, Cint),
298+
s.ios, fname, flags.read, flags.write, flags.create, flags.truncate) == C_NULL)
300299
if flags.append
301-
if ccall(:ios_seek_end, Int64, (Ptr{Cvoid},), s.ios) != 0
302-
systemerror("seeking to end of file \"$fname\"")
303-
end
300+
systemerror("seeking to end of file $fname", ccall(:ios_seek_end, Int64, (Ptr{Cvoid},), s.ios) != 0)
304301
end
305302
return s
306303
end

base/libuv.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ function uv_asynccb end
134134
function uv_timercb end
135135

136136
function reinit_stdio()
137-
global stdin = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ()))::IO
138-
global stdout = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ()))::IO
139-
global stderr = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ()))::IO
137+
global stdin = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ()))
138+
global stdout = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ()))
139+
global stderr = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ()))
140140
opts = JLOptions()
141141
if opts.color != 0
142142
have_color = (opts.color == 1)

base/loading.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,7 @@ const explicit_loaded_modules = Dict{PkgId,Module}()
22052205
const loaded_modules_order = Vector{Module}()
22062206
const module_keys = IdDict{Module,PkgId}() # the reverse
22072207

2208+
is_root_module(m::Module) = @lock require_lock haskey(module_keys, m)
22082209
root_module_key(m::Module) = @lock require_lock module_keys[m]
22092210

22102211
@constprop :none function register_root_module(m::Module)
@@ -3415,9 +3416,9 @@ function check_clone_targets(clone_targets)
34153416
end
34163417

34173418
# Set by FileWatching.__init__()
3418-
global mkpidlock_hook::Any
3419-
global trymkpidlock_hook::Any
3420-
global parse_pidfile_hook::Any
3419+
global mkpidlock_hook
3420+
global trymkpidlock_hook
3421+
global parse_pidfile_hook
34213422

34223423
# The preferences hash is only known after precompilation so just assume no preferences.
34233424
# Also ignore the active project, which means that if all other conditions are equal,

base/reflection.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Base
2020
"""
2121
parentmodule(m::Module) = ccall(:jl_module_parent, Ref{Module}, (Any,), m)
2222

23-
is_root_module(m::Module) = parentmodule(m) === m || (isdefined(Main, :Base) && m === Main.Base)
24-
2523
"""
2624
moduleroot(m::Module) -> Module
2725

base/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ function show_type_name(io::IO, tn::Core.TypeName)
10561056
# IOContext If :module is not set, default to Main (or current active module).
10571057
# nothing can be used to force printing prefix
10581058
from = get(io, :module, active_module())
1059-
if isdefined(tn, :module) && (from === nothing || !isvisible(sym, tn.module, from::Module))
1059+
if isdefined(tn, :module) && (from === nothing || !isvisible(sym, tn.module, from))
10601060
show(io, tn.module)
10611061
print(io, ".")
10621062
if globfunc && !is_id_start_char(first(string(sym)))

0 commit comments

Comments
 (0)