Skip to content

Fix bundling and rpath docs for library API#109

Open
visr wants to merge 1 commit into
JuliaLang:mainfrom
visr:rpath-docs
Open

Fix bundling and rpath docs for library API#109
visr wants to merge 1 commit into
JuliaLang:mainfrom
visr:rpath-docs

Conversation

@visr
Copy link
Copy Markdown

@visr visr commented Jan 27, 2026

The rpath is only automatically set to at-bundle when using the CLI:

JuliaC.jl/src/JuliaC.jl

Lines 173 to 179 in ed13d9e

if bundle_specified
if bundle_recipe.output_dir === nothing
bundle_recipe.output_dir = abspath(dirname(link_recipe.outname))
end
# Use @bundle magic string for standard bundle layout
link_recipe.rpath = RPATH_BUNDLE
end

For the library API this wouldn't make sense since bundling happens after linking, so at linking time we don't know yet if the user wants to bundle.

This led to some confusion when the libraries had absolute rpaths set to the Julia installation of our build server.

The rpath is only automatically set to at-bundle when using the CLI:

https://github.com/JuliaLang/JuliaC.jl/blob/ed13d9ece8db9bb29cdf5230c76a8f1de11c3ecd/src/JuliaC.jl#L173-L179

For the library API this wouldn't make sense since bundling happens after linking, so at linking time we don't know yet if the user wants to bundle.
@visr visr changed the title Fix bundling and rpath docs for lbrary API Fix bundling and rpath docs for library API Jan 27, 2026
visr added a commit to Deltares/Ribasim that referenced this pull request Jan 27, 2026
Trying #2629 again now that we
are some patch releases further along.
EDIT: the switch to Julia v1.12 is now done with
#2815, I rebased this to only
add the JuliaC switch, which is less urgent.

For JuliaC we use this branch:
JuliaLang/JuliaC.jl#47. That should set the
desired CPU_TARGET, which was the main reason for reverting the previous
attempt.

Status: I can run the TeamCity JuliaC generated binaries locally, so the
CPU_TARGET seems to work. The Linux binaries seem to for some models.
The libribasim.dll file grew from 0.9 to 1.2 GB.

Update: this now works well on Windows. There is a libribasim.dll.a
added to the zip root that we perhaps should remove, but the Windows
build went from 1h40m to 1h8m, and testing the binaries from 20m to 17m
as well so latency doesn't seem increased. I ran the Windows binaries
locally.

The binary wasn't working directly for me on Linux only after fiddling
with the load path, we need to fix that, perhaps in main.rs or with a
JuliaC rpath option or such. EDIT: see
JuliaLang/JuliaC.jl#109

<details><summary>Details, now fixed with rpath=`@bundle`</summary>
<p>

```
visser_mn@v-h7rdp002 ~/bin  $ ribasim/bin/ribasim ~/ribasim-nl/trivial/ribasim.toml 
Failed to load libribasim from "/u/visser_mn/bin/ribasim/bin/../lib/libribasim.so"
Error: DlOpen { desc: "libjulia.so.1.12: cannot open shared object file: No such file or directory" }
visser_mn@v-h7rdp002 ~/bin  $ export LD_LIBRARY_PATH=~/bin/ribasim/lib:$LD_LIBRARY_PATH
visser_mn@v-h7rdp002 ~/bin  $ ribasim/bin/ribasim ~/ribasim-nl/trivial/ribasim.toml 
Failed to load libribasim from "/u/visser_mn/bin/ribasim/bin/../lib/libribasim.so"
Error: DlOpen { desc: "libjulia-internal.so.1.12: cannot open shared object file: No such file or directory" }
visser_mn@v-h7rdp002 ~/bin  $ ldd ~/bin/ribasim/bin/ribasim
	linux-vdso.so.1 (0x00007ffe803d2000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f79b3905000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f79b36ed000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f79b34cd000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f79b30f7000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f79b3b09000)
visser_mn@v-h7rdp002 ~/bin  $ ldd ~/bin/ribasim/lib/libribasim.so 
	linux-vdso.so.1 (0x00007ffc99973000)
	libjulia.so.1.12 => /u/visser_mn/bin/ribasim/lib/libjulia.so.1.12 (0x00007fcc064d7000)
	libjulia-internal.so.1.12 => not found
	libc.so.6 => /lib64/libc.so.6 (0x00007fcbc1277000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fcbc1073000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcbc0e53000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fcc062cd000)
visser_mn@v-h7rdp002 ~/bin  $ export LD_LIBRARY_PATH=~/bin/ribasim/lib:~/bin/ribasim/lib/julia:$LD_LIBRARY_PATH
visser_mn@v-h7rdp002 ~/bin  $ ribasim/bin/ribasim ~/ribasim-nl/trivial/ribasim.toml 
┌ Info: Starting a Ribasim simulation at 2026-01-26T23:16:08.652.
│   toml_path = "/u/visser_mn/ribasim-nl/trivial/ribasim.toml"
│   cli.ribasim_version = "2026.1.0-rc1"
│   starttime = 2020-01-01T00:00:00
│   endtime = 2021-01-01T00:00:00
└   threads = 1
┌ Warning: The following experimental features are enabled: concentration
└ @ Ribasim /opt/teamcityagent/work/ecd2b8f9b25b1609/ribasim/core/src/logging.jl:51
[ Info: Computation time: 503 milliseconds
[ Info: The model finished successfully at 2026-01-26T23:16:14.037.
```

It seems the default of the JuliaC LinkRecipe is the magic string
`@julia`, whereas we need the magic string `@bundle`.
```
$ objdump -p libribasim.so | grep -E 'RPATH|RUNPATH'
  RPATH                /u/svc-teamcity-ansible/.julia/juliaup/julia-1.12.4+0.x64.linux.gnu/lib:/u/svc-teamcity-ansible/.julia/juliaup/julia-1.12.4+0.x64.linux.gnu/lib/julia
```

</p>
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant