-
Notifications
You must be signed in to change notification settings - Fork 150
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
Load SAT libs from dir relative to exe using linker flags #163
base: main
Are you sure you want to change the base?
Conversation
This allows us to remove the LD_LIBRARY_PATH code from the wrapper scripts (step 1 of removing the scripts altogether). On macOS, this requires us to prefix @rpath/ to libraries' install_names. Then on macOS and Linux respectively, we can link with -rpath @executable_path/../../lib/SAT and $ORIGIN/../../lib/SAT respectively. While here, fix up the file naming for the stub libyices on macOS: It was using the Linux shared library names.
For some context, these are the linker mechanisms used on macOS and Linux: https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html This addresses #10. |
Prior to this change, the only place that needs to know the relative path of the wrapper/binary to the BLUESPECDIR is the wrapper script. This change now requires an additional file (src/comp/Makefile) to also be kept in sync with any changes in the directory structure. I'm willing to accept that, but another possibility is: we don't link with the SAT libraries at all when building, but instead have BSC use dlopen. (This also has the advantage that stub libraries are no longer needed, when you don't want to build/ship STP/Yices, because BSC could handle the case when dlopen fails to find the library -- rather than assume it's always being linked and test whether the linked library was a stub.) FYI, I note that Yices is also installing a static archive ( |
Not an additional file, just a different one. The wrapper script no longer knows about lib/SAT.
Cool. If we only use a small number of functions from the shared libraries, that's probably viable. But that doesn't really remove the need for something to know about the relative paths, does it? Now we've just moved it from the Makefile into some bit of Haskell code.
Yes. I've a separate patch in progress to clean that up, but I was waiting for the existing yices change to land first because they conflict. |
I think you misunderstand what I'm talking about. Yes, there is directory structure under BLUESPECDIR which various places need to know about, to find their files. For example, the knowledge that the SAT libraries can be found in Separate from that is how BLUESPECDIR is computed in the first place. Right now, only the wrapper script computes BLUESPECDIR, relative to the location of the wrapper ( I'd prefer if we could limit the computation of BLUESPECDIR to one place. Right now, that's in the wrapper, but it could eventually be done in the bsc/bluetcl executables. In either case, once BLUESPECDIR is known, then the SAT libraries can loaded with
I don't think the number of functions matters. We're already importing every individual function with FFI. |
Ah, I see, you're right, I missed that point. And now that I think it through, if FFI has to do all the magic of wrapping up function pointers returned by |
This allows us to remove the LD_LIBRARY_PATH code from the
wrapper scripts (step 1 of removing the scripts altogether).
On macOS, this requires us to prefix @rpath/ to libraries'
install_names.
Then on macOS and Linux respectively, we can link with
-rpath @executable_path/../../lib/SAT and $ORIGIN/../../lib/SAT
respectively.
While here, fix up the file naming for the stub libyices on macOS:
It was using the Linux shared library names.