mkDerivation, cc-wrapper: Check hardening flag validity in Nix

This becomes necessary if more wrappers besides cc-wrapper start
supporting hardening flags. Also good to make the warning into an
error.

Also ensure interface is being used right: Not as a string, not just in
bash.
This commit is contained in:
John Ericson
2017-08-30 17:53:42 +02:00
committed by Robin Gloster
parent 822a8d0148
commit 97a48835b7
5 changed files with 19 additions and 4 deletions
+13
View File
@@ -41,7 +41,20 @@ rec {
, __propagatedImpureHostDeps ? []
, sandboxProfile ? ""
, propagatedSandboxProfile ? ""
, hardeningEnable ? []
, hardeningDisable ? []
, ... } @ attrs:
# TODO(@Ericson2314): Make this more modular, and not O(n^2).
let allHardeningFlags = [
"fortify" "stackprotector" "pie" "pic" "strictoverflow" "format" "relro"
"bindnow"
];
in assert lib.all
(flag: lib.elem flag allHardeningFlags)
(hardeningEnable ++ hardeningDisable);
let
dependencies = map lib.chooseDevOutputs [
(map (drv: drv.nativeDrv or drv) nativeBuildInputs