Bug 8589

Summary: Bootstrap packages get wrong pkg-config information
Product: ThinLinc Reporter: Pierre Ossman <ossman>
Component: Build systemAssignee: Pierre Ossman <ossman>
Status: CLOSED FIXED    
Severity: Normal CC: adaha, samuel
Priority: P2 Keywords: adaha_tester, prosaic
Version: trunk   
Target Milestone: 4.20.0   
Hardware: PC   
OS: Unknown   
Acceptance Criteria:
Bug Depends on:    
Bug Blocks: 8361, 8591    

Description Pierre Ossman cendio 2025-05-15 08:38:31 CEST
Packages that are built as part of the bootstrapping (before we have a working chroot) will be built incorrectly if they rely on pkg-config. Either failing, or producing the wrong result.


The problem is that the only special setup we do during bootstrapping is to alter $PATH. That means that our gcc and binutils are used instead of the system's.

For programs that test things via the compiler, this is sufficient. But programs that look for dependencies via pkg-config will use the system's pkg-config, and get the wrong results.



E.g., if ncurses-devel is installed on the host, then util-linux will find that and fail:

> /bin/sh ./libtool  --tag=CC   --mode=link i686-pc-linux-gnu-gcc -fsigned-char -fno-common -Wall -Werror=sequence-point -Wextra -Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wno-missing-field-initializers -Wredundant-decls -Wsign-compare -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-parameter -Wunused-result -Wunused-variable -Wnested-externs -Wpointer-arith -Wstrict-prototypes -Wimplicit-function-declaration -O2 -g  -g -o dmesg sys-utils/dmesg-dmesg.o lib/dmesg-monotonic.o  libcommon.la libtcolors.la -lrt 
> libtool: link: i686-pc-linux-gnu-gcc -fsigned-char -fno-common -Wall -Werror=sequence-point -Wextra -Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wno-missing-field-initializers -Wredundant-decls -Wsign-compare -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-parameter -Wunused-result -Wunused-variable -Wnested-externs -Wpointer-arith -Wstrict-prototypes -Wimplicit-function-declaration -O2 -g -g -o dmesg sys-utils/dmesg-dmesg.o lib/dmesg-monotonic.o  ./.libs/libcommon.a ./.libs/libtcolors.a -ltinfo -lrt
> /opt/cendio-build/arch/i386/usr/bootstrap/lib/gcc/i686-pc-linux-gnu/5.5.0/../../../../i686-pc-linux-gnu/bin/ld: cannot find -ltinfo
> collect2: error: ld returned 1 exit status


We need to provide some mechanism to redirect pkg-config to our stuff.
Comment 1 Pierre Ossman cendio 2025-07-03 16:56:58 CEST
Our current approach to cross compiling with pkg-config is to build special variants of pkg-config with other default values. This doesn't fit well with the bootstrapping.

Instead, let's use the wrapper script approach recommended by pkg-config:

https://autotools.info/pkgconfig/cross-compiling.html

This is clean enough that it will work well even during bootstrapping.
Comment 2 Pierre Ossman cendio 2025-07-03 16:58:09 CEST
We need to fix up ncurses for bug 8361. Since that package is part of the current issue here, let's do a general cleanup of our ncurses packaging at the same time.
Comment 14 Pierre Ossman cendio 2025-07-04 09:18:45 CEST
Done. Tested that both cenbuild and ThinLinc fully builds without issue after these changes.
Comment 15 Pierre Ossman cendio 2025-07-04 09:20:25 CEST
Tester should primarily check that pkg-config gives the correct results in:

 * Bootstrapping

 * Cross-compilation in cenbuild

 * Non-cross-compilation in cenbuild
Comment 16 Adam Halim cendio 2025-08-05 11:19:53 CEST
Tested:

> $ PKG_CONFIG_ALLOW_SYSTEM_LIBS="" /opt/cendio-build/arch/x86_64/usr/bootstrap/bin/x86_64-unknown-linux-gnu-pkg-config --libs-only-L zlib
> -L/opt/cendio-build/arch/x86_64/usr/lib64
> $ PKG_CONFIG_ALLOW_SYSTEM_LIBS="" cbrun x86_64 x86_64-unknown-linux-gnu-pkg-config --libs-only-L zlib
> -L/usr/lib64
> $ PKG_CONFIG_ALLOW_SYSTEM_LIBS="" cbrun win64 x86_64-w64-mingw32-pkg-config  --libs-only-L zlib
> -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib
Seems like we get sane results, and builds have been working since the upgrade.

Commits look good, closing.