From 8395890a2407b3cec15411754feaa7f8a8130f4f Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Fri, 28 Feb 2025 13:28:01 -0500 Subject: [PATCH 1/9] Use `JULIA_DEPOT_PATH` and `JULIA_LOAD_PATH` from the environment When these environment variables are set, use them. --- src/julia_init.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/julia_init.c b/src/julia_init.c index d598f90b..112c4f85 100644 --- a/src/julia_init.c +++ b/src/julia_init.c @@ -46,19 +46,39 @@ void set_depot_load_path(const char *root_dir) { #else char *julia_share_subdir = "/share/julia"; #endif - char *share_dir = - calloc(sizeof(char), strlen(root_dir) + strlen(julia_share_subdir) + 1); - strcat(share_dir, root_dir); - strcat(share_dir, julia_share_subdir); + int share_path_len = strlen(root_dir) + strlen(julia_share_subdir) + 1; + + char *curr_depot_path = getenv("JULIA_DEPOT_PATH"); + int curr_depot_path_len = curr_depot_path == NULL ? 0 : strlen(curr_depot_path); + int new_depot_path_len = curr_depot_path_len + 1 + share_path_len; + char *new_depot_path = calloc(sizeof (char), new_depot_path_len); + if (curr_depot_path_len > 0) { + strcat(new_depot_path, curr_depot_path); + strcat(new_depot_path, ":"); + } + strcat(new_depot_path, root_dir); + strcat(new_depot_path, julia_share_subdir); + + char *curr_load_path = getenv("JULIA_LOAD_PATH"); + int curr_load_path_len = curr_load_path == NULL ? 0 : strlen(curr_load_path); + int new_load_path_len = curr_load_path_len + 1 + share_path_len; + char *new_load_path = calloc(sizeof (char), new_load_path_len); + if (curr_load_path_len > 0) { + strcat(new_load_path, curr_load_path); + strcat(new_load_path, ":"); + } + strcat(new_load_path, root_dir); + strcat(new_load_path, julia_share_subdir); #ifdef _WIN32 - _putenv_s("JULIA_DEPOT_PATH", share_dir); - _putenv_s("JULIA_LOAD_PATH", share_dir); + _putenv_s("JULIA_DEPOT_PATH", new_depot_path); + _putenv_s("JULIA_LOAD_PATH", new_load_path); #else - setenv("JULIA_DEPOT_PATH", share_dir, 1); - setenv("JULIA_LOAD_PATH", share_dir, 1); + setenv("JULIA_DEPOT_PATH", new_depot_path, 1); + setenv("JULIA_LOAD_PATH", new_load_path, 1); #endif - free(share_dir); + free(new_load_path); + free(new_depot_path); } void init_julia(int argc, char **argv) { From 3ff4c505533b7de33190f0ecc410112109896fb5 Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Wed, 5 Mar 2025 11:56:11 -0500 Subject: [PATCH 2/9] Address review comment --- src/julia_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/julia_init.c b/src/julia_init.c index 112c4f85..9bbb865a 100644 --- a/src/julia_init.c +++ b/src/julia_init.c @@ -42,8 +42,10 @@ const char *get_sysimage_path(const char *libname) { void set_depot_load_path(const char *root_dir) { #ifdef _WIN32 + char *path_sep = ";"; char *julia_share_subdir = "\\share\\julia"; #else + char *path_sep = ":"; char *julia_share_subdir = "/share/julia"; #endif int share_path_len = strlen(root_dir) + strlen(julia_share_subdir) + 1; @@ -54,7 +56,7 @@ void set_depot_load_path(const char *root_dir) { char *new_depot_path = calloc(sizeof (char), new_depot_path_len); if (curr_depot_path_len > 0) { strcat(new_depot_path, curr_depot_path); - strcat(new_depot_path, ":"); + strcat(new_depot_path, path_sep); } strcat(new_depot_path, root_dir); strcat(new_depot_path, julia_share_subdir); @@ -65,7 +67,7 @@ void set_depot_load_path(const char *root_dir) { char *new_load_path = calloc(sizeof (char), new_load_path_len); if (curr_load_path_len > 0) { strcat(new_load_path, curr_load_path); - strcat(new_load_path, ":"); + strcat(new_load_path, path_sep); } strcat(new_load_path, root_dir); strcat(new_load_path, julia_share_subdir); From 37ce1ad1b3f381d9825031ec2b54040a1f44ee78 Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Mon, 16 Jun 2025 17:47:36 -0400 Subject: [PATCH 3/9] Add test --- test/runtests.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 8db26274..ff4bd0fd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -110,8 +110,12 @@ end rm(joinpath(new_depot, "compiled"); recursive=true, force=true) rm(joinpath(new_depot, "artifacts"); recursive=true, force=true) end # try + test_load_path = mktempdir() + test_depot_path = mktempdir() app_path(app_name) = abspath(app_compiled_dir, "bin", app_name * (Sys.iswindows() ? ".exe" : "")) - app_output = read(`$(app_path("MyApp")) I get --args áéíóú --julia-args --threads=3 --check-bounds=yes -O1`, String) + app_output = withenv("JULIA_DEPOT_PATH" => test_depot_path, "JULIA_LOAD_PATH" => test_load_path) do + read(`$(app_path("MyApp")) I get --args áéíóú --julia-args --threads=3 --check-bounds=yes -O1`, String) + end # Check stdlib filtering if filter == true @@ -140,6 +144,9 @@ end # Check app is precompiled in a normal process @test occursin("outputo: ok", app_output) @test occursin("myrand: ok", app_output) + # Check env-provided depot and load paths are accepted + @test occursin("DEPOT_PATH: [\"$test_depot_path", app_output) + @test occursin("LOAD_PATH: [\"$test_load_path", app_output) # Check distributed @test occursin("n = 20000000", app_output) @test occursin("From worker 2:\t8", app_output) From 97adfe2fa2f518611b23905425cbd7fb42992c11 Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Thu, 19 Jun 2025 01:33:23 +0000 Subject: [PATCH 4/9] Update `set_depot_load_path` in the embedding wrapper Also get the test working. --- examples/MyApp/src/MyApp.jl | 8 ++++++++ src/embedding_wrapper.c | 39 +++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/examples/MyApp/src/MyApp.jl b/examples/MyApp/src/MyApp.jl index d1b12b23..43e031fc 100644 --- a/examples/MyApp/src/MyApp.jl +++ b/examples/MyApp/src/MyApp.jl @@ -38,6 +38,14 @@ function real_main() @show Base.PROGRAM_FILE @show DEPOT_PATH @show LOAD_PATH + try + @show ENV["JULIA_DEPOT_PATH"] + catch + end + try + @show ENV["JULIA_LOAD_PATH"] + catch + end @show pwd() @show Base.active_project() @show Sys.BINDIR diff --git a/src/embedding_wrapper.c b/src/embedding_wrapper.c index e74dbe2f..2394d49d 100644 --- a/src/embedding_wrapper.c +++ b/src/embedding_wrapper.c @@ -37,22 +37,45 @@ jl_value_t *checked_eval_string(const char *code) { void set_depot_load_path(const char *root_dir) { #ifdef _WIN32 + char *path_sep = ";"; char *julia_share_subdir = "\\share\\julia"; #else + char *path_sep = ":"; char *julia_share_subdir = "/share/julia"; #endif - char *share_dir = - calloc(sizeof(char), strlen(root_dir) + strlen(julia_share_subdir) + 1); - strcat(share_dir, root_dir); - strcat(share_dir, julia_share_subdir); + int share_path_len = strlen(root_dir) + strlen(julia_share_subdir) + 1; + + char *curr_depot_path = getenv("JULIA_DEPOT_PATH"); + int curr_depot_path_len = curr_depot_path == NULL ? 0 : strlen(curr_depot_path); + int new_depot_path_len = curr_depot_path_len + 1 + share_path_len; + char *new_depot_path = calloc(sizeof (char), new_depot_path_len); + if (curr_depot_path_len > 0) { + strcat(new_depot_path, curr_depot_path); + strcat(new_depot_path, path_sep); + } + strcat(new_depot_path, root_dir); + strcat(new_depot_path, julia_share_subdir); + + char *curr_load_path = getenv("JULIA_LOAD_PATH"); + int curr_load_path_len = curr_load_path == NULL ? 0 : strlen(curr_load_path); + int new_load_path_len = curr_load_path_len + 1 + share_path_len; + char *new_load_path = calloc(sizeof (char), new_load_path_len); + if (curr_load_path_len > 0) { + strcat(new_load_path, curr_load_path); + strcat(new_load_path, path_sep); + } + strcat(new_load_path, root_dir); + strcat(new_load_path, julia_share_subdir); #ifdef _WIN32 - _putenv_s("JULIA_DEPOT_PATH", share_dir); - _putenv_s("JULIA_LOAD_PATH", share_dir); + _putenv_s("JULIA_DEPOT_PATH", new_depot_path); + _putenv_s("JULIA_LOAD_PATH", new_load_path); #else - setenv("JULIA_DEPOT_PATH", share_dir, 1); - setenv("JULIA_LOAD_PATH", share_dir, 1); + setenv("JULIA_DEPOT_PATH", new_depot_path, 1); + setenv("JULIA_LOAD_PATH", new_load_path, 1); #endif + free(new_load_path); + free(new_depot_path); } // main function (windows UTF16 -> UTF8 argument conversion code copied from From 0e593bab41682c78f469cdb44070a8b7b89c0e44 Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Thu, 19 Jun 2025 16:29:37 +0000 Subject: [PATCH 5/9] Fix test and undo temporary changes --- examples/MyApp/src/MyApp.jl | 8 -------- test/runtests.jl | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/examples/MyApp/src/MyApp.jl b/examples/MyApp/src/MyApp.jl index 43e031fc..d1b12b23 100644 --- a/examples/MyApp/src/MyApp.jl +++ b/examples/MyApp/src/MyApp.jl @@ -38,14 +38,6 @@ function real_main() @show Base.PROGRAM_FILE @show DEPOT_PATH @show LOAD_PATH - try - @show ENV["JULIA_DEPOT_PATH"] - catch - end - try - @show ENV["JULIA_LOAD_PATH"] - catch - end @show pwd() @show Base.active_project() @show Sys.BINDIR diff --git a/test/runtests.jl b/test/runtests.jl index ff4bd0fd..d80ac19e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -145,8 +145,8 @@ end @test occursin("outputo: ok", app_output) @test occursin("myrand: ok", app_output) # Check env-provided depot and load paths are accepted - @test occursin("DEPOT_PATH: [\"$test_depot_path", app_output) - @test occursin("LOAD_PATH: [\"$test_load_path", app_output) + @test occursin("DEPOT_PATH = [\"$test_depot_path", app_output) + @test occursin("LOAD_PATH = [\"$test_load_path", app_output) # Check distributed @test occursin("n = 20000000", app_output) @test occursin("From worker 2:\t8", app_output) From 17f42df4a926e3c3762671749eea0f074b9c48ae Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Tue, 24 Jun 2025 17:45:37 -0400 Subject: [PATCH 6/9] Windows platforms need path strings to be escaped --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index d80ac19e..8473c2e7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -145,8 +145,8 @@ end @test occursin("outputo: ok", app_output) @test occursin("myrand: ok", app_output) # Check env-provided depot and load paths are accepted - @test occursin("DEPOT_PATH = [\"$test_depot_path", app_output) - @test occursin("LOAD_PATH = [\"$test_load_path", app_output) + @test occursin("DEPOT_PATH = [\"$(escape_string(test_depot_path))", app_output) + @test occursin("LOAD_PATH = [\"$(escape_string(test_load_path))", app_output) # Check distributed @test occursin("n = 20000000", app_output) @test occursin("From worker 2:\t8", app_output) From 9f8611eb70ca3b3ba69daf33fe49c94727afa633 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Mon, 4 Aug 2025 11:29:37 -0300 Subject: [PATCH 7/9] Add new stdlib jlls --- bin/refresh_library_mapping.jl | 2 +- src/library_selection.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/refresh_library_mapping.jl b/bin/refresh_library_mapping.jl index f38ea61d..448862ac 100644 --- a/bin/refresh_library_mapping.jl +++ b/bin/refresh_library_mapping.jl @@ -4,7 +4,7 @@ using Downloads using Libdl using Glob -v = v"1.9.0" +v = v"1.12.0" v2 = VersionNumber(v.major, v.minor) url = download_url(v, Linux(:x86_64; libc = :glibc)) diff --git a/src/library_selection.jl b/src/library_selection.jl index bb989608..9832e8d3 100644 --- a/src/library_selection.jl +++ b/src/library_selection.jl @@ -8,6 +8,9 @@ const jll_mapping = Dict( "OpenBLAS_jll" => ["libopenblas64_", "libopenblas"], "nghttp2_jll" => ["libnghttp2"], "LibGit2_jll" => ["libgit2"], + "OpenSSL_jll" => ["libcrypto", "libssl"], + "Zlib_jll" => ["libz"], + "Zstd_jll" => ["libzstd"], "SuiteSparse_jll" => ["libamd", "libbtf", "libcamd", "libccolamd", "libcholmod", "libcolamd", "libklu", "libldl", "librbio", "libspqr", "libsuitesparseconfig", "libumfpack"], "OpenSSL_jll" => ["libcrypto", "libssl"], ) From 5fbcaf03c5d9d5298e57055ec4eb240ae546f644 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Mon, 4 Aug 2025 11:31:10 -0300 Subject: [PATCH 8/9] Remove those libraries for now --- src/library_selection.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/library_selection.jl b/src/library_selection.jl index 9832e8d3..5ef512d0 100644 --- a/src/library_selection.jl +++ b/src/library_selection.jl @@ -9,8 +9,6 @@ const jll_mapping = Dict( "nghttp2_jll" => ["libnghttp2"], "LibGit2_jll" => ["libgit2"], "OpenSSL_jll" => ["libcrypto", "libssl"], - "Zlib_jll" => ["libz"], - "Zstd_jll" => ["libzstd"], "SuiteSparse_jll" => ["libamd", "libbtf", "libcamd", "libccolamd", "libcholmod", "libcolamd", "libklu", "libldl", "librbio", "libspqr", "libsuitesparseconfig", "libumfpack"], "OpenSSL_jll" => ["libcrypto", "libssl"], ) From 1ce886dde243da1f90c0fe1db2c1f8ff578c11b0 Mon Sep 17 00:00:00 2001 From: K Pamnany Date: Tue, 2 Sep 2025 16:36:28 -0400 Subject: [PATCH 9/9] Undo unnecessary changes --- bin/refresh_library_mapping.jl | 2 +- src/library_selection.jl | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/refresh_library_mapping.jl b/bin/refresh_library_mapping.jl index 448862ac..f38ea61d 100644 --- a/bin/refresh_library_mapping.jl +++ b/bin/refresh_library_mapping.jl @@ -4,7 +4,7 @@ using Downloads using Libdl using Glob -v = v"1.12.0" +v = v"1.9.0" v2 = VersionNumber(v.major, v.minor) url = download_url(v, Linux(:x86_64; libc = :glibc)) diff --git a/src/library_selection.jl b/src/library_selection.jl index 5ef512d0..bb989608 100644 --- a/src/library_selection.jl +++ b/src/library_selection.jl @@ -8,7 +8,6 @@ const jll_mapping = Dict( "OpenBLAS_jll" => ["libopenblas64_", "libopenblas"], "nghttp2_jll" => ["libnghttp2"], "LibGit2_jll" => ["libgit2"], - "OpenSSL_jll" => ["libcrypto", "libssl"], "SuiteSparse_jll" => ["libamd", "libbtf", "libcamd", "libccolamd", "libcholmod", "libcolamd", "libklu", "libldl", "librbio", "libspqr", "libsuitesparseconfig", "libumfpack"], "OpenSSL_jll" => ["libcrypto", "libssl"], )