Make the library path of libpq available in ruby and add it to the DLL search paths on Windows which lacks rpath.#373
Merged
Conversation
... and add it to the search paths on Windows which lacks rpath. In ELF based systems the libpq path is stored as rpath in pg_ext.so, so that libpq is found, even if it's not in the library search paths. On Windows however the rpath mechanism doesn't work and the search path for libpq must be added manually. This is done per RubyInstaller::Runtime.add_dll_directory. The libpq path is available in extconf.rb while build only (while gem install), so that we have to pass the string to lib/pg.rb where pg_ext.so is loaded (while require 'pg'). This is a bit tricky, since pg_ext.so is linked to libpq, so that the library search path has to be set first, prior to loading pg_ext.so. Therefore a second file is needed bypassing pg_ext.so. That is postgresql_lib_path.rb and it is passed by mkmf's $INSTALLFILES mechanism. There's an issue with rake-compiler, which (in contrast to gem install) doesn't copy postgresql_lib_path.rb. This has to be addressed separatelly. Another approach would be to add a second extension file, but that is more complicated. Fixes ged#365
With this patch rake-compiler executes not just "make" but also "make install" the same way as "gem install" does. That way postgresql_lib_path.rb is copied into the lib folder as expected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In ELF based systems the libpq path is stored as rpath in
pg_ext.so, so that libpq is found, even if it's not in the library search paths.On Windows however the rpath mechanism doesn't work and the search path for libpq had to be set added manually per
RUBY_DLL_PATH. This is now automatically done perRubyInstaller::Runtime.add_dll_directory.The libpq path is available in
extconf.rbwhile build only (while gem install), so that we have to pass the string to lib/pg.rb where pg_ext.so is loaded (whilerequire 'pg'). This is a bit tricky, sincepg_ext.sois linked to libpq, so that the library search path has to be set first, prior to loadingpg_ext.so.Therefore a second file is needed bypassing
pg_ext.so. That ispostgresql_lib_path.rband it is passed by mkmf's$INSTALLFILESmechanism.There's an issue with rake-compiler, which (in contrast to gem install) doesn't copy
postgresql_lib_path.rb.This is addressed in the second commit. Another approach would be to add a second extension file, but that is more complicated.
Fixes #365