[Nix-dev] CPU optimized packages

Danny Wilson danny at prime.vc
Thu Feb 7 16:02:11 CET 2013


Well in this case I am the user. And I don't want to fill this in for 
every different server I might have.

My suggestion was to make -march=native pure, by expanding it on the 
system configuring itself at nix expression evaluation time:

$ echo "" | gcc -O3 -march=native -mtune=native -v -E - 2>&1 |grep cc1 
|sed -r 's/.*? - -(.*)$/-\1/'
-march=corei7 -mcx16 -msahf -mno-movbe -maes -mno-pclmul -mpopcnt 
-mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx 
-msse4.2 -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 
--param l2-cache-size=4096 -mtune=generic -O3


So if I'd say:

nixpkgs.config.servers.http.nginx.optimize_cflags = true;

The server building the package would run above command and add these to 
CFLAGS, which in turn become part of the hash.

> Shea Levy <mailto:shea at shealevy.com>
> 7 februari 2013 15:33
> Hi Danny,
>
> Unfortunately, there's not a good answer to this because -march=native 
> is inherently impure. Is there any reason you can't tell users "Find 
> out what -march=native means on your system and then fill in 
> nixpkgs.config.extra_cflags with the result?" or some such (Note that 
> config.extra_cflags doesn't currently exist AFAIK, but could)?
>
> ~Shea
>
> On 02/07/2013 07:36 AM, Danny Wilson wrote:
>
> Danny Wilson <mailto:danny at prime.vc>
> 7 februari 2013 13:36
> With help of the gentoo wiki ( 
> http://en.gentoo-wiki.com/wiki/Hardware_CFLAGS )
> I found this produces a nice GCC option list:
>
> echo "" | gcc -O3 -march=native -mtune=native -v -E - 2>&1 |grep cc1 
> |sed -r 's/.*? - -(.*)$/-\1/'
>
>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
> Danny Wilson <mailto:danny at prime.vc>
> 7 februari 2013 12:37
> I'd like some packages to be optimized for my server CPU. GCC has
> -march=native for this, but that would not generate a cpu specific nixos
> hash.
>
> Is there a nix expression available which adds something like this:
> gcc -march=native -Q --help=target |grep enabled
>
> to CFLAGS and correctly hashing it?
>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
> ------------------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20130207/be6567a1/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1178 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20130207/be6567a1/attachment.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20130207/be6567a1/attachment-0001.jpg 


More information about the nix-dev mailing list