glibc: expose enableCET as overridable argument, default "permissive"

this should be a gentler way to introduce CET-compiled
binaries into general usage
This commit is contained in:
Robert Scott
2024-03-24 13:43:27 +00:00
parent 9d21bcb0df
commit da25f95bf4
2 changed files with 6 additions and 4 deletions
+4 -3
View File
@@ -36,6 +36,7 @@
, withLinuxHeaders ? false
, profilingLibraries ? false
, withGd ? false
, enableCET ? false
, extraBuildInputs ? []
, extraNativeBuildInputs ? []
, ...
@@ -154,9 +155,9 @@ stdenv.mkDerivation ({
# and on aarch64 with binutils 2.30 or later.
# https://sourceware.org/glibc/wiki/PortStatus
"--enable-static-pie"
] ++ lib.optionals stdenv.hostPlatform.isx86_64 [
] ++ lib.optionals (enableCET != false) [
# Enable Intel Control-flow Enforcement Technology (CET) support
"--enable-cet"
"--enable-cet${if builtins.isString enableCET then "=${enableCET}" else ""}"
] ++ lib.optionals withLinuxHeaders [
"--enable-kernel=3.10.0" # RHEL 7 and derivatives, seems oldest still supported kernel
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
@@ -208,7 +209,7 @@ stdenv.mkDerivation ({
passthru = { inherit version; minorRelease = version; };
}
// (removeAttrs args [ "withLinuxHeaders" "withGd" "postInstall" "makeFlags" ]) //
// (removeAttrs args [ "withLinuxHeaders" "withGd" "enableCET" "postInstall" "makeFlags" ]) //
{
src = fetchurl {
+2 -1
View File
@@ -2,6 +2,7 @@
, withLinuxHeaders ? true
, profilingLibraries ? false
, withGd ? false
, enableCET ? if stdenv.hostPlatform.isx86_64 then "permissive" else false
, pkgsBuildBuild
, libgcc
}:
@@ -15,7 +16,7 @@ let
in
(callPackage ./common.nix { inherit stdenv; } {
inherit withLinuxHeaders withGd profilingLibraries;
inherit withLinuxHeaders withGd profilingLibraries enableCET;
pname = "glibc" + lib.optionalString withGd "-gd" + lib.optionalString (stdenv.cc.isGNU && libgcc==null) "-nolibgcc";
}).overrideAttrs(previousAttrs: {