Skip to content

Conversation

@esabouraud
Copy link

This PR ensures that libpq.so is loaded at run time from the same directory as the one used at compile time.
The goal is to remove ambiguity at run time on systems where multiple versions of the PostgreSQL client are installed. Of course this is however less flexible because multiple versions of pgqd have to be built against different versions of libpq, but this protects against unforeseen API/ABI breakages.

Before:

# readelf -d pgqd

Dynamic section at offset 0xddf0 contains 26 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libpq.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libevent-2.1.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 ...

After (built on RHEL8, linking against PostgreSQL 13):

# readelf -d pgqd

Dynamic section at offset 0xdde0 contains 27 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libpq.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libevent-2.1.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000f (RPATH)              Library rpath: [/usr/pgsql-13/lib]
 ...

This ensures that libpq is loaded at run time from the same directory as the one used at compile time. This removes ambiguity at run time on systems where multiple versions of the PostgreSQL client are installed.
Of course this is however less flexible because multiple versions of pgqd have to be built against different versions of libpq, but this protects against unforeseen API/ABI breakages.
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