cc-wrapper: externalize default_cxx_stdlib_compile

This value is require to get c++ std include path for libclang based tools (vim plugins in my case).
I currently extract it this with this rather command:

```
eval echo $(nix-instantiate --eval --expr 'with (import <nixpkgs>) {}; clang.default_cxx_stdlib_compile')
```

it did not trigger any recompilation on my system.
This commit is contained in:
Jörg Thalheim 2017-06-08 19:00:40 +01:00
parent 3cb5d52dac
commit e2197465c1
No known key found for this signature in database
GPG Key ID: CA4106B8D7CC79FA
3 changed files with 20 additions and 6 deletions

View File

@ -34,6 +34,9 @@ let
binutils_bin = if nativeTools then "" else getBin binutils; binutils_bin = if nativeTools then "" else getBin binutils;
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils. # The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
coreutils_bin = if nativeTools then "" else getBin coreutils; coreutils_bin = if nativeTools then "" else getBin coreutils;
default_cxx_stdlib_compile=optionalString (stdenv.isLinux && !(cc.isGNU or false))
"-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)";
in in
stdenv.mkDerivation { stdenv.mkDerivation {
@ -46,8 +49,9 @@ stdenv.mkDerivation {
inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin; inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin;
gnugrep_bin = if nativeTools then "" else gnugrep; gnugrep_bin = if nativeTools then "" else gnugrep;
passthru = { passthru = {
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang; inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile;
emacsBufferSetup = pkgs: '' emacsBufferSetup = pkgs: ''
; We should handle propagation here too ; We should handle propagation here too
@ -189,11 +193,7 @@ stdenv.mkDerivation {
export real_cc=cc export real_cc=cc
export real_cxx=c++ export real_cxx=c++
export default_cxx_stdlib_compile="${ export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
if stdenv.isLinux && !(cc.isGNU or false)
then "-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)"
else ""
}"
if [ -e $ccPath/gcc ]; then if [ -e $ccPath/gcc ]; then
wrap gcc ${./cc-wrapper.sh} $ccPath/gcc wrap gcc ${./cc-wrapper.sh} $ccPath/gcc

View File

@ -293,6 +293,13 @@ rec {
sha256 = "19zs03giv8h5xmv18y9zn85sxr8akphvbscclrqhs4cf88285cgl"; sha256 = "19zs03giv8h5xmv18y9zn85sxr8akphvbscclrqhs4cf88285cgl";
}; };
dependencies = []; dependencies = [];
# In addition to the arguments you pass to your compiler, you also need to
# specify the path of the C++ std header (if you are using C++).
# These usually implicitly set by cc-wrapper around clang (pkgs/build-support/cc-wrapper).
# The linked ruby code shows generates the required '.clang_complete' for cmake based projects
# https://gist.github.com/Mic92/135e83803ed29162817fce4098dec144
# as an alternative you can execute the following command:
# $ eval echo $(nix-instantiate --eval --expr 'with (import <nixpkgs>) {}; clang.default_cxx_stdlib_compile')
preFixup = '' preFixup = ''
substituteInPlace "$out"/share/vim-plugins/clang_complete/plugin/clang_complete.vim \ substituteInPlace "$out"/share/vim-plugins/clang_complete/plugin/clang_complete.vim \
--replace "let g:clang_library_path = '' + "''" + ''" "let g:clang_library_path='${llvmPackages.clang.cc}/lib/libclang.so'" --replace "let g:clang_library_path = '' + "''" + ''" "let g:clang_library_path='${llvmPackages.clang.cc}/lib/libclang.so'"

View File

@ -1,3 +1,10 @@
# In addition to the arguments you pass to your compiler, you also need to
# specify the path of the C++ std header (if you are using C++).
# These usually implicitly set by cc-wrapper around clang (pkgs/build-support/cc-wrapper).
# The linked ruby code shows generates the required '.clang_complete' for cmake based projects
# https://gist.github.com/Mic92/135e83803ed29162817fce4098dec144
# as an alternative you can execute the following command:
# $ eval echo $(nix-instantiate --eval --expr 'with (import <nixpkgs>) {}; clang.default_cxx_stdlib_compile')
preFixup = '' preFixup = ''
substituteInPlace "$out"/share/vim-plugins/clang_complete/plugin/clang_complete.vim \ substituteInPlace "$out"/share/vim-plugins/clang_complete/plugin/clang_complete.vim \
--replace "let g:clang_library_path = '' + "''" + ''" "let g:clang_library_path='${llvmPackages.clang.cc}/lib/libclang.so'" --replace "let g:clang_library_path = '' + "''" + ''" "let g:clang_library_path='${llvmPackages.clang.cc}/lib/libclang.so'"