Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link helper libraries statically #1182

Closed
jougs opened this issue Apr 17, 2019 · 10 comments · Fixed by #2655
Closed

Link helper libraries statically #1182

jougs opened this issue Apr 17, 2019 · 10 comments · Fixed by #2655
Assignees
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority stale Automatic marker for inactivity, please have another look here T: Enhancement New functionality, model or documentation

Comments

@jougs
Copy link
Contributor

jougs commented Apr 17, 2019

The NEST source code is split into several directories (conngen, libnestutil, librandom, models, nestkernel, precise, sli, topology), each built into a dynamic helper library. The nest executable (residing in the nest subdirectory) comes into existence by a bit of glue code and dynamically linking all of the helper libraries.

This issue demands that the setup is changed so that the nest executable is statically linking its helper libraries, while still allowing to link all external libraries dynamically.

@gtrensch and @heplesser might have additional ideas and thoughts on this.

@jougs jougs added T: Enhancement New functionality, model or documentation ZC: Kernel DO NOT USE THIS LABEL ZP: Pending DO NOT USE THIS LABEL S: Normal Handle this with default priority I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Apr 17, 2019
@jougs jougs self-assigned this Apr 17, 2019
@Silmathoron
Copy link
Member

Out of curiosity, what is the advantage of linking statically compared to the current dynamical linking?

@jougs
Copy link
Contributor Author

jougs commented Apr 17, 2019

The main advantage is that static linking eliminates dynamic linking as a possible problem source ;-)

An example would be an issue we are currently seeing on JURON, where the system scheduler (LSF) also installs a library called libtopology.so. Due to the specific setup of the library search paths on the system, that is found before NEST's library with the same name and a pethora of undefined references is thrown at the user. Debugging this took one of us almost a full day and it would be nicer to avoid such problems altogether.

@ikitayama
Copy link

ikitayama commented Apr 17, 2019 via email

@Silmathoron
Copy link
Member

Ok, thanks!

@AndiH
Copy link

AndiH commented May 6, 2019

I want to note somewhere how we solved the issue for JURON, which @jougs referred to in a previous reply.

As @jougs said, the issue arises due to LSF coming with its own liptopology.so.

CMake builds the Nest executable using RUNPATH to locate Nest's libtology.so and use the symbols defined in there. RUNPATH is searched after LD_LIBRARY_PATH. And here lies the issue: JURON's LSF installation is taught to the environment via an environment module, appending LD_LIBRARY_PATH by the LSF location. When now Nest searches for libtology.so, it will first look for the file in all locations of LD_LIBRARY_PATH, and only then consider the paths defined in its RUNPATH. This fails, as the Nest executable finds LSF's libtopology.so.

A possible fix is to convert RUNPATH into RPATH as RPATH is searched before LD_LIBRARY_PATH and not after (like RUNPATH) is.

I converted RUNPATH to RPATH with this little snippet I found on a Github Gist, but there are probably more suitable solutions out there.

@heplesser heplesser removed ZC: Kernel DO NOT USE THIS LABEL ZP: Pending DO NOT USE THIS LABEL labels Apr 7, 2020
@heplesser heplesser added this to the NEST 3.2 milestone Jun 30, 2021
@github-actions
Copy link

github-actions bot commented Sep 3, 2021

Issue automatically marked stale!

@github-actions github-actions bot added the stale Automatic marker for inactivity, please have another look here label Sep 3, 2021
@terhorstd
Copy link
Contributor

Is this related to #1630? Should this be handled consistently?

@jougs jougs removed the stale Automatic marker for inactivity, please have another look here label Nov 22, 2021
@jougs
Copy link
Contributor Author

jougs commented Nov 22, 2021

@terhorstd: No, it's not. This one is purely about the internal helper libraries that are linked together to form the nest and sli executables and the pynestkernel.so.

As I'm anyway here, I might as well give a quick update on the status:

@stinebuu stinebuu modified the milestones: NEST 3.2, NEST 3.3 Dec 6, 2021
@jougs
Copy link
Contributor Author

jougs commented Feb 21, 2022

It would be good to investigate, if it makes sense to change the default so that static linking becomes the default for all modules and enable dynamic linking only on demand.

Also see #1717.

@clinssen clinssen removed this from the NEST 3.3 milestone Mar 7, 2022
@github-actions
Copy link

github-actions bot commented Dec 6, 2022

Issue automatically marked stale!

@github-actions github-actions bot added the stale Automatic marker for inactivity, please have another look here label Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority stale Automatic marker for inactivity, please have another look here T: Enhancement New functionality, model or documentation
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

8 participants