Skip to content

Some packages may fail to compile with GCC 15 #475479

Description

@Aleksanaa

With #471587 merged, GCC 15 becomes the default C/C++ compiler on Linux. This brings some breaking changes that may cause some packages to fail to compile:

  1. GCC 15 updates the default C version from gnu17 to gnu23, which brings some syntax breakages. bool, true, false, nullptr, thread_local, etc., are currently reserved keywords, so they can no longer be defined as variable names in the code. The parameters of function declaration must be explicit, and can no longer be empty to indicate that any parameters can be accepted.

  2. Reduced the number of headers in C++ that implicitly include other standard library headers, which would result in the need to add a <cstdint> header in some old code.

  3. Some new compilation warnings have been added, such as -Wrestrict, which generally will not error out, but some projects may turn on -Werror by default.

See https://gcc.gnu.org/gcc-15/porting_to.html for more detailed explanation.

We've tried to fix most of the packages that affect more in staging-next, but some leaf packages may still fail. When you try to fix these packages, you can try the following methods:

  1. Check the upstream repository to see if there is already a fix. If there is, you can pull the corresponding commit with fetchpatch, or update to the latest version if a new version is available.

  2. Search for the package in https://repology.org/projects/, and check how other distributions such as arch, debian, gentoo, and alpine patch these packages.

  3. It's better if you can fix it yourself, but don't forget to submit patches upstream if possible.

  4. If none of these methods are applicable, you can fix by setting env.NIX_CFLAGS_COMPILE = "-std=gnu17" (some projects may require gnu11 or even older) and adding. Note that in mixed C/C++ projects, NIX_CFLAGS_COMPILE may be incorrectly passed to clang's c++ frontend, causing it to fail on macOS (TODO: ask for proper solution). If C++ code lacks headers, you can use sed to add headers temporarily, for example, sed -e '1i #include <cstdint>' -i db/blob/blob_file_meta.h.

  5. For packages that are already unmaintained upstream for a long time, one possible option is to drop them directly instead of fixing them. You can also tell by repology whether other distributions still package them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: build failureA package fails to build3.skill: sprintableA larger issue which is split into distinct actionable tasks5.scope: trackingLong-lived issue tracking long-term fixes or multiple sub-problems

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions