Repository navigation
configure: ignore library directories of a foreign architecture - #1121
Open
qianeric-backup wants to merge 1 commit into
Open
qianeric-backup wants to merge 1 commit into
qianeric-backup wants to merge 1 commit into
Conversation
/etc/ld.so.conf.d/ lists the native multiarch directory next to a foreign
one on Debian and Ubuntu. A x86_64 host therefore gets both
/usr/lib/x86_64-linux-gnu and /usr/lib/i386-linux-gnu into LIBDIRS.
The module checks match libraries by file name only:
TMP_LIB=`/bin/ls $i/libssl.so* 2> /dev/null | grep ssl`
so a 32-bit libssl.so in the i386 directory satisfies the check in a 64-bit
build. Its directory is then appended to XLIBPATHS and the linker tries every
object in it:
/usr/bin/ld: skipping incompatible /lib/i386-linux-gnu/libgcc_s.so.1
The resulting -L path is not just noise: it points at the wrong library set.
Filter LIBDIRS down to the directories whose objects match the host ELF class
before any module is probed. The check samples the first lib*.so* in a
directory with file(1) and keeps the directory when it does not contradict
SIXFOUR; empty directories and directories without any lib*.so* are kept as
before. When file(1) is not available the filter is skipped entirely and the
old behaviour is preserved.
Directories below --prefix are never filtered. SIXFOUR comes from uname -m,
which reports the build host under a cross compiler, so filtering there could
drop the target libraries the user pointed at explicitly.
On a x86_64 host this turns
XLIBPATHS=-L/usr/lib -L/usr/local/lib -L/lib -L/lib/i386-linux-gnu
into
XLIBPATHS=-L/usr/lib -L/usr/local/lib -L/lib -L/lib/x86_64-linux-gnu
and removes both "skipping incompatible" lines from the build.
qianeric-backup
force-pushed
the
fix/foreign-arch-libdirs
branch
from
November 2, 2026 16:46
62067f9 to
01dbd59
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The library-directory filter can hide native dependencies by inspecting symlinks rather than their targets and rejecting samples whose architecture cannot be determined.
2 open issues
What changed in this PR
This PR adds architecture filtering to configure to prevent foreign library directories from entering Hydra’s dependency search paths. It addresses incompatible-library detection, not the broader pkg-config request in #450.
Changes:
- Samples shared libraries with
fileand filters directories according toSIXFOURbefore module probes. - Skips filtering when
fileis unavailable and exempts directories beneath--prefix.
| File | Description |
|---|---|
configure |
Adds library-directory classification and filtering before dependency detection. |
Review effort: Balanced
| ARCH_LIBDIRS="$ARCH_LIBDIRS $archdir" | ||
| continue | ||
| fi | ||
| archdesc=`file -b "$archsample" 2> /dev/null` |
Comment on lines
+225
to
+233
| if [ "$SIXFOUR" = "64" ]; then | ||
| case "$archdesc" in | ||
| *64-bit*) ARCH_LIBDIRS="$ARCH_LIBDIRS $archdir" ;; | ||
| esac | ||
| else | ||
| case "$archdesc" in | ||
| *32-bit*) ARCH_LIBDIRS="$ARCH_LIBDIRS $archdir" ;; | ||
| esac | ||
| fi |
Owner
|
@qianeric-backup please have a look at the issues copilot found |
This branch has not been deployed
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.

The problem
On Debian and Ubuntu,
/etc/ld.so.conf.d/i386-linux-gnu.conflists the 32-bit multiarchdirectories next to the native ones, and
configurereads all ofld.so.conf.dintoLIBDIRS:LIBDIRS="$LIBDIRS `cat /etc/ld.so.conf /etc/ld.so.conf.d/* 2> /dev/null | ...`"A x86_64 host therefore ends up with both
/usr/lib/x86_64-linux-gnuand/usr/lib/i386-linux-gnuin the search list.The module checks match libraries by file name only:
TMP_LIB=`/bin/ls $i/libssl.so* 2> /dev/null | grep ssl`A 32-bit
libssl.soin the i386 directory satisfies that check in a 64-bit build, its directoryis appended to
XLIBPATHS, and the linker then walks a directory full of objects it cannot use:That is not only noise — the generated
-Lpath points at the wrong library set.The change
Filter
LIBDIRSdown to directories whose objects match the host ELF class, before any module isprobed. Each directory is sampled through the first
lib*.so*it contains; directories without anylibrary, and directories whose sample does not contradict
SIXFOUR, are kept exactly as before.Two guards:
file(1)missing → the whole filter is skipped and behaviour is unchanged.--prefix→ never filtered.SIXFOURis derived fromuname -m, whichreports the build host under a cross compiler, so filtering there could drop the target
libraries the user pointed at explicitly.
Effect
Before (
XLIBPATHSand the two linker warnings):After:
Verified on x86_64 Ubuntu 24.04 with gcc 13.3.0:
./configure && makecompletes with zero"skipping incompatible" lines and a working
./hydra. The filter is architecture-agnostic inprinciple (
SIXFOURpicks the 64-bit or 32-bit expectation), but I only had a 64-bit host to testit on.
Relation to #450
This is adjacent to the pkg-config request in #450 and does not implement it. When looking at that,
I found that
configurealready carries pkg-config logic — but only inside theDarwinbranch, sonon-macOS platforms never use it. I drafted promoting it to all platforms, then dropped that
change: the per-module checks already cover the common layouts (
/usr/*p*sql*/include,$i/libssh/libssh.h, and so on), and I could not demonstrate a real failure it fixes on a normalLinux install. Submitting that without evidence seemed worse than leaving #450 for someone who hits
a concrete non-standard prefix.
This arch filter, by contrast, reproduces on any Debian/Ubuntu x86_64 host.