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

Revert "small changes to make Base more statically compileable" #53808

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ function is_top_bit_set(x::Union{Int8,UInt8})
end

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

function check_sign_bit(::Type{To}, x) where {To}
@inline
Expand Down
2 changes: 2 additions & 0 deletions base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ end
# options #
###########

is_root_module(m::Module) = false

inlining_enabled() = (JLOptions().can_inline == 1)

function coverage_enabled(m::Module)
Expand Down
10 changes: 5 additions & 5 deletions base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ macro assert(ex, msgs...)
msg = Main.Base.string(msg)
else
# string() might not be defined during bootstrap
msg = :(_assert_tostring($(Expr(:quote,msg))))
msg = quote
msg = $(Expr(:quote,msg))
isdefined(Main, :Base) ? Main.Base.string(msg) :
(Core.println(msg); "Error during bootstrap. See stdout.")
end
end
return :($(esc(ex)) ? $(nothing) : throw(AssertionError($msg)))
end

# this may be overridden in contexts where `string(::Expr)` doesn't work
_assert_tostring(msg) = isdefined(Main, :Base) ? Main.Base.string(msg) :
(Core.println(msg); "Error during bootstrap. See stdout.")

struct ExponentialBackOff
n::Int
first_delay::Float64
Expand Down
2 changes: 1 addition & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ end

#Show an error by directly calling jl_printf.
#Useful in Base submodule __init__ functions where stderr isn't defined yet.
function showerror_nostdio(@nospecialize(err), msg::AbstractString)
function showerror_nostdio(err, msg::AbstractString)
stderr_stream = ccall(:jl_stderr_stream, Ptr{Cvoid}, ())
ccall(:jl_printf, Cint, (Ptr{Cvoid},Cstring), stderr_stream, msg)
ccall(:jl_printf, Cint, (Ptr{Cvoid},Cstring), stderr_stream, ":\n")
Expand Down
4 changes: 2 additions & 2 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A string containing the script name passed to Julia from the command line. Note
script name remains unchanged from within included files. Alternatively see
[`@__FILE__`](@ref).
"""
global PROGRAM_FILE::String = ""
global PROGRAM_FILE = ""

"""
ARGS
Expand Down Expand Up @@ -480,7 +480,7 @@ end

## hook for disabling threaded libraries ##

library_threading_enabled::Bool = true
library_threading_enabled = true
const disable_library_threading_hooks = []

function at_disable_library_threading(f)
Expand Down
13 changes: 5 additions & 8 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,12 @@ function open(fname::String; lock = true,
if !lock
s._dolock = false
end
if ccall(:ios_file, Ptr{Cvoid},
(Ptr{UInt8}, Cstring, Cint, Cint, Cint, Cint),
s.ios, fname, flags.read, flags.write, flags.create, flags.truncate) == C_NULL
systemerror("opening file \"$fname\"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this change is the actual issue here. Just replace this with $(repr(fname)) as it was before?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end
systemerror("opening file $(repr(fname))",
ccall(:ios_file, Ptr{Cvoid},
(Ptr{UInt8}, Cstring, Cint, Cint, Cint, Cint),
s.ios, fname, flags.read, flags.write, flags.create, flags.truncate) == C_NULL)
if flags.append
if ccall(:ios_seek_end, Int64, (Ptr{Cvoid},), s.ios) != 0
systemerror("seeking to end of file \"$fname\"")
end
systemerror("seeking to end of file $fname", ccall(:ios_seek_end, Int64, (Ptr{Cvoid},), s.ios) != 0)
end
return s
end
Expand Down
6 changes: 3 additions & 3 deletions base/libuv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ function uv_asynccb end
function uv_timercb end

function reinit_stdio()
global stdin = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ()))::IO
global stdout = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ()))::IO
global stderr = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ()))::IO
global stdin = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ()))
global stdout = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ()))
global stderr = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ()))
opts = JLOptions()
if opts.color != 0
have_color = (opts.color == 1)
Expand Down
7 changes: 4 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ const explicit_loaded_modules = Dict{PkgId,Module}()
const loaded_modules_order = Vector{Module}()
const module_keys = IdDict{Module,PkgId}() # the reverse

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

@constprop :none function register_root_module(m::Module)
Expand Down Expand Up @@ -3415,9 +3416,9 @@ function check_clone_targets(clone_targets)
end

# Set by FileWatching.__init__()
global mkpidlock_hook::Any
global trymkpidlock_hook::Any
global parse_pidfile_hook::Any
global mkpidlock_hook
global trymkpidlock_hook
global parse_pidfile_hook

# The preferences hash is only known after precompilation so just assume no preferences.
# Also ignore the active project, which means that if all other conditions are equal,
Expand Down
2 changes: 0 additions & 2 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Base
"""
parentmodule(m::Module) = ccall(:jl_module_parent, Ref{Module}, (Any,), m)

is_root_module(m::Module) = parentmodule(m) === m || (isdefined(Main, :Base) && m === Main.Base)

"""
moduleroot(m::Module) -> Module

Expand Down
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ function show_type_name(io::IO, tn::Core.TypeName)
# IOContext If :module is not set, default to Main (or current active module).
# nothing can be used to force printing prefix
from = get(io, :module, active_module())
if isdefined(tn, :module) && (from === nothing || !isvisible(sym, tn.module, from::Module))
if isdefined(tn, :module) && (from === nothing || !isvisible(sym, tn.module, from))
show(io, tn.module)
print(io, ".")
if globfunc && !is_id_start_char(first(string(sym)))
Expand Down
2 changes: 1 addition & 1 deletion base/threadingconstructs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function _sym_to_tpid(tp::Symbol)
elseif tp == :foreign
return Int8(-1)
else
throw(ArgumentError("Unrecognized threadpool name `$tp`"))
throw(ArgumentError("Unrecognized threadpool name `$(repr(tp))`"))
end
end

Expand Down
5 changes: 0 additions & 5 deletions stdlib/FileWatching/src/FileWatching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,6 @@ function uv_fspollcb(handle::Ptr{Cvoid}, status::Int32, prev::Ptr, curr::Ptr)
nothing
end

global uv_jl_pollcb::Ptr{Cvoid}
global uv_jl_fspollcb::Ptr{Cvoid}
global uv_jl_fseventscb_file::Ptr{Cvoid}
global uv_jl_fseventscb_folder::Ptr{Cvoid}

function __init__()
global uv_jl_pollcb = @cfunction(uv_pollcb, Cvoid, (Ptr{Cvoid}, Cint, Cint))
global uv_jl_fspollcb = @cfunction(uv_fspollcb, Cvoid, (Ptr{Cvoid}, Cint, Ptr{Cvoid}, Ptr{Cvoid}))
Expand Down
5 changes: 3 additions & 2 deletions stdlib/LinearAlgebra/src/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ function check()
interface = USE_BLAS64 ? :ilp64 : :lp64
if !any(lib.interface == interface for lib in config.loaded_libs)
interfacestr = uppercase(string(interface))
@error("No loaded BLAS libraries were built with $interfacestr support.")
exit(1)
@error("No loaded BLAS libraries were built with $(interfacestr) support")
println("Quitting.")
exit()
end
end

Expand Down