← Back to issue list

Snapcraft messes with include path precedence in unhealthy ways

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1548232
Type
issue
State
closed
Author
~removed2831044
Labels
—
Created
Updated
Closed

Current evaluation

Include-path precedence was corrected by pkg-config work in canonical/snapcraft#429 (commit a117bd273), with a regression test added.

Resolution: closed resolved

Reason: The maintainer closed the report after confirming that pkg-config work had already fixed it in merged canonical/snapcraft#429, commit a117bd273. A test was added to guard against recurrence.

Evaluated by: mr-cal-bot

No scores available.

Issue body

When building LibreOffice on Snapcraft (both 1.0.2/wily and 2.2.2/xenial) additional include paths are injected into the environment by setting CFLAGS environment. This works for the trivial case to find a unique header that is just at a different location. However, headers do not have unique names, the order of include header locations is relevant. In case of LibreOffice, this causes the compiler to pick up the nss.h header from glibc instead of the nss.h header from Mozillas Network Security Services resulting in a compile time error. Currently, I am working around this by completely overriding the rules for the breaking compilation units with a hardcoded rule that orders the include paths properly, but which in its current form would be quite a maintainability burden. Beyond the concrete problem (nss.h for some LibreOffice compilation units), please note that in this case we are lucky that the fumbled include path precedence results in a compile time error. Its easy to see that there might be other, apparently more trivial headers (e.g. something declaring some common typedefs for integer types) that _compile_ just fine when picking up the wrong header, but fail in subtle and nasty ways at runtime.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Include-path precedence was corrected by pkg-config work in canonical/snapcraft#429 (commit a117bd273), with a regression test added.
stealth/space-bunny-alpha — closed resolved Include-path precedence bug from CFLAGS/pkg-config injection was already fixed by the pkg-config work in merged PR canonical/snapcraft#429 (commit a117bd273); maintainer closed the report, citing that PR and adding a regression test.
stealth/space-bunny-alpha — closed stale Closed without a documented fix or linked PR; Snapcraft's CFLAGS include-path precedence problem was not shown to be resolved.
qwen/qwen3.6-35b-a3b — — Abandoned. Snapcraft's CFLAGS injection overrides header include path precedence, causing compiler errors such as selecting glibc's nss.h over Mozilla's. The author implemented a local workaround, but the issue was closed without upstream resolution.
qwen/qwen3.6-35b-a3b — — Abandoned and closed without resolution. Snapcraft's CFLAGS injection alters include path precedence, causing header conflicts that break builds like LibreOffice. No fix was implemented.

Update history

Date Change
created

Related work

  • Likely Fixed By: canonical/snapcraft#429 (confidence 99%)

    Merged pkg-config changes corrected compiler include ordering and added regression coverage.

Related issues

Issue Project State Summary Similarity
#1558965 Snap building fails due to missing include directory snapcraft (launchpad) closed Fixed by merged PR snapcraft#397: configured include and library paths are now ensured to exist before use.
75%
#1604472 snapcraft changing pkgconfig .pc prefix is creating conflicts between parts snapcraft (launchpad) closed Resolved conflicting pkg-config prefix rewriting through snapcore/snapcraft PR #676, which a maintainer linked as the issue's resolution.
74%
#1670100 Snapcraft includes files from installed snaps in new snap snapcraft (launchpad) closed Fixed by excluding /snap/ paths from crawled dependencies in snapcore/snapcraft PR #1231 (commit 0e9b5a84e).
73%
#5158 Snapcraft doesn't honor ${pcfiledir} in pkgconfig files snapcraft closed Fixed ${pcfiledir} handling via snapcraft#5157 (0a7f753ac) for Core20/Core22 and craft-parts#977 (b4a09d95) for Core24+.
72%