Skip to content

Commit

Permalink
[libjulia] turn LibOSXUnwind_jll into a build dep for Julia 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Feb 20, 2022
1 parent 9dc65a6 commit 81e0610
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 11 deletions.
2 changes: 1 addition & 1 deletion L/libjulia/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include("common.jl")
jllversion=v"1.7.0"
jllversion=v"1.7.1"
build_julia(ARGS, v"1.6.3"; jllversion)
build_julia(ARGS, v"1.7.0"; jllversion)
build_julia(ARGS, v"1.8.0-DEV"; jllversion)
65 changes: 65 additions & 0 deletions L/libjulia/bundled/libunwind-julia-1.6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/src/julia_internal.h b/src/julia_internal.h
index 0b76696791..f6bd2f1f3f 100644
--- a/src/julia_internal.h
+++ b/src/julia_internal.h
@@ -893,48 +893,7 @@ typedef struct {

// Might be called from unmanaged thread
uint64_t jl_getUnwindInfo(uint64_t dwBase);
-#ifdef _OS_WINDOWS_
-#include <dbghelp.h>
-JL_DLLEXPORT EXCEPTION_DISPOSITION __julia_personality(
- PEXCEPTION_RECORD ExceptionRecord, void *EstablisherFrame, PCONTEXT ContextRecord, void *DispatcherContext);
-extern HANDLE hMainThread;
-typedef CONTEXT bt_context_t;
-#if defined(_CPU_X86_64_)
-typedef CONTEXT bt_cursor_t;
-#else
-typedef struct {
- STACKFRAME64 stackframe;
- CONTEXT context;
-} bt_cursor_t;
-#endif
-extern jl_mutex_t jl_in_stackwalk;
-#elif !defined(JL_DISABLE_LIBUNWIND)
-// This gives unwind only local unwinding options ==> faster code
-# define UNW_LOCAL_ONLY
-# include <libunwind.h>
-typedef unw_context_t bt_context_t;
-typedef unw_cursor_t bt_cursor_t;
-# if (!defined(SYSTEM_LIBUNWIND) || UNW_VERSION_MAJOR > 1 || \
- (UNW_VERSION_MAJOR == 1 && UNW_VERSION_MINOR != 0 && UNW_VERSION_MINOR != 1))
-// Enable our memory manager only for libunwind with our patch or
-// on a newer release
-# define JL_UNW_HAS_FORMAT_IP 1
-# endif
-#else
-// Unwinding is disabled
-typedef int bt_context_t;
-typedef int bt_cursor_t;
-#endif
-size_t rec_backtrace(jl_bt_element_t *bt_data, size_t maxsize, int skip) JL_NOTSAFEPOINT;
-// Record backtrace from a signal handler. `ctx` is the context of the code
-// which was asynchronously interrupted.
-size_t rec_backtrace_ctx(jl_bt_element_t *bt_data, size_t maxsize, bt_context_t *ctx,
- jl_gcframe_t *pgcstack) JL_NOTSAFEPOINT;
-#ifdef LIBOSXUNWIND
-size_t rec_backtrace_ctx_dwarf(jl_bt_element_t *bt_data, size_t maxsize, bt_context_t *ctx, jl_gcframe_t *pgcstack) JL_NOTSAFEPOINT;
-#endif
JL_DLLEXPORT jl_value_t *jl_get_backtrace(void);
-void jl_critical_error(int sig, bt_context_t *context);
JL_DLLEXPORT void jl_raise_debugger(void);
int jl_getFunctionInfo(jl_frame_t **frames, uintptr_t pointer, int skipC, int noInline) JL_NOTSAFEPOINT;
JL_DLLEXPORT void jl_gdblookup(void* ip) JL_NOTSAFEPOINT;
diff --git a/src/julia_threads.h b/src/julia_threads.h
index f42984130f..8a8411f822 100644
--- a/src/julia_threads.h
+++ b/src/julia_threads.h
@@ -67,7 +67,6 @@ typedef struct {
#endif
#if defined(JL_HAVE_UCONTEXT) || defined(JL_HAVE_UNW_CONTEXT)
#define UNW_LOCAL_ONLY
-#include <libunwind.h>
typedef struct {
ucontext_t ctx;
#if defined(JL_TSAN_ENABLED)
44 changes: 34 additions & 10 deletions L/libjulia/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ function libjulia_platforms(julia_version)
return platforms
end

libjulia_platforms() = vcat(libjulia_platforms(v"1.6.0"), libjulia_platforms(v"1.7.0"))

# Collection of sources required to build Julia
function build_julia(ARGS, version::VersionNumber; jllversion=version)
name = "libjulia"
Expand All @@ -65,6 +63,14 @@ function build_julia(ARGS, version::VersionNumber; jllversion=version)
ArchiveSource("https://github.com/JuliaLang/julia/releases/download/v$(version)/julia-$(version).tar.gz", checksums[version]),
DirectorySource("./bundled"),
]

if version == v"1.6.3"
# WORKAROUND
push!(sources, ArchiveSource("https://github.com/JuliaBinaryWrappers/LibOSXUnwind_jll.jl/releases/download/LibOSXUnwind-v0.0.7%2B0/LibOSXUnwind.v0.0.7.x86_64-apple-darwin.tar.gz",
"e2ea6ecae13c0f2666d1b3020098feeab92affae1614f6b2a992dde0af88ec2f",
unpack_target="LibOSXUnwind_jll"))
end

end

# Bash recipe for building across all platforms
Expand All @@ -83,6 +89,16 @@ function build_julia(ARGS, version::VersionNumber; jllversion=version)
done
fi
# HACK to allow building Julia 1.6 in Julia >= 1.7, as we can't install an old
# LibOSXUnwind_jll for it (due to it becoming a stdlib in Julia 1.7).
# See also <https://github.com/JuliaPackaging/Yggdrasil/pull/4320>
if [[ "${target}" == *apple* ]] && [[ "${version}" == 1.6.* ]]; then
cp $WORKSPACE/srcdir/LibOSXUnwind_jll/include/*.h ${includedir}
mkdir -p ${includedir}/mach-o
cp $WORKSPACE/srcdir/LibOSXUnwind_jll/include/mach-o/*.h ${includedir}/mach-o
cp $WORKSPACE/srcdir/LibOSXUnwind_jll/lib/libosxunwind.* ${libdir}
fi
case ${target} in
*linux*)
OS=Linux
Expand Down Expand Up @@ -268,6 +284,14 @@ function build_julia(ARGS, version::VersionNumber; jllversion=version)
# environment results in a segfault.
make USE_CROSS_FLISP=1 NO_GIT=1 LDFLAGS="${LDFLAGS}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" -j${nproc} VERBOSE=1 ${MAKE_TARGET} DSYMUTIL=true
# HACK to avoid runtime dependency on LibOSXUnwind_jll with Julia 1.6: it
# disables the `#include <libunwind.h>` statements in two header files,
# and all code directly depending on them; luckily all of that is internal
# and should not affect external code using the Julia kernel "API"
if [[ "${version}" == 1.6.* ]]; then
atomic_patch -p1 $WORKSPACE/srcdir/libunwind-julia-1.6.patch
fi
# 'manually' install libraries and headers
mkdir -p ${libdir}
mkdir -p ${includedir}/julia
Expand Down Expand Up @@ -313,8 +337,8 @@ function build_julia(ARGS, version::VersionNumber; jllversion=version)
]
if version < v"1.5.1"
push!(dependencies, Dependency("LibOSXUnwind_jll", compat="0.0.5"))
elseif version < v"1.7"
push!(dependencies, Dependency("LibOSXUnwind_jll", compat="0.0.6"))
elseif version < v"1.6"
push!(dependencies, BuildDependency(PackageSpec(; name="LibOSXUnwind_jll", version=v"0.0.6")))
end

if version < v"1.6"
Expand All @@ -323,11 +347,11 @@ function build_julia(ARGS, version::VersionNumber; jllversion=version)
push!(dependencies, BuildDependency("SuiteSparse_jll"))
end

if version < v"1.7"
push!(dependencies, BuildDependency(PackageSpec(name="PCRE2_jll", version=v"10")))
#if version < v"1.7"
# push!(dependencies, BuildDependency(PackageSpec(name="PCRE2_jll", version=v"10")))
#else
# push!(dependencies, BuildDependency("PCRE2_jll", compat="10.36"))
end
#end

if version.major == 1 && version.minor == 3
push!(dependencies, BuildDependency("OpenBLAS_jll", compat="0.3.5"))
Expand All @@ -343,9 +367,9 @@ function build_julia(ARGS, version::VersionNumber; jllversion=version)
push!(dependencies, Dependency("libLLVM_jll", compat="9.0.1"))
push!(dependencies, BuildDependency(PackageSpec(name="LibGit2_jll", version=v"0.28.2")))
elseif version.major == 1 && version.minor == 6
push!(dependencies, BuildDependency(PackageSpec(name="OpenBLAS_jll", version=v"0.3.10")))
push!(dependencies, Dependency("libLLVM_jll", compat="11.0.1"))
push!(dependencies, BuildDependency(PackageSpec(name="LibGit2_jll", version=v"1.2")))
push!(dependencies, BuildDependency(get_addable_spec("OpenBLAS_jll", v"0.3.10+10")))
push!(dependencies, BuildDependency(get_addable_spec("LLVM_full_jll", v"11.0.1+3")))
push!(dependencies, BuildDependency(get_addable_spec("LibGit2_jll", v"1.2.3+0")))
elseif version.major == 1 && version.minor == 7
#push!(dependencies, BuildDependency("OpenBLAS_jll", compat="0.3.13"))
#push!(dependencies, Dependency("libLLVM_jll", compat="12.0.0"))
Expand Down

0 comments on commit 81e0610

Please sign in to comment.