Skip to content

Commit 0de2836

Browse files
authored
Merge branch 'JuliaLang:master' into convert-Time-from-TimeType
2 parents ef19f9d + 92aacab commit 0de2836

File tree

15 files changed

+179
-63
lines changed

15 files changed

+179
-63
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia
8989
julia-stdlib: | $(DIRS) julia-deps
9090
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/stdlib
9191

92-
julia-base: julia-deps $(build_sysconfdir)/julia/startup.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl $(build_datarootdir)/julia/juliac.jl $(build_datarootdir)/julia/juliac-buildscript.jl $(build_datarootdir)/julia/juliac-trim-base.jl $(build_datarootdir)/julia/juliac-trim-stdlib.jl
92+
julia-base: julia-deps $(build_sysconfdir)/julia/startup.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl $(build_datarootdir)/julia/juliac/juliac.jl $(build_datarootdir)/julia/juliac/juliac-buildscript.jl $(build_datarootdir)/julia/juliac/juliac-trim-base.jl $(build_datarootdir)/julia/juliac/juliac-trim-stdlib.jl
9393
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/base
9494

9595
julia-libccalltest: julia-deps
@@ -184,6 +184,7 @@ $(build_sysconfdir)/julia/startup.jl: $(JULIAHOME)/etc/startup.jl | $(build_sysc
184184
@cp $< $@
185185

186186
$(build_datarootdir)/julia/%: $(JULIAHOME)/contrib/% | $(build_datarootdir)/julia
187+
mkdir -p $(dir $@)
187188
$(INSTALL_M) $< $(dir $@)
188189

189190
$(build_depsbindir)/stringreplace: $(JULIAHOME)/contrib/stringreplace.c | $(build_depsbindir)

base/invalidation.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ function scan_new_method!(method::Method, image_backedges_only::Bool)
206206
end
207207

208208
function scan_new_methods!(extext_methods::Vector{Any}, internal_methods::Vector{Any}, image_backedges_only::Bool)
209+
if image_backedges_only && Base.generating_output(true)
210+
# Replacing image bindings is forbidden during incremental precompilation - skip backedge insertion
211+
return
212+
end
209213
for method in internal_methods
210214
if isa(method, Method)
211215
scan_new_method!(method, image_backedges_only)

contrib/juliac/Artifacts.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[[mingw-w64]]
2+
arch = "x86_64"
3+
git-tree-sha1 = "b17bda08a19173572926f43a48aad5ef3d845e7c"
4+
os = "windows"
5+
lazy = true
6+
7+
[[mingw-w64.download]]
8+
sha256 = "53645e06775a55733580426341395c67dda20a664af83bcda76a1d052b618b59"
9+
url = "https://github.com/JuliaLang/PackageCompiler.jl/releases/download/v2.1.24/x86_64-14.2.0-release-posix-seh-msvcrt-rt_v12-rev0.tar.gz"
10+
11+
[[mingw-w64]]
12+
arch = "i686"
13+
git-tree-sha1 = "76b9f278e7de1d7dfdfe3a786afbe9c1e29003ea"
14+
os = "windows"
15+
lazy = true
16+
17+
[[mingw-w64.download]]
18+
sha256 = "d049bd771e01b02f2ca9274435f0e6f9f4f295bf2af72a8059dd851c52144910"
19+
url = "https://github.com/JuliaLang/PackageCompiler.jl/releases/download/v2.1.24/i686-14.2.0-release-posix-dwarf-msvcrt-rt_v12-rev0.tar.gz"
File renamed without changes.
File renamed without changes.
File renamed without changes.

contrib/juliac.jl renamed to contrib/juliac/juliac.jl

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# Julia compiler wrapper script
44
# NOTE: The interface and location of this script are considered unstable/experimental
55

6+
using LazyArtifacts
7+
68
module JuliaConfig
7-
include(joinpath(@__DIR__, "julia-config.jl"))
9+
include(joinpath(@__DIR__, "..", "julia-config.jl"))
810
end
911

1012
julia_cmd = `$(Base.julia_cmd()) --startup-file=no --history-file=no`
@@ -30,6 +32,57 @@ if help !== nothing
3032
exit(0)
3133
end
3234

35+
# Copied from PackageCompiler
36+
# https://github.com/JuliaLang/PackageCompiler.jl/blob/1c35331d8ef81494f054bbc71214811253101993/src/PackageCompiler.jl#L147-L190
37+
function get_compiler_cmd(; cplusplus::Bool=false)
38+
cc = get(ENV, "JULIA_CC", nothing)
39+
path = nothing
40+
@static if Sys.iswindows()
41+
path = joinpath(LazyArtifacts.artifact"mingw-w64",
42+
"extracted_files",
43+
(Int==Int64 ? "mingw64" : "mingw32"),
44+
"bin",
45+
cplusplus ? "g++.exe" : "gcc.exe")
46+
compiler_cmd = `$path`
47+
end
48+
if cc !== nothing
49+
compiler_cmd = Cmd(Base.shell_split(cc))
50+
path = nothing
51+
elseif !Sys.iswindows()
52+
compilers_cpp = ("g++", "clang++")
53+
compilers_c = ("gcc", "clang")
54+
found_compiler = false
55+
if cplusplus
56+
for compiler in compilers_cpp
57+
if Sys.which(compiler) !== nothing
58+
compiler_cmd = `$compiler`
59+
found_compiler = true
60+
break
61+
end
62+
end
63+
end
64+
if !found_compiler
65+
for compiler in compilers_c
66+
if Sys.which(compiler) !== nothing
67+
compiler_cmd = `$compiler`
68+
found_compiler = true
69+
if cplusplus && !WARNED_CPP_COMPILER[]
70+
@warn "could not find a c++ compiler (g++ or clang++), falling back to $compiler, this might cause link errors"
71+
WARNED_CPP_COMPILER[] = true
72+
end
73+
break
74+
end
75+
end
76+
end
77+
found_compiler || error("could not find a compiler, looked for ",
78+
join(((cplusplus ? compilers_cpp : ())..., compilers_c...), ", ", " and "))
79+
end
80+
if path !== nothing
81+
compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path)))
82+
end
83+
return compiler_cmd
84+
end
85+
3386
# arguments to forward to julia compilation process
3487
julia_args = []
3588
enable_trim::Bool = false
@@ -82,6 +135,7 @@ function get_rpath(; relative::Bool = false)
82135
end
83136
end
84137

138+
cc = get_compiler_cmd()
85139
absfile = abspath(file)
86140
cflags = JuliaConfig.cflags(; framework=false)
87141
cflags = Base.shell_split(cflags)
@@ -93,7 +147,6 @@ tmpdir = mktempdir(cleanup=false)
93147
img_path = joinpath(tmpdir, "img.a")
94148
bc_path = joinpath(tmpdir, "img-bc.a")
95149

96-
97150
function precompile_env()
98151
# Pre-compile the environment
99152
# (otherwise obscure error messages will occur)
@@ -121,7 +174,6 @@ function compile_products(enable_trim::Bool)
121174
println(stderr, "\nFailed to compile $file")
122175
exit(1)
123176
end
124-
125177
end
126178

127179
function link_products()
@@ -137,11 +189,11 @@ function link_products()
137189
julia_libs = Base.shell_split(Base.isdebugbuild() ? "-ljulia-debug -ljulia-internal-debug" : "-ljulia -ljulia-internal")
138190
try
139191
if output_type == "--output-lib"
140-
cmd2 = `cc $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
192+
cmd2 = `$(cc) $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
141193
elseif output_type == "--output-sysimage"
142-
cmd2 = `cc $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
194+
cmd2 = `$(cc) $(allflags) $(rpath) -o $outname -shared -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
143195
else
144-
cmd2 = `cc $(allflags) $(rpath) -o $outname -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
196+
cmd2 = `$(cc) $(allflags) $(rpath) -o $outname -Wl,$(Base.Linking.WHOLE_ARCHIVE) $img_path -Wl,$(Base.Linking.NO_WHOLE_ARCHIVE) $(julia_libs)`
145197
end
146198
verbose && println("Running: $cmd2")
147199
run(cmd2)

doc/src/devdocs/sysimg.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ debug info, respectively, and so will make debugging more difficult.
176176
We have identified many small changes to Base that significantly increase the set of programs
177177
that can be reliably trimmed. Unfortunately some of those changes would be considered breaking,
178178
and so are only applied when trimming is requested (this is done by an external build script,
179-
currently maintained inside the test suite as `contrib/juliac-buildscript.jl`).
179+
currently maintained inside the test suite as `contrib/juliac/juliac-buildscript.jl`).
180180
Therefore in many cases trimming will require you to opt in to new variants of Base and some
181181
standard libraries.
182182

src/cgutils.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,10 +1601,17 @@ static void undef_var_error_ifnot(jl_codectx_t &ctx, Value *ok, jl_sym_t *name,
16011601
ctx.builder.SetInsertPoint(ifok);
16021602
}
16031603

1604+
// ctx.builder.CreateIsNotNull(v) lowers incorrectly in non-standard
1605+
// address spaces where null is not zero
1606+
// TODO: adapt to https://github.com/llvm/llvm-project/pull/131557 once merged
16041607
static Value *null_pointer_cmp(jl_codectx_t &ctx, Value *v)
16051608
{
16061609
++EmittedNullchecks;
1607-
return ctx.builder.CreateIsNotNull(v);
1610+
Type *T = v->getType();
1611+
return ctx.builder.CreateICmpNE(
1612+
v,
1613+
ctx.builder.CreateAddrSpaceCast(
1614+
Constant::getNullValue(ctx.builder.getPtrTy(0)), T));
16081615
}
16091616

16101617

src/debug-registry.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ typedef struct {
1212
const llvm::object::ObjectFile *obj;
1313
llvm::DIContext *ctx;
1414
int64_t slide;
15-
} objfileentry_t;
15+
std::map<uintptr_t, StringRef, std::greater<size_t>> *symbolmap;
16+
} jl_object_file_entry_t;
1617

1718
// Central registry for resolving function addresses to `jl_code_instance_t`s and
1819
// originating `ObjectFile`s (for the DWARF debug info).
@@ -121,7 +122,7 @@ class JITDebugInfoRegistry
121122
using rev_map = std::map<KeyT, ValT, std::greater<KeyT>>;
122123

123124
typedef rev_map<size_t, SectionInfo> objectmap_t;
124-
typedef rev_map<uint64_t, objfileentry_t> objfilemap_t;
125+
typedef rev_map<uint64_t, jl_object_file_entry_t> objfilemap_t;
125126

126127
objectmap_t objectmap{};
127128
rev_map<size_t, std::pair<size_t, jl_code_instance_t *>> cimap{};
@@ -152,4 +153,6 @@ class JITDebugInfoRegistry
152153
void add_image_info(image_info_t info) JL_NOTSAFEPOINT;
153154
bool get_image_info(uint64_t base, image_info_t *info) const JL_NOTSAFEPOINT;
154155
Locked<objfilemap_t>::LockT get_objfile_map() JL_NOTSAFEPOINT;
156+
157+
std::shared_mutex symbol_mutex;
155158
};

0 commit comments

Comments
 (0)