Page MenuHomeFreeBSD

EC2: Add clibs-lib32 pkg to small/builder images
Needs ReviewPublic

Authored by cperciva on Fri, Mar 20, 12:35 AM.

Details

Summary

On amd64 (but not aarch64) the FreeBSD-clang package depends on the
32-bit version of the libgcc_s.so.1 shared library, which is provided
by FreeBSD-clibs-lib32.

For some unknown reason, pkg does not install FreeBSD-clibs-lib32 when
vmimage.subr runs 'pkg ... install <long list of packages>'.

However, the *next* time 'pkg install' runs, it realizes that it needs
the 32-bit libgcc_s.so.1 -- even though that particular library is not
needed by the particular package we're trying to install -- and goes
looking for it... and ends up picking gcc12-devel as a provider.

Later in the EC2 image building process, we run 'pkg autoremove' (which
was added during 15.0 to get rid of "bogus dependencies") and pkg
decides that gcc12-devel is an automatic port which is not depended
upon and removes it... and also removes FreeBSD-clang, since it knows
that it can't keep FreeBSD-clang without keeping the port which is
supplying the 32-bit libgcc_s.so.1 library.

It's not clear if this is one bug in pkg or multiple bugs in pkg, not
is it clear why a 64-bit clang needs a 32-bit libgcc_s.so.1, but for
now adding FreeBSD-clibs-lib32 to the "small" and "builder" flavours of
EC2 images fixes the build.

MFC after: 5 days
Sponsored by: Amazon

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 71562
Build 68445: arc lint + arc unit

Event Timeline

@ivy @bapt @ifreund_freebsdfoundation.org Tagging you here not so much to review the change but in case you have any idea what's going wrong in pkg.

After more investigation: The culprit here is libclang_rt.asan-i386.so which is landing in FreeBSD-clang and creating the dependency on 32-bit libraries.

the described behaviour seems like clearly a bug in pkg. from the pkgbase side, i don't mind this change as a workaround, but i wonder what the correct fix is here; do we want a separate package for 32-bit clang, like clang-lib32? clibs-lib32 is 3MB, which is relatively tiny compared to clang itself, but i think i'd prefer not to have any mandatory dependencies from native packages to compat packages - you should be able to completely ignore compat if you don't want it.

In D55978#1280739, @ivy wrote:

the described behaviour seems like clearly a bug in pkg. from the pkgbase side, i don't mind this change as a workaround, but i wonder what the correct fix is here; do we want a separate package for 32-bit clang, like clang-lib32? clibs-lib32 is 3MB, which is relatively tiny compared to clang itself, but i think i'd prefer not to have any mandatory dependencies from native packages to compat packages - you should be able to completely ignore compat if you don't want it.

There's definitely a bug in pkg resulting in it having trouble making up its mind about whether it needs a package installed to satisfy a demand for a 32-bit libgcc_s.so.1 -- but yes, I do think that pkgbase should put libclang_rt.asan-i386.so into a clang-lib32 package so that it's possible to have an amd64 system without any 32-bit code installed.