New stage-packages requirements after setting base

After switching the ldc2 compiler snap to use base: core, I’ve noticed some warnings showing up in the builds.

For amd64 builds:

The 'ldc' part is missing libraries that are not included in the snap or base. They can be satisfied by adding the following entry for this part
stage-packages:
- lib32gcc1
- libc6-i386

For i386 builds:

The 'ldc' part is missing libraries that are not included in the snap or base. They can be satisfied by adding the following entry for this part
stage-packages:
- lib64gcc1
- libc6-amd64

The reason for this appears to be because the package always includes both 32- and 64-bit versions of the D runtime and standard libraries. The ones whose bitness matches the “host” bitness of the snap always link against the C libs on the core snap. In the pre-base version of the snap package, the same happens for the other bitness, e.g. in the amd64 build of the snap, the 32-bit libs link as follows:

/snap/ldc2/115/lib32$ ldd libdruntime-ldc-shared.so
	linux-gate.so.1 =>  (0xf771e000)
	libm.so.6 => /snap/core/current/lib/i386-linux-gnu/libm.so.6 (0xf757d000)
	libpthread.so.0 => /snap/core/current/lib/i386-linux-gnu/libpthread.so.0 (0xf7560000)
	librt.so.1 => /snap/core/current/lib/i386-linux-gnu/librt.so.1 (0xf7557000)
	libdl.so.2 => /snap/core/current/lib/i386-linux-gnu/libdl.so.2 (0xf7552000)
	libgcc_s.so.1 => /snap/core/current/lib/i386-linux-gnu/libgcc_s.so.1 (0xf7534000)
	libc.so.6 => /snap/core/current/lib/i386-linux-gnu/libc.so.6 (0xf737e000)
	/lib/ld-linux.so.2 (0xf771f000)

However, once base: core is set in snapcraft.yaml, the linking of the non-host-bitness libs changes:

/snap/ldc2/132/lib32$ ldd libdruntime-ldc-shared.so
	linux-gate.so.1 =>  (0xf7748000)
	libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf75be000)
	libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf75a1000)
	librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf7598000)
	libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7593000)
	libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf7575000)
	libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf73bf000)
	/lib/ld-linux.so.2 (0xf7749000)

Something similar happens in the i386 package for the 64-bit libs.

I’m a bit confused as to why, because the core snap contains both lib/i386-linux-gnu (which should provide all the core C libs needed by the 32-bit D libs) and lib/x86_64-linux-gnu (which should provide all the core C libs needed by the 64-bit D libs).

It’s no problem to add stage-packages as indicated (using on amd64 and on i386 to customize per arch), but before doing that I’d like to clarify why this is necessary. What changed when adding the base: core to snapcraft.yaml? Or is this a bug, with snapcraft not recognizing the libs are available in core?

Thanks in advance for any advice and feedback.

1 Like

I suspect this is a snapcraft issue with the dependency search in this multi-arch scenario. I’ll look into it, but if your snap works just fine without those stage packages, feel free to ignore those warnings. :slight_smile:

1 Like

Thanks for the advice and info. I’m not aware of any actual issues in snap behaviour, so I’ll hold off making any changes for now.

Would it help for me to write up an issue report on Launchpad?

@joseph.wakeling Can you share your project?

If not, perhaps you can try and see if you get the same results when using this snapcraft version:
sudo snap refresh snapcraft --channel=edge/pr-2942

1 Like

Sure thing, it’s this one: https://github.com/ldc-developers/ldc2.snap

Published as ldc2 in the snap store: https://snapcraft.io/ldc2

The builds where the stage-packages issue starts showing up are the most recent of this snap package definition on Launchpad: https://code.launchpad.net/~ldc-developers/+snap/ldc2-1.18/

I’ll try and do that later today. Thanks!

Snapcraft only scans for libraries of the build architecture, afaik. When it does the scan to ensure you have included all required libraries it will moan about not finding the foreign architectured libraries. This affects any snap build that is including alien architecture libraries, such as and amd64 build including x86/i386 libraries, or an arm64 build including armhf libraries.

Thanks for the extra feedback. What i don’t get is why ldd shows up the affected built shared libraries as linking against /lib/i386-linux-gnu/... rather than /snap/core/lib/i386-linux-gnu/... given that the i386 libs linked against must also be in the core snap. Unless what I see as the core snap on my system, is different from the core base used in the snapcraft build process?

I just tried this now. The built 32-bit libs in the snap now correctly link against libs in /snap/core/current/lib/i386-linux-gnu/, and snapcraft no longer contains about missing stage-packages.

2 Likes

Thank you for testing that @joseph.wakeling :slight_smile: That fix should be included in 3.11+.

Have a great day!

1 Like

Apologies for the late follow-up here (have been rather distracted from snap maintenance for obvious reasons…), but just to report: I’ve rebuilt some of the affected snaps using the latest snapcraft 4.1.1, and while in amd64 builds all is fine, the i386 builds still show up the missing packages report:

The 'ldc' part is missing libraries that are not included in the snap or base. They can be satisfied by adding the following entry for this part
stage-packages:
- lib64gcc1
- libc6-amd64

Is this to be expected given differences between amd64 and i386 core snaps? (Note I’m still using original core, not core18 or core20.)

That probably indicates that your i386 build contains 64-bit binaries.

Thanks! The 32-bit snap package will contain 64-bit libs, yes (it’s a compiler built for multi-arch support).

So do I understand right that whereas lib32gcc1 and libc6-i386 are already in the amd64 core snap, lib64gcc1 and libc6-amd64 are not in the i386 core? And hence I need to make sure that those libs are staged?