Skip to content

Commit

Permalink
[julia-git] Fix broken compilation due to JuliaLang/julia#36588
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Sep 25, 2020
1 parent 1e9ef7c commit b29b9d4
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
From 18daf2967a518634f9d7477d523de5e56ea12cab Mon Sep 17 00:00:00 2001
From: Yichao Yu <[email protected]>
Date: Thu, 24 Sep 2020 22:10:32 -0400
Subject: [PATCH 1/7] Fix broken linking and initialization due to #36588

And speed up startup.
---
cli/Makefile | 8 ++++----
cli/loader_exe.c | 9 +++++++--
cli/loader_lib.c | 3 +++
3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/cli/Makefile b/cli/Makefile
index 39cabecf1b..3e49a9f781 100644
--- a/cli/Makefile
+++ b/cli/Makefile
@@ -79,7 +79,7 @@ $(build_bindir)/julia-debug$(EXE): $(BUILDDIR)/Info.plist
endif

$(build_shlibdir)/libjulialoader.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_OBJS)
- @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) -shared $(SHIPFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB))
+ @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) -shared $(SHIPFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB)) $(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT)
ifneq ($(OS), WINNT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader.$(JL_MAJOR_SHLIB_EXT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader.$(SHLIB_EXT)
@@ -87,17 +87,17 @@ endif


$(build_shlibdir)/libjulialoader-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_DOBJS)
- @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) -shared $(DEBUGFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB))
+ @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) -shared $(DEBUGFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH_LIB)) $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT)
ifneq ($(OS), WINNT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader-debug.$(JL_MAJOR_SHLIB_EXT)
@ln -sf $(notdir $@) $(build_shlibdir)/libjulialoader-debug.$(SHLIB_EXT)
endif

$(build_bindir)/julia$(EXE): $(OBJS)
- @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(SHIPFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH))
+ @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(SHIPFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH) $(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT))

$(build_bindir)/julia-debug$(EXE): $(DOBJS)
- @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(DEBUGFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH))
+ @$(call PRINT_LINK, $(CC) $(LOADER_CFLAGS) $(DEBUGFLAGS) $^ -o $@ $(LOADER_LDFLAGS) $(RPATH) $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT))


clean: | $(CLEAN_TARGETS)
diff --git a/cli/loader_exe.c b/cli/loader_exe.c
index 74d8a150dc..12fcd1a2aa 100644
--- a/cli/loader_exe.c
+++ b/cli/loader_exe.c
@@ -6,13 +6,18 @@ extern "C" {

/* Define ptls getter, as this cannot be defined within a shared library. */
#if !defined(_OS_WINDOWS_) && !defined(_OS_DARWIN_)
-__attribute__ ((visibility("default"))) JL_CONST_FUNC void * jl_get_ptls_states_static(void)
+void jl_set_ptls_states_getter(void *(*f)(void));
+static JL_CONST_FUNC void * jl_get_ptls_states_static(void)
{
/* Because we can't #include <julia.h> in this file, we define a TLS state object with
* hopefully enough room; at last check, the `jl_tls_states_t` struct was <16KB. */
static __attribute__((tls_model("local-exec"))) __thread char tls_states[32768];
return &tls_states;
}
+__attribute__((constructor)) void jl_register_ptls_states_getter(void)
+{
+ jl_set_ptls_states_getter(jl_get_ptls_states_static);
+}
#endif

#ifdef _OS_WINDOWS_
@@ -27,7 +32,7 @@ int main(int argc, char * argv[])
{
#endif
// Immediately get the current exe dir, allowing us to calculate relative paths.
- const char * exe_dir = get_exe_dir();
+ const char * exe_dir = NULL; // get_exe_dir();

#ifdef _OS_WINDOWS_
// Convert Windows wchar_t values to UTF8
diff --git a/cli/loader_lib.c b/cli/loader_lib.c
index a8ab0b9837..7530693d74 100644
--- a/cli/loader_lib.c
+++ b/cli/loader_lib.c
@@ -131,9 +131,12 @@ const char * get_exe_dir()
return exe_dir;
}

+int repl_entrypoint(int argc, char *argv[]);
+
// Load libjulia and run the REPL with the given arguments (in UTF-8 format)
int load_repl(const char * exe_dir, int argc, char * argv[])
{
+ return repl_entrypoint(argc, (char **)argv);
// Pre-load libraries that libjulia needs.
int deps_len = strlen(dep_libs);
char * curr_dep = &dep_libs[0];
--
2.28.0

2 changes: 1 addition & 1 deletion archlinuxcn/julia-git/0002-Fix-source-file-paths.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 292218f0e1d7895622f89f36bd5a1de5a7618435 Mon Sep 17 00:00:00 2001
From ed5cbaf4e0897f58efa41f4fcf5a9e44a700cd28 Mon Sep 17 00:00:00 2001
From: Yichao Yu <[email protected]>
Date: Sun, 19 Jul 2020 09:40:32 -0400
Subject: [PATCH 2/7] Fix source file paths
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 245461fb6c105700c13354818a298de194052901 Mon Sep 17 00:00:00 2001
From 7a167f64eb72a3f505b42b31fcc22bfbd32a9c2d Mon Sep 17 00:00:00 2001
From: Yichao Yu <[email protected]>
Date: Sat, 22 Aug 2020 10:19:15 -0400
Subject: [PATCH 3/7] Optimize allocation of arrays
Expand All @@ -11,10 +11,10 @@ Subject: [PATCH 3/7] Optimize allocation of arrays
4 files changed, 115 insertions(+), 12 deletions(-)

diff --git a/base/boot.jl b/base/boot.jl
index e653a82399..f23621a966 100644
index 7c8d05cc13..c6db3a37e5 100644
--- a/base/boot.jl
+++ b/base/boot.jl
@@ -430,19 +430,11 @@ const NTuple{N,T} = Tuple{Vararg{T,N}}
@@ -445,19 +445,11 @@ const NTuple{N,T} = Tuple{Vararg{T,N}}
struct UndefInitializer end
const undef = UndefInitializer()
# type and dimensionality specified, accepting dims as series of Ints
Expand Down
2 changes: 1 addition & 1 deletion archlinuxcn/julia-git/0004-Enable-basic-AA-in-O2.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 59f66247961e29c46db7cd0102fc26a586b0ffdd Mon Sep 17 00:00:00 2001
From 8e660c4cc342feb40ce75f15b11d7eb79cbdf6fe Mon Sep 17 00:00:00 2001
From: Yichao Yu <[email protected]>
Date: Mon, 31 Aug 2020 12:44:58 -0400
Subject: [PATCH 4/7] Enable basic AA in O2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 3b1bfd92c3dd65a6b8786ef580e24bff1e8446c4 Mon Sep 17 00:00:00 2001
From 5a0feed8efc1476e7d0faa40d4addfc847a4eaf9 Mon Sep 17 00:00:00 2001
From: Yichao Yu <[email protected]>
Date: Fri, 21 Aug 2020 10:29:29 -0400
Subject: [PATCH 5/7] Add ccall special cases for a few more libc functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 363ae638f7dab9666953d272ba0ea634fa621e1b Mon Sep 17 00:00:00 2001
From 2a57b5286e544ad4178de9d652e05e70df15bdcc Mon Sep 17 00:00:00 2001
From: Yichao Yu <[email protected]>
Date: Fri, 21 Aug 2020 13:15:02 -0400
Subject: [PATCH 6/7] Optimize objectid in codegen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 1d1ab6de59ad420562176257724a39e9e8b161c4 Mon Sep 17 00:00:00 2001
From 5cf5068bdc64a6fe37380271b64d3aecf1ecda85 Mon Sep 17 00:00:00 2001
From: Yichao Yu <[email protected]>
Date: Thu, 13 Aug 2020 02:24:27 -0400
Subject: [PATCH 7/7] Mark more functions as not safepoint in codegen.
Expand Down
14 changes: 8 additions & 6 deletions archlinuxcn/julia-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ makedepends=("${depends_libs[@]}" "${makedepends_llvm[@]}"
gcc-fortran git patchelf python)
options=('debug' '!strip' '!buildflags')
_patches=(
0001-Fix-broken-linking-and-initialization-due-to-36588.patch
0002-Fix-source-file-paths.patch
0003-Optimize-allocation-of-arrays.patch
0004-Enable-basic-AA-in-O2.patch
Expand All @@ -60,12 +61,13 @@ source=('git://github.com/JuliaLang/julia'
julia-clear-precompile.hook
arch-source-translate.cpp)
md5sums=('SKIP'
'69eacc96dbfd27ae8103bf6171e28619'
'60e6d3ae62adc938f3e4aed050769696'
'4bfae9c17499c322d1b8fc2b0167f052'
'd6e7afc5e3755ae8116738238b455063'
'fc1d741c0e2ebd0c80bbf9762b9e9a4f'
'aa6424e67a790c65b4d0d28d66befcd2'
'3b4e9222b2f75587f822df0b95eb0a00'
'3ce8db2b6b13c891acfd39d98daa51bc'
'7ea0764315f173971f240aac51e53ade'
'e21fcad49073286a119cc7a471449d3f'
'435c34f51e3934fd15266bec801cc07d'
'818c161a5d25d276c5a990d5883ec564'
'6eca32e71f0a21aac66ca30821fd7bbe'
'effd2c21ffb69e66b43d4b7fbe074a51'
'bde100b283ea5b7aaf80613abec98a57'
'6e7fcba300512df8ab8ab65d3e1eb847'
Expand Down
2 changes: 1 addition & 1 deletion archlinuxcn/julia-git/lilac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ repo_depends:
update_on:
- source: vcs
- source: manual
manual: 29
manual: 30

0 comments on commit b29b9d4

Please sign in to comment.