PackageCompiler.jl icon indicating copy to clipboard operation
PackageCompiler.jl copied to clipboard

`julia_init.c`: Use `JULIA_DEPOT_PATH` and `JULIA_LOAD_PATH` from the environment

Open kpamnany opened this issue 9 months ago • 6 comments

When these environment variables are set, use them.

Closes #910.

kpamnany avatar Feb 28 '25 18:02 kpamnany

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 86.21%. Comparing base (e522d5f) to head (4d34b76). :warning: Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1032   +/-   ##
=======================================
  Coverage   86.21%   86.21%           
=======================================
  Files           3        3           
  Lines         798      798           
=======================================
  Hits          688      688           
  Misses        110      110           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Feb 28 '25 19:02 codecov[bot]

The CI failure on nightly seems to be due to an upstream change -- the alloc parameter to jl_get_binding_wr() was removed. I'm not sure how this should be fixed, but it is unrelated to this PR.

kpamnany avatar Feb 28 '25 21:02 kpamnany

Bump. Can this be reviewed please? @KristofferC? Someone else?

kpamnany avatar Mar 04 '25 14:03 kpamnany

Not to be a pain, but always nice with a test to make sure the intended use case doesn't break in the future..

KristofferC avatar Mar 05 '25 12:03 KristofferC

Not to be a pain, but always nice with a test to make sure the intended use case doesn't break in the future..

You're absolutely right. Will add one.

kpamnany avatar Mar 05 '25 16:03 kpamnany

BTW, looks like the CI workflow needs updating. All of CI has failed because:

Error: This request has been automatically failed because it uses a deprecated version of actions/cache: 0c45773b623bea8c8e75f6c82b208c3cf94ea4f9. Please update your workflow to use v3/v4 of actions/cache to avoid interruptions. Learn more: https://github.blog/changelog/2024-12-05-notice-of-upcoming-releases-and-breaking-changes-for-github-actions/#actions-cache-v1-v2-and-actions-toolkit-cache-package-closing-down

kpamnany avatar Mar 05 '25 17:03 kpamnany

I was unable to test locally:

fatal: error thrown and no exception handler available.                                    
InitError(mod=:OpenSSL_jll, error=ErrorException("could not load library \"@rpath/libcrypto.3.dylib\"\ndlopen(@rpath/libcrypto.3.dylib, 0x0001): tried: '/private/var/folders/94/8yjg0k
414zn6h3k8443yhr9w0000gn/T/jl_RFxxru/MyAppCompiled/lib/julia/libcrypto.3.dylib' (no such file), '/private/var/folders/94/8yjg0k414zn6h3k8443yhr9w0000gn/T/jl_RFxxru/MyAppCompiled/lib/j
ulia/../libcrypto.3.dylib' (no such file), '/private/var/folders/94/8yjg0k414zn6h3k8443yhr9w0000gn/T/jl_RFxxru/MyAppCompiled/lib/libcrypto.3.dylib' (no such file), '/private/var/folde
rs/94/8yjg0k414zn6h3k8443yhr9w0000gn/T/jl_RFxxru/MyAppCompiled/lib/julia/libcrypto.3.dylib' (no such file)"))

Any suggestions?

kpamnany avatar Jun 16 '25 22:06 kpamnany

Are you able to test PackageCompiler#master locally?

DilumAluthge avatar Jun 16 '25 22:06 DilumAluthge

Are you able to test PackageCompiler#master locally?

No, when I tried, I got the error I posted above. Any idea about that?

I'll try again, because it looks like the test needs debugging.

kpamnany avatar Jun 17 '25 11:06 kpamnany

No, when I tried, I got the error I posted above. Any idea about that?

Do you have any JULIA_* environment variables defined in your environment? And what platform are you testing on?

DilumAluthge avatar Jun 17 '25 13:06 DilumAluthge

I was running on Mac. Moved to Linux and was able to test. 🤷‍♂️

The Windows failures are because of path munging:

occursin("LOAD_PATH = [\"C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\jl_CXxD8T", "...]\nLOAD_PATH = [\"C:\\\\Users\\\\RUNNER~1\\\\AppData\\\\Local\\\\Temp\\\\jl_CXxD8T\",...")

Any pointers to how to normalize paths with the correct number of escapes? Someone must have already written code to do this, right?

kpamnany avatar Jun 19 '25 17:06 kpamnany

Okay, figured that one out -- the answer is escape_string.

Now what's broken is that julia_init is actually gone from Julia 1.12 -- removed by https://github.com/JuliaLang/julia/pull/58231. I think it needs to be replaced here by something like:

    jl_resolve_sysimg_location(JL_IMAGE_CWD, NULL);
    jl_image_buf_t sysimage = jl_preload_sysimg(jl_options.image_file);

    jl_init_(sysimage);

But I'm not really sure. Ideally, there should be a separate PR to get PackageCompiler.jl to work with 1.12. @DilumAluthge: any suggestions on who could help with this? Also cc: @gbaraldi who removed julia_init.

kpamnany avatar Jun 25 '25 13:06 kpamnany

Yeah let's see if Gabriel knows how to fix it.

DilumAluthge avatar Jun 25 '25 13:06 DilumAluthge

Bump. Paging @gbaraldi!

kpamnany avatar Jul 31 '25 18:07 kpamnany

See #1047 for the Julia init adaptation.

visr avatar Jul 31 '25 18:07 visr

I cherry-picked the relevant commit (thanks @visr) but still failures on nightly. E.g. from here:

fatal: error thrown and no exception handler available.
Core.InitError(mod=:Curl, error=ErrorException("could not load library \"/tmp/jl_ZGNyky/MyAppCompiled/bin/../lib/julia/libcrypto.so.3\"\n/tmp/jl_ZGNyky/MyAppCompiled/bin/../lib/julia/libcrypto.so.3: cannot open shared object file: No such file or directory"))

There's also this error:

/home/runner/work/PackageCompiler.jl/PackageCompiler.jl/src/julia_init.c: In function ‘init_julia’:
/home/runner/work/PackageCompiler.jl/PackageCompiler.jl/src/julia_init.c:100:5: error: implicit declaration of function ‘jl_init_’; did you mean ‘jl_init’? [-Werror=implicit-function-declaration]
  100 |     jl_init_(sysimage);
      |     ^~~~~~~~
      |     jl_init

So, still can't proceed here. :-(

kpamnany avatar Aug 01 '25 18:08 kpamnany

Oh that function is in the private julia-internal.h header

gbaraldi avatar Aug 04 '25 14:08 gbaraldi

Is the prototype for jl_init_ being moved out of julia_internal.h or is some other solution planned for 1.12?

kpamnany avatar Aug 13 '25 18:08 kpamnany

We actually want to use jl_init_with_image_file(NULL, sysimage_path); instead

gbaraldi avatar Aug 14 '25 14:08 gbaraldi

Remaining errors look unrelated to this PR and identical to the errors on master. Can you take a look and maybe merge this please @KristofferC?

kpamnany avatar Oct 09 '25 12:10 kpamnany