Using Clang instead of GCC: Difference between revisions
imported>Milahu add link to C#Use_a_different_compiler_version |
imported>Artturin Undoing a edit because it's not exactly true and is because of a bug, linked the issue |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 10: | Line 10: | ||
Depending on the case you may want to set this value in different location, and using different mechanism. | Depending on the case you may want to set this value in different location, and using different mechanism. | ||
Note you may get errors like <code>fatal error: ... file not found</code> on standard library <code>#include</code> directives, because of this bug https://github.com/NixOS/nixpkgs/issues/150655 | |||
== Globally, in a package repository tree == | == Globally, in a package repository tree == | ||
Line 16: | Line 17: | ||
If you have a set of packages in a repository tree, you can set the | If you have a set of packages in a repository tree, you can set the | ||
<code>stdenv</code> value in the scope where the <code>callPackage</code> are | <code>stdenv</code> value in the scope where the <code>callPackage</code> are | ||
called. Be carefull '''all the packages present in the scope will be built with Clang''' | called. Be carefull '''all the packages present in the scope will be built with Clang''' | ||
because the <code>callPackage</code> that resolves the package function | because the <code>callPackage</code> that resolves the package function | ||
inputs will use the <code>pkgs.clangStdenv</code> for all packages. | inputs will use the <code>pkgs.clangStdenv</code> for all packages. | ||
Line 27: | Line 28: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
or import nixpkgs with replaceStdenv. | |||
<syntaxhighlight lang="nix"> | |||
import <nixpkgs> { config = { replaceStdenv = ({ pkgs }: pkgs.clangStdenv); }; } | |||
</syntaxhighlight> | |||
== For a specific package in a repository tree == | == For a specific package in a repository tree == |