[Nix-dev] NIX_ENFORCE_NO_NATIVE

Andreas Herrmann andreash87 at gmx.ch
Wed Jun 8 16:14:25 CEST 2016


Hi everyone,

I'm using Nix to manage some of my numerics applications. I am compiling the programs specifically on and for a certain platform and am using GCC's `-march=native` flag so that the compiler can apply all the platform specific optimizations it knows. (SSE, AVX, etc.)

I noticed that this doesn't really work as expected, anymore. Many of the platform features are not detected automatically. While digging through nixpkgs I found that there is an environment variable `NIX_ENFORCE_NO_NATIVE` that defaults to `1` which means that the `-march=native` flag is going to be ignored. The reasoning is to prevent impurity. This flag was introduced this march [1].

Now, I understand that this is important for packages that are compiled on Hydra for the binary cache. But, I think it's not a good thing for GCC to quietly ignore the `-march=native` flag. Especially, when being run outside of a nix-builder.

Maybe a warning would be appropriate in that case, or even in general? After all, people usually have a good reason to set `-march=native`. In those cases performance tends to be important.

Best, Andreas

[1]: https://github.com/NixOS/nixpkgs/commit/0c6db0ca48612f18e5c2b744dfa385ba8eecc950



More information about the nix-dev mailing list