Skip to content

Commit 2e1bcc6

Browse files
authored
Merge pull request #17179 from JuliaLang/jn/personality
win: precompile=yes :)
2 parents 4823351 + 5f31073 commit 2e1bcc6

File tree

9 files changed

+33
-25
lines changed

9 files changed

+33
-25
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ notifications:
5656
- http://julia.mit.edu:8000/travis-hook
5757
before_install:
5858
- make check-whitespace
59-
- JULIA_SYSIMG_BUILD_FLAGS="--output-ji ../usr/lib/julia/sys.ji"
6059
- if [ `uname` = "Linux" ]; then
6160
contrib/travis_fastfail.sh || exit 1;
6261
mkdir -p $HOME/bin;
@@ -93,7 +92,7 @@ script:
9392
- make -C moreutils mispipe
9493
- make $BUILDOPTS -C base version_git.jl.phony
9594
- moreutils/mispipe "make $BUILDOPTS NO_GIT=1 -C deps" bar > deps.log || cat deps.log
96-
- make $BUILDOPTS NO_GIT=1 JULIA_SYSIMG_BUILD_FLAGS="$JULIA_SYSIMG_BUILD_FLAGS" prefix=/tmp/julia install | moreutils/ts -s "%.s"
95+
- make $BUILDOPTS NO_GIT=1 prefix=/tmp/julia install | moreutils/ts -s "%.s"
9796
- make $BUILDOPTS NO_GIT=1 build-stats
9897
- du -sk /tmp/julia/*
9998
- if [ `uname` = "Darwin" ]; then
@@ -102,8 +101,8 @@ script:
102101
done;
103102
fi
104103
- cd .. && mv julia julia2
105-
- cp /tmp/julia/lib/julia/sys.ji local.ji && /tmp/julia/bin/julia -J local.ji -e 'true' &&
106-
/tmp/julia/bin/julia-debug -J local.ji -e 'true' && rm local.ji
104+
- /tmp/julia/bin/julia --precompiled=no -e 'true' &&
105+
/tmp/julia/bin/julia-debug --precompiled=no -e 'true'
107106
- /tmp/julia/bin/julia -e 'versioninfo()'
108107
- export JULIA_CPU_CORES=2 && export JULIA_TEST_MAXRSS_MB=600 && cd /tmp/julia/share/julia/test &&
109108
/tmp/julia/bin/julia --check-bounds=yes runtests.jl $TESTSTORUN &&

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ build_script:
5353

5454
test_script:
5555
- usr\bin\julia -e "versioninfo()"
56-
- copy usr\lib\julia\sys.ji local.ji && usr\bin\julia -J local.ji -e "true" && del local.ji
56+
- usr\bin\julia --precompiled=no -e "true"
5757
- cd test && ..\usr\bin\julia --check-bounds=yes runtests.jl all &&
5858
..\usr\bin\julia --check-bounds=yes runtests.jl libgit2-online pkg

contrib/windows/msys_build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ for lib in SUITESPARSE ARPACK BLAS LAPACK FFTW \
166166
done
167167
echo 'override LIBLAPACK = $(LIBBLAS)' >> Make.user
168168
echo 'override LIBLAPACKNAME = $(LIBBLASNAME)' >> Make.user
169-
echo 'JULIA_SYSIMG_BUILD_FLAGS=--output-ji ../usr/lib/julia/sys.ji' >> Make.user
170169

171170
# Remaining dependencies:
172171
# libuv since its static lib is no longer included in the binaries

src/codegen.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
#include "llvm-version.h"
44
#include "platform.h"
55
#include "options.h"
6-
#if defined(_OS_WINDOWS_) && !defined(LLVM38)
7-
// trick pre-llvm38 into skipping the generation of _chkstk calls
6+
#if defined(_OS_WINDOWS_) && !defined(LLVM39)
7+
// trick pre-llvm39 into skipping the generation of _chkstk calls
88
// since it has some codegen issues associated with them:
99
// (a) assumed to be within 32-bit offset
1010
// (b) bad asm is generated for certain code patterns:
1111
// see https://github.com/JuliaLang/julia/pull/11644#issuecomment-112276813
1212
// also, use ELF because RuntimeDyld COFF I686 support didn't exist
13+
// also, use ELF because RuntimeDyld COFF X86_64 doesn't seem to work (fails to generate function pointers)?
1314
#define FORCE_ELF
1415
#endif
1516
#if defined(_CPU_X86_)
@@ -414,6 +415,9 @@ static Function *jlgetnthfieldchecked_func;
414415
//static Function *jlsetnthfield_func;
415416
#ifdef _OS_WINDOWS_
416417
static Function *resetstkoflw_func;
418+
#if defined(_CPU_X86_64_)
419+
static Function *juliapersonality_func;
420+
#endif
417421
#endif
418422
static Function *diff_gc_total_bytes_func;
419423
static Function *jlarray_data_owner_func;
@@ -5464,6 +5468,11 @@ static void init_julia_llvm_env(Module *m)
54645468
resetstkoflw_func = Function::Create(FunctionType::get(T_int32, false),
54655469
Function::ExternalLinkage, "_resetstkoflw", m);
54665470
add_named_global(resetstkoflw_func, &_resetstkoflw);
5471+
#if defined(_CPU_X86_64_)
5472+
juliapersonality_func = Function::Create(FunctionType::get(T_int32, true),
5473+
Function::ExternalLinkage, "__julia_personality", m);
5474+
add_named_global(juliapersonality_func, &__julia_personality);
5475+
#endif
54675476
#ifndef FORCE_ELF
54685477
#if defined(_CPU_X86_64_)
54695478
#if defined(_COMPILER_MINGW_)

src/debuginfo.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ void jl_add_linfo_in_flight(StringRef name, jl_lambda_info_t *linfo, const DataL
128128
}
129129

130130
#if defined(_OS_WINDOWS_)
131-
#if defined(_CPU_X86_64_)
132-
extern "C" EXCEPTION_DISPOSITION _seh_exception_handler(PEXCEPTION_RECORD ExceptionRecord,void *EstablisherFrame, PCONTEXT ContextRecord, void *DispatcherContext);
133-
#endif
134131
static void create_PRUNTIME_FUNCTION(uint8_t *Code, size_t Size, StringRef fnname,
135132
uint8_t *Section, size_t Allocated, uint8_t *UnwindData)
136133
{
@@ -143,7 +140,7 @@ static void create_PRUNTIME_FUNCTION(uint8_t *Code, size_t Size, StringRef fnnam
143140
if (!catchjmp[0]) {
144141
catchjmp[0] = 0x48;
145142
catchjmp[1] = 0xb8; // mov RAX, QWORD PTR [...]
146-
*(uint64_t*)(&catchjmp[2]) = (uint64_t)&_seh_exception_handler;
143+
*(uint64_t*)(&catchjmp[2]) = (uint64_t)&__julia_personality;
147144
catchjmp[10] = 0xff;
148145
catchjmp[11] = 0xe0; // jmp RAX
149146
UnwindData[0] = 0x09; // version info, UNW_FLAG_EHANDLER
@@ -421,9 +418,9 @@ class JuliaJITEventListener: public JITEventListener
421418
assert(SectionAddrCheck);
422419
assert(SectionLoadOffset != 1);
423420
catchjmp[SectionLoadOffset] = 0x48;
424-
catchjmp[SectionLoadOffset + 1] = 0xb8; // mov RAX, QWORD PTR [&_seh_exception_handle]
421+
catchjmp[SectionLoadOffset + 1] = 0xb8; // mov RAX, QWORD PTR [&__julia_personality]
425422
*(uint64_t*)(&catchjmp[SectionLoadOffset + 2]) =
426-
(uint64_t)&_seh_exception_handler;
423+
(uint64_t)&__julia_personality;
427424
catchjmp[SectionLoadOffset + 10] = 0xff;
428425
catchjmp[SectionLoadOffset + 11] = 0xe0; // jmp RAX
429426
UnwindData[SectionLoadOffset] = 0x09; // version info, UNW_FLAG_EHANDLER

src/init.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ jl_options_t jl_options = { 0, // quiet
7373
JL_OPTIONS_FAST_MATH_DEFAULT,
7474
0, // worker
7575
JL_OPTIONS_HANDLE_SIGNALS_ON,
76-
#ifdef _OS_WINDOWS_
77-
// TODO remove this when using LLVM 3.5+
78-
JL_OPTIONS_USE_PRECOMPILED_NO,
79-
#else
8076
JL_OPTIONS_USE_PRECOMPILED_YES,
81-
#endif
8277
JL_OPTIONS_USE_COMPILECACHE_YES,
8378
NULL, // bindto
8479
NULL, // outputbc

src/jitlayers.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,29 +532,37 @@ ExecutionEngine *jl_ExecutionEngine;
532532
#endif
533533

534534
// MSVC's link.exe requires each function declaration to have a Comdat section
535-
// rather than litter the code with conditionals,
535+
// So rather than litter the code with conditionals,
536536
// all global values that get emitted call this function
537537
// and it decides whether the definition needs a Comdat section and adds the appropriate declaration
538538
// TODO: consider moving this into jl_add_to_shadow or jl_dump_shadow? the JIT doesn't care, so most calls are now no-ops
539539
template<class T> // for GlobalObject's
540540
static T *addComdat(T *G)
541541
{
542-
#if defined(_OS_WINDOWS_) && defined(_COMPILER_MICROSOFT_)
542+
#if defined(_OS_WINDOWS_) && defined(LLVM35)
543543
if (imaging_mode && !G->isDeclaration()) {
544-
#ifdef LLVM35
545544
// Add comdat information to make MSVC link.exe happy
545+
// it's valid to emit this for ld.exe too,
546+
// but makes it very slow to link for no benefit
546547
if (G->getParent() == shadow_output) {
548+
#if defined(_COMPILER_MICROSOFT_)
547549
Comdat *jl_Comdat = G->getParent()->getOrInsertComdat(G->getName());
548550
// ELF only supports Comdat::Any
549551
jl_Comdat->setSelectionKind(Comdat::NoDuplicates);
550552
G->setComdat(jl_Comdat);
553+
#endif
554+
#if defined(_CPU_X86_64_)
555+
// Add unwind exception personalities to functions to handle async exceptions
556+
assert(!juliapersonality_func || juliapersonality_func->getParent() == shadow_output);
557+
if (Function *F = dyn_cast<Function>(G))
558+
F->setPersonalityFn(juliapersonality_func);
559+
#endif
551560
}
552561
// add __declspec(dllexport) to everything marked for export
553562
if (G->getLinkage() == GlobalValue::ExternalLinkage)
554563
G->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
555564
else
556565
G->setDLLStorageClass(GlobalValue::DefaultStorageClass);
557-
#endif
558566
}
559567
#endif
560568
return G;

src/julia_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ typedef struct {
350350
uint64_t jl_getUnwindInfo(uint64_t dwBase);
351351
#ifdef _OS_WINDOWS_
352352
#include <dbghelp.h>
353+
JL_DLLEXPORT EXCEPTION_DISPOSITION __julia_personality(
354+
PEXCEPTION_RECORD ExceptionRecord, void *EstablisherFrame, PCONTEXT ContextRecord, void *DispatcherContext);
353355
extern HANDLE hMainThread;
354356
typedef CONTEXT bt_context_t;
355357
#if defined(_CPU_X86_64_)

src/signals-win.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ static LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
278278
}
279279

280280
#if defined(_CPU_X86_64_)
281-
EXCEPTION_DISPOSITION _seh_exception_handler(PEXCEPTION_RECORD ExceptionRecord, void *EstablisherFrame, PCONTEXT ContextRecord, void *DispatcherContext)
282-
{
281+
JL_DLLEXPORT EXCEPTION_DISPOSITION __julia_personality(PEXCEPTION_RECORD ExceptionRecord, void *EstablisherFrame, PCONTEXT ContextRecord, void *DispatcherContext) {
283282
EXCEPTION_POINTERS ExceptionInfo;
284283
ExceptionInfo.ExceptionRecord = ExceptionRecord;
285284
ExceptionInfo.ContextRecord = ContextRecord;

0 commit comments

Comments
 (0)