Skip to content

Commit

Permalink
cc-wrapper: add option to skip flags for native optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
abbradar committed Mar 24, 2016
1 parent 89693e7 commit 0c6db0c
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 21 deletions.
14 changes: 14 additions & 0 deletions pkgs/build-support/cc-wrapper/cc-wrapper.sh
Expand Up @@ -91,6 +91,20 @@ if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then
params=("${rest[@]}")
fi


# Clear march/mtune=native -- they bring impurity.
if [ "$NIX_ENFORCE_NO_NATIVE" = 1 ]; then
rest=()
for i in "${params[@]}"; do
if [[ "$i" = -m*=native ]]; then
skip $i
else
rest=("${rest[@]}" "$i")
fi
done
params=("${rest[@]}")
fi

if [[ "$isCpp" = 1 ]]; then
NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${NIX_CXXSTDLIB_COMPILE-@default_cxx_stdlib_compile@}"
NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK $NIX_CXXSTDLIB_LINK"
Expand Down
14 changes: 14 additions & 0 deletions pkgs/build-support/cc-wrapper/gnat-wrapper.sh
Expand Up @@ -70,6 +70,20 @@ if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then
fi


# Clear march/mtune=native -- they bring impurity.
if [ "$NIX_ENFORCE_NO_NATIVE" = 1 ]; then
rest=()
for i in "${params[@]}"; do
if [[ "$i" = -m*=native ]]; then
skip $i
else
rest=("${rest[@]}" "$i")
fi
done
params=("${rest[@]}")
fi


# Add the flags for the GNAT compiler proper.
extraAfter=($NIX_GNATFLAGS_COMPILE)
extraBefore=()
Expand Down
1 change: 0 additions & 1 deletion pkgs/development/libraries/crypto++/default.nix
Expand Up @@ -25,7 +25,6 @@ stdenv.mkDerivation rec {
''
sed -i GNUmakefile \
-e 's|-march=native|${marchflags} -fPIC|g' \
-e 's|-mtune=native||g' \
-e '/^CXXFLAGS =/s|-g ||'
'';

Expand Down
9 changes: 0 additions & 9 deletions pkgs/misc/emulators/higan/0001-change-flags.diff
Expand Up @@ -11,15 +11,6 @@ diff -rupN higan_v095-source.orig/GNUmakefile higan_v095-source/GNUmakefile
objects := libco

# profile-guided optimization mode
@@ -43,7 +44,7 @@ ifeq ($(platform),windows)
else ifeq ($(platform),macosx)
flags += -march=native
else ifeq ($(platform),linux)
- flags += -march=native -fopenmp
+ flags += -fopenmp
link += -fopenmp
link += -Wl,-export-dynamic
link += -lX11 -lXext -ldl
diff -rupN higan_v095-source.orig/icarus/GNUmakefile higan_v095-source/icarus/GNUmakefile
--- higan_v095-source.orig/icarus/GNUmakefile 2015-11-04 10:28:26.186486119 +0100
+++ higan_v095-source/icarus/GNUmakefile 2015-11-04 10:28:48.755059317 +0100
Expand Down
1 change: 1 addition & 0 deletions pkgs/stdenv/darwin/default.nix
Expand Up @@ -26,6 +26,7 @@ in rec {

commonPreHook = ''
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
export NIX_IGNORE_LD_THROUGH_GCC=1
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
export MACOSX_DEPLOYMENT_TARGET=10.7
Expand Down
1 change: 1 addition & 0 deletions pkgs/stdenv/linux/default.nix
Expand Up @@ -23,6 +23,7 @@ rec {
commonPreHook =
''
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
${if system == "x86_64-linux" then "NIX_LIB64_IN_SELF_RPATH=1" else ""}
${if system == "mips64el-linux" then "NIX_LIB32_IN_SELF_RPATH=1" else ""}
'';
Expand Down
1 change: 1 addition & 0 deletions pkgs/stdenv/native/default.nix
Expand Up @@ -16,6 +16,7 @@ rec {
# Disable purity tests; it's allowed (even needed) to link to
# libraries outside the Nix store (like the C library).
export NIX_ENFORCE_PURITY=
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
'';

prehookFreeBSD = ''
Expand Down
1 change: 1 addition & 0 deletions pkgs/stdenv/nix/default.nix
Expand Up @@ -6,6 +6,7 @@ import ../generic rec {
preHook =
''
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
export NIX_IGNORE_LD_THROUGH_GCC=1
'';

Expand Down
5 changes: 0 additions & 5 deletions pkgs/tools/networking/pingtcp/default.nix
Expand Up @@ -13,11 +13,6 @@ stdenv.mkDerivation rec {

nativeBuildInputs = [ cmake ];

postPatch = ''
substituteInPlace {.,pfcquirks}/CMakeLists.txt \
--replace "-march=native" ""
'';

enableParallelBuilding = true;

doCheck = false;
Expand Down
6 changes: 0 additions & 6 deletions pkgs/tools/security/crackxls/default.nix
Expand Up @@ -13,12 +13,6 @@ stdenv.mkDerivation rec {

buildInputs = [ pkgconfig autoconf automake openssl libgsf gmp ];

patchPhase = ''
substituteInPlace Makefile.in \
--replace '-march=native' "" \
--replace '-mtune=native' ""
'';

installPhase =
''
mkdir -p $out/bin
Expand Down

0 comments on commit 0c6db0c

Please sign in to comment.