New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdenv: expose libc/c++ stdlib header at runtime #95733
Conversation
fi | ||
|
||
if [[ -f "$NIX_CC/nix-support/cxxpath" ]]; then | ||
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}${CPLUS_INCLUDE_PATH:+':'}$(< "$NIX_CC/nix-support/cxxpath") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaking this should also fix #73345 (comment)
+ optionalString (libcxx != null | ||
|| (isClang && !(stdenv.targetPlatform.useLLVM or false) && gccForLibs.langCC or false) | ||
|| (isGNU && cc.langCC or false)) '' | ||
touch "$out/nix-support/libcxx-cxxflags" | ||
touch "$out/nix-support/libcxx-ldflags" | ||
'' | ||
+ optionalString (libcxx == null && (isClang && !(stdenv.targetPlatform.useLLVM or false) && gccForLibs.langCC or false)) '' | ||
+ optionalString (libcxx == null | ||
&& (isClang && !(stdenv.targetPlatform.useLLVM or false) && gccForLibs.langCC or false)) '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are only cosmetics to make them fit into the github review window.
'' | ||
# c++ includes come from gcc | ||
+ optionalString (gccForLibs.langCC or false) '' | ||
echo "$(echo ${gccForLibs}/include/c++/*):$(echo ${gccForLibs}/include/c++/*/${targetPlatform.config})" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct that gcc only ever contains one directory at those levels?
no function change
At runtime in a nix-shell we want to find include paths used by the current c/c++ compiler for use in c/c++ tooling i.e. clangd/clang-tools.
This way it should respect the current environment instead of hard-coding what was used at build-time. Also only include c++ specific headers in CPLUS_INCLUDE_PATH as CPATH is respected for c++ as well according to clang(1).
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/get-clangd-to-find-standard-headers-in-nix-shell/11268/7 |
Closing this to encourage other folks to pick it up.... I luckily don't have to do c++... |
Motivation for this change
It evaluate, but I need to test it actually.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)