diff --git a/cli/Makefile b/cli/Makefile index 39cabecf1be81d..3e49a9f781febf 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 74d8a150dc6394..12fcd1a2aaa291 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 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 a8ab0b9837522d..7530693d743de9 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];