Skip to content

Commit a5540b3

Browse files
authored
Backports for 1.10.4 (#54416)
Backported PRs: - [x] #54010 <!-- Overload `Base.literal_pow` for `AbstractQ` --> - [x] #54143 <!-- Fix `make install` from tarballs --> - [x] #54151 <!-- LinearAlgebra: Correct zero element in `_generic_matvecmul!` for block adj/trans --> - [x] #54233 <!-- set MAX_OS_WRITE on unix --> - [x] #54251 <!-- fix typo in gc_mark_memory8 when chunking a large array --> - [x] #54363 <!-- typeintersect: fix another stack overflow caused by circular constraints --> - [x] #54497 <!-- Make TestLogger thread-safe (introduce a lock) --> - [x] #53796 <!-- Add a missing doc --> - [x] #54465 <!-- typeintersect: conservative typevar subtitution during `finish_unionall` --> - [x] #54514 <!-- typeintersect: followup cleanup for the nothrow path of type instantiation --> Need manual backport: - [ ] #52505 <!-- fix alignment of emit_unbox_store copy --> - [ ] #53373 <!-- fix sysimage-native-code=no option with pkgimages --> - [ ] #53815 <!-- create phantom task for GC threads --> - [ ] #53984 <!-- Profile: fix heap snapshot is valid char check --> - [ ] #54276 <!-- Fix solve for complex `Hermitian` with non-vanishing imaginary part on diagonal --> Contains multiple commits, manual intervention needed: - [ ] #52854 <!-- Change to streaming out the heap snapshot data --> - [ ] #53218 <!-- Fix interpreter_exec.jl test --> - [ ] #53833 <!-- Profile: make heap snapshots viewable in vscode viewer --> - [ ] #54303 <!-- LinearAlgebra: improve type-inference in Symmetric/Hermitian matmul --> - [ ] #52694 <!-- Reinstate similar for AbstractQ for backward compatibility --> Non-merged PRs with backport label: - [ ] #54471 <!-- Actually setup jit targets when compiling packageimages instead of targeting only one --> - [ ] #53452 <!-- RFC: allow Tuple{Union{}}, returning Union{} --> - [ ] #51479 <!-- prevent code loading from lookin in the versioned environment when building Julia -->
2 parents 54614fd + 7ebe203 commit a5540b3

22 files changed

+402
-179
lines changed

Make.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ ifeq ($(OS), WINNT)
13651365
HAVE_SSP := 1
13661366
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(BUILDROOT)/src/julia.expmap \
13671367
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic
1368-
JLDFLAGS += -Wl,--stack,8388608
1368+
JLDFLAGS += -Wl,--stack,8388608 --disable-auto-import --disable-runtime-pseudo-reloc
13691369
ifeq ($(ARCH),i686)
13701370
JLDFLAGS += -Wl,--large-address-aware
13711371
endif

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ $(foreach link,base $(JULIAHOME)/test,$(eval $(call symlink_target,$(link),$$(bu
6161
julia_flisp.boot.inc.phony: julia-deps
6262
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony
6363

64+
# Build the HTML docs (skipped if already exists, notably in tarballs)
65+
$(BUILDROOT)/doc/_build/html/en/index.html: $(shell find $(BUILDROOT)/base $(BUILDROOT)/doc \( -path $(BUILDROOT)/doc/_build -o -path $(BUILDROOT)/doc/deps -o -name *_constants.jl -o -name *_h.jl -o -name version_git.jl \) -prune -o -type f -print)
66+
@$(MAKE) docs
67+
6468
julia-symlink: julia-cli-$(JULIA_BUILD_MODE)
6569
ifeq ($(OS),WINNT)
6670
echo '@"%~dp0/'"$$(echo '$(call rel_path,$(BUILDROOT),$(JULIA_EXECUTABLE))')"'" %*' | tr / '\\' > $(BUILDROOT)/julia.bat
@@ -265,7 +269,7 @@ define stringreplace
265269
endef
266270

267271

268-
install: $(build_depsbindir)/stringreplace docs
272+
install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
269273
@$(MAKE) $(QUIET_MAKE) $(JULIA_BUILD_MODE)
270274
@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(private_libexecdir); do \
271275
mkdir -p $(DESTDIR)$$subdir; \
@@ -523,7 +527,7 @@ app:
523527
darwinframework:
524528
$(MAKE) -C $(JULIAHOME)/contrib/mac/framework
525529

526-
light-source-dist.tmp: docs
530+
light-source-dist.tmp: $(BUILDROOT)/doc/_build/html/en/index.html
527531
ifneq ($(BUILDROOT),$(JULIAHOME))
528532
$(error make light-source-dist does not work in out-of-tree builds)
529533
endif

base/linking.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function ld()
110110
# LLD supports mingw style linking
111111
flavor = "gnu"
112112
m = Sys.ARCH == :x86_64 ? "i386pep" : "i386pe"
113-
default_args = `-m $m -Bdynamic --enable-auto-image-base --allow-multiple-definition`
113+
default_args = `-m $m -Bdynamic --enable-auto-image-base --allow-multiple-definition --disable-auto-import --disable-runtime-pseudo-reloc`
114114
elseif Sys.isapple()
115115
flavor = "darwin"
116116
arch = Sys.ARCH == :aarch64 ? :arm64 : Sys.ARCH

base/stream.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const DEFAULT_READ_BUFFER_SZ = 10485760 # 10 MB
122122
if Sys.iswindows()
123123
const MAX_OS_WRITE = UInt(0x1FF0_0000) # 511 MB (determined semi-empirically, limited to 31 MB on XP)
124124
else
125-
const MAX_OS_WRITE = UInt(typemax(Csize_t))
125+
const MAX_OS_WRITE = UInt(0x7FFF_0000) # almost 2 GB (both macOS and linux have this kernel restriction, although only macOS documents it)
126126
end
127127

128128

cli/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ LOADER_CFLAGS += -DGLIBCXX_LEAST_VERSION_SYMBOL=\"$(shell echo "$(CSL_NEXT_GLIBC
1717
endif
1818

1919
ifeq ($(OS),WINNT)
20-
LOADER_LDFLAGS += -municode -mconsole -nostdlib --disable-auto-import \
21-
--disable-runtime-pseudo-reloc -lntdll -lkernel32 -lpsapi
20+
LOADER_LDFLAGS += -municode -mconsole -nostdlib -lntdll -lkernel32 -lpsapi
2221
else ifeq ($(OS),Linux)
2322
LOADER_LDFLAGS += -Wl,--no-as-needed -ldl -lpthread -rdynamic -lc -Wl,--as-needed
2423
else ifeq ($(OS),FreeBSD)

doc/src/base/math.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Base.Math.tand
7070
Base.Math.sincosd
7171
Base.Math.sinpi
7272
Base.Math.cospi
73+
Base.Math.tanpi
7374
Base.Math.sincospi
7475
Base.sinh(::Number)
7576
Base.cosh(::Number)

src/aotcompile.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,8 @@ static void materializePreserved(Module &M, Partition &partition) {
11661166
GV.setInitializer(nullptr);
11671167
GV.setLinkage(GlobalValue::ExternalLinkage);
11681168
GV.setVisibility(GlobalValue::HiddenVisibility);
1169+
if (GV.getDLLStorageClass() != GlobalValue::DLLStorageClassTypes::DefaultStorageClass)
1170+
continue; // Don't mess with exported or imported globals
11691171
GV.setDSOLocal(true);
11701172
}
11711173

@@ -1645,6 +1647,7 @@ void jl_dump_native_impl(void *native_code,
16451647
if (jl_small_typeof_copy) {
16461648
jl_small_typeof_copy->setVisibility(GlobalValue::HiddenVisibility);
16471649
jl_small_typeof_copy->setDSOLocal(true);
1650+
jl_small_typeof_copy->setDLLStorageClass(GlobalValue::DLLStorageClassTypes::DefaultStorageClass);
16481651
}
16491652
}
16501653

@@ -1673,16 +1676,17 @@ void jl_dump_native_impl(void *native_code,
16731676
// reflect the address of the jl_RTLD_DEFAULT_handle variable
16741677
// back to the caller, so that we can check for consistency issues
16751678
GlobalValue *jlRTLD_DEFAULT_var = jl_emit_RTLD_DEFAULT_var(&metadataM);
1676-
addComdat(new GlobalVariable(metadataM,
1677-
jlRTLD_DEFAULT_var->getType(),
1678-
true,
1679-
GlobalVariable::ExternalLinkage,
1680-
jlRTLD_DEFAULT_var,
1681-
"jl_RTLD_DEFAULT_handle_pointer"), TheTriple);
1682-
16831679
Type *T_size = DL.getIntPtrType(Context);
16841680
Type *T_psize = T_size->getPointerTo();
16851681

1682+
auto FT = FunctionType::get(Type::getInt8Ty(Context)->getPointerTo()->getPointerTo(), {}, false);
1683+
auto F = Function::Create(FT, Function::ExternalLinkage, "get_jl_RTLD_DEFAULT_handle_addr", metadataM);
1684+
llvm::IRBuilder<> builder(BasicBlock::Create(Context, "top", F));
1685+
builder.CreateRet(jlRTLD_DEFAULT_var);
1686+
F->setLinkage(GlobalValue::ExternalLinkage);
1687+
if (TheTriple.isOSBinFormatCOFF())
1688+
F->setDLLStorageClass(GlobalValue::DLLStorageClassTypes::DLLExportStorageClass);
1689+
16861690
if (TheTriple.isOSWindows()) {
16871691
// Windows expect that the function `_DllMainStartup` is present in an dll.
16881692
// Normal compilers use something like Zig's crtdll.c instead we provide a

src/builtins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,11 +1365,11 @@ JL_CALLABLE(jl_f_apply_type)
13651365
jl_vararg_t *vm = (jl_vararg_t*)args[0];
13661366
if (!vm->T) {
13671367
JL_NARGS(apply_type, 2, 3);
1368-
return (jl_value_t*)jl_wrap_vararg(args[1], nargs == 3 ? args[2] : NULL, 1);
1368+
return (jl_value_t*)jl_wrap_vararg(args[1], nargs == 3 ? args[2] : NULL, 1, 0);
13691369
}
13701370
else if (!vm->N) {
13711371
JL_NARGS(apply_type, 2, 2);
1372-
return (jl_value_t*)jl_wrap_vararg(vm->T, args[1], 1);
1372+
return (jl_value_t*)jl_wrap_vararg(vm->T, args[1], 1, 0);
13731373
}
13741374
}
13751375
else if (jl_is_unionall(args[0])) {
@@ -2060,7 +2060,7 @@ void jl_init_primitives(void) JL_GC_DISABLED
20602060
add_builtin("Tuple", (jl_value_t*)jl_anytuple_type);
20612061
add_builtin("TypeofVararg", (jl_value_t*)jl_vararg_type);
20622062
add_builtin("SimpleVector", (jl_value_t*)jl_simplevector_type);
2063-
add_builtin("Vararg", (jl_value_t*)jl_wrap_vararg(NULL, NULL, 0));
2063+
add_builtin("Vararg", (jl_value_t*)jl_wrap_vararg(NULL, NULL, 0, 0));
20642064

20652065
add_builtin("Module", (jl_value_t*)jl_module_type);
20662066
add_builtin("MethodTable", (jl_value_t*)jl_methtable_type);

src/codegen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,12 @@ struct JuliaVariable {
493493
if (GlobalValue *V = m->getNamedValue(name))
494494
return cast<GlobalVariable>(V);
495495
auto T_size = m->getDataLayout().getIntPtrType(m->getContext());
496-
return new GlobalVariable(*m, _type(T_size),
496+
auto var = new GlobalVariable(*m, _type(T_size),
497497
isconst, GlobalVariable::ExternalLinkage,
498498
NULL, name);
499+
if (Triple(m->getTargetTriple()).isOSWindows())
500+
var->setDLLStorageClass(GlobalValue::DLLStorageClassTypes::DLLImportStorageClass); // Cross-library imports must be explicit for COFF (Windows)
501+
return var;
499502
}
500503
GlobalVariable *realize(jl_codectx_t &ctx);
501504
};
@@ -1786,9 +1789,6 @@ static inline GlobalVariable *prepare_global_in(Module *M, GlobalVariable *G)
17861789
G->isConstant(), GlobalVariable::ExternalLinkage,
17871790
nullptr, G->getName(), nullptr, G->getThreadLocalMode());
17881791
proto->copyAttributesFrom(G);
1789-
// DLLImport only needs to be set for the shadow module
1790-
// it just gets annoying in the JIT
1791-
proto->setDLLStorageClass(GlobalValue::DefaultStorageClass);
17921792
return proto;
17931793
}
17941794
return cast<GlobalVariable>(local);

src/gf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static jl_value_t *inst_varargp_in_env(jl_value_t *decl, jl_svec_t *sparams)
735735
vm = T_has_tv ? jl_type_unionall(v, T) : T;
736736
if (N_has_tv)
737737
N = NULL;
738-
vm = (jl_value_t*)jl_wrap_vararg(vm, N, 1); // this cannot throw for these inputs
738+
vm = (jl_value_t*)jl_wrap_vararg(vm, N, 1, 0); // this cannot throw for these inputs
739739
}
740740
sp++;
741741
decl = ((jl_unionall_t*)decl)->body;
@@ -984,7 +984,7 @@ static void jl_compilation_sig(
984984
// avoid Vararg{Type{Type{...}}}
985985
if (jl_is_type_type(type_i) && jl_is_type_type(jl_tparam0(type_i)))
986986
type_i = (jl_value_t*)jl_type_type;
987-
type_i = (jl_value_t*)jl_wrap_vararg(type_i, (jl_value_t*)NULL, 1); // this cannot throw for these inputs
987+
type_i = (jl_value_t*)jl_wrap_vararg(type_i, (jl_value_t*)NULL, 1, 0); // this cannot throw for these inputs
988988
}
989989
else {
990990
type_i = inst_varargp_in_env(decl, sparams);

src/interpreter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ static jl_value_t *do_invoke(jl_value_t **args, size_t nargs, interpreter_state
135135
JL_GC_PUSHARGS(argv, nargs - 1);
136136
size_t i;
137137
for (i = 1; i < nargs; i++)
138-
argv[i] = eval_value(args[i], s);
138+
argv[i-1] = eval_value(args[i], s);
139139
jl_method_instance_t *meth = (jl_method_instance_t*)args[0];
140140
assert(jl_is_method_instance(meth));
141-
jl_value_t *result = jl_invoke(argv[1], &argv[2], nargs - 2, meth);
141+
jl_value_t *result = jl_invoke(argv[0], nargs == 2 ? NULL : &argv[1], nargs - 2, meth);
142142
JL_GC_POP();
143143
return result;
144144
}

0 commit comments

Comments
 (0)