Skip to content

Commit

Permalink
Merge branch 'master' into juliac-rpath
Browse files Browse the repository at this point in the history
  • Loading branch information
topolarity authored Jan 31, 2025
2 parents 23b45cf + 2a9c133 commit 47f1ba3
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 55 deletions.
96 changes: 58 additions & 38 deletions contrib/juliac.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module JuliaConfig
include(joinpath(@__DIR__, "julia-config.jl"))
end

cmd = Base.julia_cmd()
cmd = `$cmd --startup-file=no --history-file=no`
julia_cmd = `$(Base.julia_cmd()) --startup-file=no --history-file=no`
output_type = nothing # exe, sharedlib, sysimage
outname = nothing
file = nothing
Expand Down Expand Up @@ -89,48 +88,69 @@ init_path = joinpath(tmpdir, "init.a")
img_path = joinpath(tmpdir, "img.a")
bc_path = joinpath(tmpdir, "img-bc.a")

open(initsrc_path, "w") do io
print(io, """
#include <julia.h>
__attribute__((constructor)) void static_init(void) {
if (jl_is_initialized())
return;
julia_init(JL_IMAGE_IN_MEMORY);
jl_exception_clear();
}
""")
end

cmd = addenv(`$cmd --project=$(Base.active_project()) --output-o $img_path --output-incremental=no --strip-ir --strip-metadata $julia_args $(joinpath(@__DIR__,"juliac-buildscript.jl")) $absfile $output_type $add_ccallables`, "OPENBLAS_NUM_THREADS" => 1, "JULIA_NUM_THREADS" => 1)
verbose && println("Running: $cmd")
if !success(pipeline(cmd; stdout, stderr))
println(stderr, "\nFailed to compile $file")
exit(1)
function precompile_env()
# Pre-compile the environment
# (otherwise obscure error messages will occur)
cmd = addenv(`$julia_cmd --project=$(Base.active_project()) -e "using Pkg; Pkg.precompile()"`)
verbose && println("Running: $cmd")
if !success(pipeline(cmd; stdout, stderr))
println(stderr, "\nError encountered during pre-compilation of environment.")
exit(1)
end
end

run(`cc $(cflags) -g -c -o $init_path $initsrc_path`)
function compile_products()
# Compile the Julia code
cmd = addenv(`$julia_cmd --project=$(Base.active_project()) --output-o $img_path --output-incremental=no --strip-ir --strip-metadata $julia_args $(joinpath(@__DIR__,"juliac-buildscript.jl")) $absfile $output_type $add_ccallables`, "OPENBLAS_NUM_THREADS" => 1, "JULIA_NUM_THREADS" => 1)
verbose && println("Running: $cmd")
if !success(pipeline(cmd; stdout, stderr))
println(stderr, "\nFailed to compile $file")
exit(1)
end

if output_type == "--output-lib" || output_type == "--output-sysimage"
of, ext = splitext(outname)
soext = "." * Base.BinaryPlatforms.platform_dlext()
if ext == ""
outname = of * soext
# Compile the initialization code
open(initsrc_path, "w") do io
print(io, """
#include <julia.h>
__attribute__((constructor)) void static_init(void) {
if (jl_is_initialized())
return;
julia_init(JL_IMAGE_IN_MEMORY);
jl_exception_clear();
}
""")
end
run(`cc $(cflags) -g -c -o $init_path $initsrc_path`)
end

julia_libs = Base.shell_split(Base.isdebugbuild() ? "-ljulia-debug -ljulia-internal-debug" : "-ljulia -ljulia-internal")
try
cmd2 = nothing
if output_type == "--output-lib"
cmd2 = `cc $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $init_path $(julia_libs)`
elseif output_type == "--output-sysimage"
cmd2 = `cc $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
else
cmd2 = `cc $(allflags) $(rpath) -o $outname -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $init_path $(julia_libs)`
function link_products()
global outname
if output_type == "--output-lib" || output_type == "--output-sysimage"
of, ext = splitext(outname)
soext = "." * Base.BinaryPlatforms.platform_dlext()
if ext == ""
outname = of * soext
end
end

julia_libs = Base.shell_split(Base.isdebugbuild() ? "-ljulia-debug -ljulia-internal-debug" : "-ljulia -ljulia-internal")
try
if output_type == "--output-lib"
cmd2 = `cc $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $init_path $(julia_libs)`
elseif output_type == "--output-sysimage"
cmd2 = `cc $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
else
cmd2 = `cc $(allflags) $(rpath) -o $outname -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $init_path $(julia_libs)`
end
verbose && println("Running: $cmd2")
run(cmd2)
catch e
println("\nCompilation failed: ", e)
exit(1)
end
verbose && println("Running: $cmd2")
run(cmd2)
catch
println("\nCompilation failed.")
exit(1)
end

precompile_env()
compile_products()
link_products()
2 changes: 1 addition & 1 deletion deps/JuliaSyntax.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JULIASYNTAX_BRANCH = main
JULIASYNTAX_SHA1 = dfd1d69b153eb119873035e62993a109b27192f0
JULIASYNTAX_SHA1 = 2e965a159dd9f87d216d2d50ecbd2ed4f9af2c5a
JULIASYNTAX_GIT_URL := https://github.com/JuliaLang/JuliaSyntax.jl.git
JULIASYNTAX_TAR_URL = https://api.github.com/repos/JuliaLang/JuliaSyntax.jl/tarball/$1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
40d7bcc6e5741d50a457ace2ca8b2c0c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b9429b90a28460ef0272cd42a5c221629c6d60221ed088ae3e591cc3d8dbdec32788074397419e58b611bda7df32c7379ec7fafeead7056ed9665591474cec5d

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
187f155c32a79f57a89e31e672d2d8c5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
69347af996d77b88b5e5b6e44ff046e9197775a66802a0da6fb5fcbf9e5ca533566955c8435bc25490f6ca0c002b4c1effcddaf932b7eb91e00a8f99554b7b8d

This file was deleted.

This file was deleted.

5 changes: 4 additions & 1 deletion src/codegen-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ JL_DLLEXPORT uint32_t jl_get_LLVM_VERSION_fallback(void)

JL_DLLEXPORT int jl_compile_extern_c_fallback(LLVMOrcThreadSafeModuleRef llvmmod, void *params, void *sysimg, jl_value_t *declrt, jl_value_t *sigt)
{
return 0;
// Assume we were able to register the ccallable with the JIT. The
// fact that we didn't is not observable since we cannot compile
// anything else.
return 1;
}

JL_DLLEXPORT void jl_teardown_codegen_fallback(void) JL_NOTSAFEPOINT
Expand Down
3 changes: 2 additions & 1 deletion src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2623,7 +2623,6 @@ static void strip_specializations_(jl_method_instance_t *mi)
if (inferred && inferred != jl_nothing) {
if (jl_options.strip_ir) {
record_field_change((jl_value_t**)&codeinst->inferred, jl_nothing);
record_field_change((jl_value_t**)&codeinst->edges, (jl_value_t*)jl_emptysvec);
}
else if (jl_options.strip_metadata) {
jl_value_t *stripped = strip_codeinfo_meta(mi->def.method, inferred, codeinst);
Expand All @@ -2632,6 +2631,8 @@ static void strip_specializations_(jl_method_instance_t *mi)
}
}
}
if (jl_options.strip_ir)
record_field_change((jl_value_t**)&codeinst->edges, (jl_value_t*)jl_emptysvec);
if (jl_options.strip_metadata)
record_field_change((jl_value_t**)&codeinst->debuginfo, (jl_value_t*)jl_nulldebuginfo);
codeinst = jl_atomic_load_relaxed(&codeinst->next);
Expand Down
2 changes: 1 addition & 1 deletion stdlib/JuliaSyntaxHighlighting.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JULIASYNTAXHIGHLIGHTING_BRANCH = main
JULIASYNTAXHIGHLIGHTING_SHA1 = eb8097c5f1dbfca80b5e6664af031ff1fe0904af
JULIASYNTAXHIGHLIGHTING_SHA1 = 2680c8bde1aa274f25d7a434c645f16b3a1ee731
JULIASYNTAXHIGHLIGHTING_GIT_URL := https://github.com/julialang/JuliaSyntaxHighlighting.jl.git
JULIASYNTAXHIGHLIGHTING_TAR_URL = https://api.github.com/repos/julialang/JuliaSyntaxHighlighting.jl/tarball/$1
18 changes: 16 additions & 2 deletions stdlib/REPL/test/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,22 @@ end
end

@testset "non-loaded packages in doc search" begin
str = get_help_io("Profile")
@test occursin("Couldn't find Profile, but a loadable package with that name exists.", str)
temp_package = mktempdir()
write(joinpath(temp_package, "Project.toml"),
"""
name = "FooPackage"
uuid = "2e6e0b2d-0e7f-4b7f-9f3b-6f3f3f3f3f3f"
""")
mkpath(joinpath(temp_package, "src"))
write(joinpath(temp_package, "src", "FooPackage.jl"),
"""
module FooPackage
end
""")
push!(LOAD_PATH, temp_package)
str = get_help_io("FooPackage")
@test occursin("Couldn't find FooPackage, but a loadable package with that name exists.", str)
@test pop!(LOAD_PATH) == temp_package
end

@testset "Check @var_str also completes to var\"\" in REPL.doc_completions()" begin
Expand Down
16 changes: 9 additions & 7 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ add_method_to_glob_fn!()
@test_parseerror "function finally() end"

# PR #16170
@test Meta.lower(Main, Meta.parse("true(x) = x")) == Expr(:error, "invalid function name \"true\"")
@test Meta.lower(Main, Meta.parse("false(x) = x")) == Expr(:error, "invalid function name \"false\"")
@test Meta.lower(Main, Meta.parse("true(x) = x")) == Expr(:error, "\"true\" is not a valid function argument name")
@test Meta.lower(Main, Meta.parse("false(x) = x")) == Expr(:error, "\"false\" is not a valid function argument name")

# issue #16355
@test Meta.lower(Main, :(f(d:Int...) = nothing)) == Expr(:error, "\"d:Int\" is not a valid function argument name")
Expand Down Expand Up @@ -925,8 +925,8 @@ g21054(>:) = >:2
@test g21054(-) == -2

# issue #21168
@test Meta.lower(Main, :(a.[1])) == Expr(:error, "invalid syntax \"a.[1]\"")
@test Meta.lower(Main, :(a.{1})) == Expr(:error, "invalid syntax \"a.{1}\"")
@test_broken Meta.lower(Main, :(a.[1])) == Expr(:error, "invalid syntax \"a.[1]\"")
@test_broken Meta.lower(Main, :(a.{1})) == Expr(:error, "invalid syntax \"a.{1}\"")

# Issue #21225
let abstr = Meta.parse("abstract type X end")
Expand Down Expand Up @@ -1496,8 +1496,8 @@ end

# issue #26739
let exc = try Core.eval(@__MODULE__, :(sin.[1])) catch exc ; exc end
@test exc isa ErrorException
@test startswith(exc.msg, "syntax: invalid syntax \"sin.[1]\"")
@test_broken exc isa ErrorException
@test_broken startswith(exc.msg, "syntax: invalid syntax \"sin.[1]\"")
end

# issue #26873
Expand Down Expand Up @@ -2454,7 +2454,9 @@ end
@test_throws MethodError @m37134()(1.0) == 62

macro n37134()
:($(esc(Expr(:tuple, Expr(:..., :x))))->$(esc(:x)))
quote
((x...,)) -> (x)
end |> esc
end
@test @n37134()(2,1) === (2,1)

Expand Down

0 comments on commit 47f1ba3

Please sign in to comment.