/usr prefix unconditionally placed above any other prefix #250

Closed
opened 2023-09-26 14:04:36 +00:00 by vishwin · 3 comments

Sometime after the 1.8 series, the logic changed to unconditionally prefer libraries in /usr over any other prefix. At least on FreeBSD, we have the base system (/usr et al) and ${LOCALBASE} (usually /usr/local but can be any prefix hierarchy not dissimilar to /opt). Especially in a package building scenario, we want to prioritise ${LOCALBASE} over the base system.

The biggest trigger for us is allowing users to pick their OpenSSL provider, whether OpenSSL from the base system or OpenSSL/LibreSSL from ports (which gets installed into ${LOCALBASE}). The base system OpenSSL is always present in the environment regardless. With the current pkgconf, even if a user selects a provider from ports, the base OpenSSL is unconditionally detected and used leading to miscompiles and mislinks, particularly when OpenSSL was not traditionally detected/used in this way.

Example context from building irssi, with pkgconf 2.0.3:

% pkgconf --list-all
ncurses                        ncursesw - ncurses 6.2 library
libusb-2.0                     libusb-2.0 - Library that abstracts ways to access USB devices (v2.0)
panelw                         panelw - ncurses 6.2 add-on library
libssl                         OpenSSL-libssl - Secure Sockets Layer and cryptography libraries
menu                           menuw - ncurses 6.2 add-on library
ncursesw                       ncursesw - ncurses 6.2 library
zlib                           zlib - zlib compression library
libusb-1.0                     libusb-1.0 - Library that abstracts ways to access USB devices (v1.0)
libcrypto                      OpenSSL-libcrypto - OpenSSL cryptography library
libmagic                       libmagic - Magic number recognition library
openssl                        OpenSSL - Secure Sockets Layer and cryptography libraries and tools
liblzma                        liblzma - General purpose data compression library
formw                          formw - ncurses 6.2 add-on library
tinfow                         tinfow - ncurses 6.2 terminal interface library
form                           formw - ncurses 6.2 add-on library
libusb-0.1                     libusb-0.1 - Library that abstracts ways to access USB devices (v0.1)
tinfo                          tinfow - ncurses 6.2 terminal interface library
panel                          panelw - ncurses 6.2 add-on library
menuw                          menuw - ncurses 6.2 add-on library
glib-2.0                       GLib - C Utility Library
libpkgconf                     libpkgconf - a library for accessing and manipulating development framework configuration
icu-i18n                       icu-i18n - International Components for Unicode: Internationalization library
libffi                         libffi - Library supporting Foreign Function Interfaces
irssi-1                        Irssi - Irssi chat client
libpcre2-32                    libpcre2-32 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support
icu-uc                         icu-uc - International Components for Unicode: Common and Data libraries
history                        History - Gnu History library for managing previously-entered lines
gio-2.0                        GIO - glib I/O library
gthread-2.0                    GThread - Thread support for GLib
libxml-2.0                     libXML - libXML library version2.
libssl                         LibreSSL-libssl - Secure Sockets Layer and cryptography libraries
python-3.11                    Python - Build a C extension for Python
libpcre2-16                    libpcre2-16 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support
pkg                            pkg - Library to manipulate packages
libpcre2-8                     libpcre2-8 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support
openssl                        LibreSSL - Secure Sockets Layer and cryptography libraries and tools
gobject-2.0                    GObject - GLib Type, Object, Parameter and Signal Library
gio-unix-2.0                   GIO unix specific APIs - unix specific headers for glib I/O library
gmodule-2.0                    GModule - Dynamic module loader for GLib
libpcre2-posix                 libpcre2-posix - Posix compatible interface to libpcre2-8
gmodule-export-2.0             GModule - Dynamic module loader for GLib
gmodule-no-export-2.0          GModule - Dynamic module loader for GLib
libtls                         LibreSSL-libtls - Secure communications using the TLS socket protocol.
icu-io                         icu-io - International Components for Unicode: Stream and I/O Library
python-3.11-embed              Python - Embed Python into an application
readline                       Readline - Gnu Readline library for command line editing
libutf8proc                    libutf8proc - UTF8 processing
libcrypto                      LibreSSL-libcrypto - LibreSSL cryptography library

With pkgconf 1.8.1 this ordering was different and correct:

% pkgconf --list-all
glib-2.0                       GLib - C Utility Library
libpkgconf                     libpkgconf - a library for accessing and manipulating development framework configuration
icu-i18n                       icu-i18n - International Components for Unicode: Internationalization library
libffi                         libffi - Library supporting Foreign Function Interfaces
irssi-1                        Irssi - Irssi chat client
libpcre2-32                    libpcre2-32 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support
icu-uc                         icu-uc - International Components for Unicode: Common and Data libraries
history                        History - Gnu History library for managing previously-entered lines
gio-2.0                        GIO - glib I/O library
gthread-2.0                    GThread - Thread support for GLib
libxml-2.0                     libXML - libXML library version2.
libssl                         LibreSSL-libssl - Secure Sockets Layer and cryptography libraries
python-3.11                    Python - Build a C extension for Python
libpcre2-16                    libpcre2-16 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support
pkg                            pkg - Library to manipulate packages
libpcre2-8                     libpcre2-8 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support
openssl                        LibreSSL - Secure Sockets Layer and cryptography libraries and tools
gobject-2.0                    GObject - GLib Type, Object, Parameter and Signal Library
gio-unix-2.0                   GIO unix specific APIs - unix specific headers for glib I/O library
gmodule-2.0                    GModule - Dynamic module loader for GLib
libpcre2-posix                 libpcre2-posix - Posix compatible interface to libpcre2-8
gmodule-export-2.0             GModule - Dynamic module loader for GLib
gmodule-no-export-2.0          GModule - Dynamic module loader for GLib
libtls                         LibreSSL-libtls - Secure communications using the TLS socket protocol.
icu-io                         icu-io - International Components for Unicode: Stream and I/O Library
python-3.11-embed              Python - Embed Python into an application
readline                       Readline - Gnu Readline library for command line editing
libutf8proc                    libutf8proc - UTF8 processing
libcrypto                      LibreSSL-libcrypto - LibreSSL cryptography library
ncurses                        ncursesw - ncurses 6.2 library
libusb-2.0                     libusb-2.0 - Library that abstracts ways to access USB devices (v2.0)
panelw                         panelw - ncurses 6.2 add-on library
libssl                         OpenSSL-libssl - Secure Sockets Layer and cryptography libraries
menu                           menuw - ncurses 6.2 add-on library
ncursesw                       ncursesw - ncurses 6.2 library
zlib                           zlib - zlib compression library
libusb-1.0                     libusb-1.0 - Library that abstracts ways to access USB devices (v1.0)
libcrypto                      OpenSSL-libcrypto - OpenSSL cryptography library
libmagic                       libmagic - Magic number recognition library
openssl                        OpenSSL - Secure Sockets Layer and cryptography libraries and tools
liblzma                        liblzma - General purpose data compression library
formw                          formw - ncurses 6.2 add-on library
tinfow                         tinfow - ncurses 6.2 terminal interface library
form                           formw - ncurses 6.2 add-on library
libusb-0.1                     libusb-0.1 - Library that abstracts ways to access USB devices (v0.1)
tinfo                          tinfow - ncurses 6.2 terminal interface library
panel                          panelw - ncurses 6.2 add-on library
menuw                          menuw - ncurses 6.2 add-on library
Sometime after the 1.8 series, the logic changed to unconditionally prefer libraries in `/usr` over any other prefix. At least on FreeBSD, we have the base system (`/usr` et al) and `${LOCALBASE}` (usually `/usr/local` but can be any prefix hierarchy not dissimilar to `/opt`). Especially in a package building scenario, we want to prioritise `${LOCALBASE}` over the base system. The biggest trigger for us is allowing users to pick their OpenSSL provider, whether OpenSSL from the base system or OpenSSL/LibreSSL from ports (which gets installed into `${LOCALBASE}`). The base system OpenSSL is always present in the environment regardless. With the current pkgconf, even if a user selects a provider from ports, the base OpenSSL is unconditionally detected and used leading to miscompiles and mislinks, particularly when OpenSSL was not traditionally detected/used in this way. Example context from building irssi, with pkgconf 2.0.3: ``` % pkgconf --list-all ncurses ncursesw - ncurses 6.2 library libusb-2.0 libusb-2.0 - Library that abstracts ways to access USB devices (v2.0) panelw panelw - ncurses 6.2 add-on library libssl OpenSSL-libssl - Secure Sockets Layer and cryptography libraries menu menuw - ncurses 6.2 add-on library ncursesw ncursesw - ncurses 6.2 library zlib zlib - zlib compression library libusb-1.0 libusb-1.0 - Library that abstracts ways to access USB devices (v1.0) libcrypto OpenSSL-libcrypto - OpenSSL cryptography library libmagic libmagic - Magic number recognition library openssl OpenSSL - Secure Sockets Layer and cryptography libraries and tools liblzma liblzma - General purpose data compression library formw formw - ncurses 6.2 add-on library tinfow tinfow - ncurses 6.2 terminal interface library form formw - ncurses 6.2 add-on library libusb-0.1 libusb-0.1 - Library that abstracts ways to access USB devices (v0.1) tinfo tinfow - ncurses 6.2 terminal interface library panel panelw - ncurses 6.2 add-on library menuw menuw - ncurses 6.2 add-on library glib-2.0 GLib - C Utility Library libpkgconf libpkgconf - a library for accessing and manipulating development framework configuration icu-i18n icu-i18n - International Components for Unicode: Internationalization library libffi libffi - Library supporting Foreign Function Interfaces irssi-1 Irssi - Irssi chat client libpcre2-32 libpcre2-32 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support icu-uc icu-uc - International Components for Unicode: Common and Data libraries history History - Gnu History library for managing previously-entered lines gio-2.0 GIO - glib I/O library gthread-2.0 GThread - Thread support for GLib libxml-2.0 libXML - libXML library version2. libssl LibreSSL-libssl - Secure Sockets Layer and cryptography libraries python-3.11 Python - Build a C extension for Python libpcre2-16 libpcre2-16 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support pkg pkg - Library to manipulate packages libpcre2-8 libpcre2-8 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support openssl LibreSSL - Secure Sockets Layer and cryptography libraries and tools gobject-2.0 GObject - GLib Type, Object, Parameter and Signal Library gio-unix-2.0 GIO unix specific APIs - unix specific headers for glib I/O library gmodule-2.0 GModule - Dynamic module loader for GLib libpcre2-posix libpcre2-posix - Posix compatible interface to libpcre2-8 gmodule-export-2.0 GModule - Dynamic module loader for GLib gmodule-no-export-2.0 GModule - Dynamic module loader for GLib libtls LibreSSL-libtls - Secure communications using the TLS socket protocol. icu-io icu-io - International Components for Unicode: Stream and I/O Library python-3.11-embed Python - Embed Python into an application readline Readline - Gnu Readline library for command line editing libutf8proc libutf8proc - UTF8 processing libcrypto LibreSSL-libcrypto - LibreSSL cryptography library ``` With pkgconf 1.8.1 this ordering was different and correct: ``` % pkgconf --list-all glib-2.0 GLib - C Utility Library libpkgconf libpkgconf - a library for accessing and manipulating development framework configuration icu-i18n icu-i18n - International Components for Unicode: Internationalization library libffi libffi - Library supporting Foreign Function Interfaces irssi-1 Irssi - Irssi chat client libpcre2-32 libpcre2-32 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support icu-uc icu-uc - International Components for Unicode: Common and Data libraries history History - Gnu History library for managing previously-entered lines gio-2.0 GIO - glib I/O library gthread-2.0 GThread - Thread support for GLib libxml-2.0 libXML - libXML library version2. libssl LibreSSL-libssl - Secure Sockets Layer and cryptography libraries python-3.11 Python - Build a C extension for Python libpcre2-16 libpcre2-16 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support pkg pkg - Library to manipulate packages libpcre2-8 libpcre2-8 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support openssl LibreSSL - Secure Sockets Layer and cryptography libraries and tools gobject-2.0 GObject - GLib Type, Object, Parameter and Signal Library gio-unix-2.0 GIO unix specific APIs - unix specific headers for glib I/O library gmodule-2.0 GModule - Dynamic module loader for GLib libpcre2-posix libpcre2-posix - Posix compatible interface to libpcre2-8 gmodule-export-2.0 GModule - Dynamic module loader for GLib gmodule-no-export-2.0 GModule - Dynamic module loader for GLib libtls LibreSSL-libtls - Secure communications using the TLS socket protocol. icu-io icu-io - International Components for Unicode: Stream and I/O Library python-3.11-embed Python - Embed Python into an application readline Readline - Gnu Readline library for command line editing libutf8proc libutf8proc - UTF8 processing libcrypto LibreSSL-libcrypto - LibreSSL cryptography library ncurses ncursesw - ncurses 6.2 library libusb-2.0 libusb-2.0 - Library that abstracts ways to access USB devices (v2.0) panelw panelw - ncurses 6.2 add-on library libssl OpenSSL-libssl - Secure Sockets Layer and cryptography libraries menu menuw - ncurses 6.2 add-on library ncursesw ncursesw - ncurses 6.2 library zlib zlib - zlib compression library libusb-1.0 libusb-1.0 - Library that abstracts ways to access USB devices (v1.0) libcrypto OpenSSL-libcrypto - OpenSSL cryptography library libmagic libmagic - Magic number recognition library openssl OpenSSL - Secure Sockets Layer and cryptography libraries and tools liblzma liblzma - General purpose data compression library formw formw - ncurses 6.2 add-on library tinfow tinfow - ncurses 6.2 terminal interface library form formw - ncurses 6.2 add-on library libusb-0.1 libusb-0.1 - Library that abstracts ways to access USB devices (v0.1) tinfo tinfow - ncurses 6.2 terminal interface library panel panelw - ncurses 6.2 add-on library menuw menuw - ncurses 6.2 add-on library ```

Reverting 384ade5 restores the pre-2.0.0 behaviour.

Reverting 384ade5 restores the pre-2.0.0 behaviour.

Sometime after the 1.8 series, the logic changed to unconditionally prefer libraries in /usr over any other prefix. At least on FreeBSD, we have the base system (/usr et al) and {LOCALBASE} (usually /usr/local but can be any prefix hierarchy not dissimilar to /opt). Especially in a package building scenario, we want to prioritise {LOCALBASE} over the base system.

What leads you to this conclusion? Literally nothing has changed in regard to how PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH are evaluated.

If you want /usr/local paths to be preferred over /usr paths, then you must place them first in your --with-pkg-config-path configure argument. It searches in the specified order.

> Sometime after the 1.8 series, the logic changed to unconditionally prefer libraries in /usr over any other prefix. At least on FreeBSD, we have the base system (/usr et al) and ${LOCALBASE} (usually /usr/local but can be any prefix hierarchy not dissimilar to /opt). Especially in a package building scenario, we want to prioritise ${LOCALBASE} over the base system. What leads you to this conclusion? Literally nothing has changed in regard to how PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH are evaluated. If you want /usr/local paths to be preferred over /usr paths, then you must place them first in your `--with-pkg-config-path` configure argument. It searches in the specified order.

PKG_CONFIG_LIBDIR was set to have /usr/libdata/pkgconfig last after all other entries, but was not honoured after 384ade5. Your commit also fixes things, thanks!

`PKG_CONFIG_LIBDIR` was set to have `/usr/libdata/pkgconfig` last after all other entries, but was not honoured after 384ade5. Your commit also fixes things, thanks!
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ariadne/pkgconf#250
There is no content yet.