Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phps: Fix build with GCC 14 #393

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions pkgs/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,32 @@
assert builtins.all (line: lineAssertion line string) lines;

lib.foldl removeLine string lines;

/*
Produces a modified `env` from an old `attrs` and a attrset of list of env var values.

The lists will be concatenated with spaces.

Type: mergeEnv :: drvAttrs -> attrSet<envName, array<string>> -> attrSet<envName, string>
*/
mergeEnv =
attrs: extraEnvs:

let
oldEnv = attrs.env or { };

appendEnvVar =
name: value:
let
oldVal = oldEnv.${name} or "";
sep = lib.optionalString (oldVal != "") " ";
stringifiedNewVals = lib.concatStringsSep " " value;
in
"${oldVal}${sep}${stringifiedNewVals}";

applicableExtraEnvs = lib.filterAttrs (_name: value: value != [ ]) extraEnvs;

extraEnvsConcatenated = lib.mapAttrs appendEnvVar applicableExtraEnvs;
in
oldEnv // extraEnvsConcatenated;
}
29 changes: 19 additions & 10 deletions pkgs/package-overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let

inherit (pkgs) lib;

inherit (import ./lib.nix { inherit lib; }) removeLines;
inherit (import ./lib.nix { inherit lib; }) mergeEnv removeLines;
in

{
Expand Down Expand Up @@ -202,9 +202,12 @@ in
''
)
];
}
// lib.optionalAttrs (lib.versionOlder prev.php.version "7.1" && pkgs.stdenv.cc.isClang) {
NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + " -Wno-incompatible-function-pointer-types";

env = mergeEnv attrs {
NIX_CFLAGS_COMPILE = lib.optionals (lib.versionOlder prev.php.version "7.1") [
"-Wno-incompatible-function-pointer-types"
];
};
}
);

Expand Down Expand Up @@ -399,9 +402,12 @@ in
];
in
ourPatches ++ upstreamPatches;
}
// lib.optionalAttrs (lib.versionOlder prev.php.version "7.1" && pkgs.stdenv.cc.isClang) {
NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + " -Wno-register";

env = mergeEnv attrs {
NIX_CFLAGS_COMPILE = lib.optionals (lib.versionOlder prev.php.version "7.1" && pkgs.stdenv.cc.isClang) [
"-Wno-register"
];
};
}
);

Expand Down Expand Up @@ -1018,9 +1024,12 @@ in
++ lib.optionals (lib.versionOlder prev.php.version "7.4") [
"--with-zlib-dir=${pkgs.zlib.dev}"
];
}
// lib.optionalAttrs (lib.versionOlder prev.php.version "7.0" && pkgs.stdenv.cc.isClang) {
NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + " -Wno-incompatible-function-pointer-types";

env = mergeEnv attrs {
NIX_CFLAGS_COMPILE = lib.optionals (lib.versionOlder prev.php.version "7.0" && pkgs.stdenv.cc.isClang) [
"-Wno-incompatible-function-pointer-types"
];
};
}
);
};
Expand Down
31 changes: 21 additions & 10 deletions pkgs/phps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let

inherit (prev) lib;

inherit (import ./lib.nix { inherit lib; }) mergeEnv;

_mkArgs =
args:

Expand Down Expand Up @@ -95,16 +97,25 @@ let
done
''
+ attrs.preConfigure;
}
// lib.optionalAttrs (prev.stdenv.cc.isClang) {
# Downgrade the following errors to warnings. `-Wint-conversion` only affects PHP 7.3.
NIX_CFLAGS_COMPILE =
(attrs.NIX_CFLAGS_COMPILE or "")
+ lib.optionalString (lib.versionOlder args.version "8.2") " -Wno-compare-distinct-pointer-types -Wno-implicit-const-int-float-conversion -Wno-deprecated-declarations -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types-discards-qualifiers"
+ lib.optionalString (lib.versionOlder args.version "8.0") " -Wno-implicit-int -Wno-implicit-function-declaration"
+ lib.optionalString (
lib.versionAtLeast args.version "7.3" && lib.versionOlder args.version "7.4"
) " -Wno-int-conversion";

env = mergeEnv attrs {
NIX_CFLAGS_COMPILE =
# Downgrade the following errors to warnings.
lib.optionals (lib.versionOlder args.version "8.2") [
"-Wno-compare-distinct-pointer-types"
"-Wno-implicit-const-int-float-conversion"
"-Wno-deprecated-declarations"
"-Wno-incompatible-function-pointer-types"
"-Wno-incompatible-pointer-types-discards-qualifiers"
]
++ lib.optionals (lib.versionOlder args.version "8.0") [
"-Wno-implicit-int"
"-Wno-implicit-function-declaration"
]
++ lib.optionals (lib.versionAtLeast args.version "7.3" && lib.versionOlder args.version "7.4") [
"-Wno-int-conversion"
];
};
};

# For passing libxml2 and pcre2 to php-packages.nix.
Expand Down
Loading