From 07796ccb578e44b8545133bb7dc2a73537d94c59 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sat, 5 Aug 2017 15:20:13 +0200 Subject: [PATCH] libgcrypt: fix clang build Fixes #27906 Because #pragma GCC optimize ("O0") doesn't work for clang and NIX_CFLAGS_COMPILE bypasses the fixup done by the makefiles everything gets compiled with -O2. The build still uses optimisation for everything else. --- pkgs/development/libraries/libgcrypt/default.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/libgcrypt/default.nix b/pkgs/development/libraries/libgcrypt/default.nix index ed742bee8741..5bcb8c5fe98a 100644 --- a/pkgs/development/libraries/libgcrypt/default.nix +++ b/pkgs/development/libraries/libgcrypt/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, libgpgerror, enableCapabilities ? false, libcap }: +{ stdenv, fetchurl, libgpgerror, enableCapabilities ? false, libcap }: assert enableCapabilities -> stdenv.isLinux; @@ -14,9 +14,13 @@ stdenv.mkDerivation rec { outputs = [ "out" "dev" "info" ]; outputBin = "dev"; - buildInputs = - [ libgpgerror ] - ++ lib.optional enableCapabilities libcap; + # The CPU Jitter random number generator must not be compiled with + # optimizations and the optimize -O0 pragma only works for gcc. + # The build enables -O2 by default for everything else. + hardeningDisable = stdenv.lib.optional stdenv.cc.isClang "fortify"; + + buildInputs = [ libgpgerror ] + ++ stdenv.lib.optional enableCapabilities libcap; # Make sure libraries are correct for .pc and .la files # Also make sure includes are fixed for callers who don't use libgpgcrypt-config