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:
-
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.
-
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.
-
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:
-
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.
-
Search for the package in https://repology.org/projects/, and check how other distributions such as arch, debian, gentoo, and alpine patch these packages.
-
It's better if you can fix it yourself, but don't forget to submit patches upstream if possible.
-
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.
-
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.
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:
GCC 15 updates the default C version from
gnu17tognu23, 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.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.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:
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.Search for the package in https://repology.org/projects/, and check how other distributions such as arch, debian, gentoo, and alpine patch these packages.
It's better if you can fix it yourself, but don't forget to submit patches upstream if possible.
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_COMPILEmay 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 usesedto add headers temporarily, for example,sed -e '1i #include <cstdint>' -i db/blob/blob_file_meta.h.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.