Skip to content
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

Use rules based c++ toolchain #634

Open
finn-ball opened this issue Dec 20, 2024 · 2 comments
Open

Use rules based c++ toolchain #634

finn-ball opened this issue Dec 20, 2024 · 2 comments
Labels
P3 minor: not priorized type: feature request

Comments

@finn-ball
Copy link

Is your feature request related to a problem? Please describe.
The current toolchain definitions are long and verbose:
https://github.com/tweag/rules_nixpkgs/blob/master/core/private/cc_toolchain/cc_toolchain_config.bzl

Describe the solution you'd like
Use the new rules based toolchain, example here:
https://github.com/bazelbuild/rules_cc/tree/main/examples/rule_based_toolchain

@malt3 malt3 added the P3 minor: not priorized label Dec 21, 2024
@malt3
Copy link
Collaborator

malt3 commented Dec 21, 2024

Thank you for reaching out. I have seen the new, rules based approach and it looks very promising.
Without having looked at it at a deeper level, I’m not sure how much work this entails. I think we should consider doing this.

In any case, if you or someone else wants to take a stab, we are open to contributions.

@kczulko
Copy link
Contributor

kczulko commented Jan 21, 2025

Hello,

Let me paste here some of my tiny findings for giving it a try yesterday evening. I ended up with such an error list:

ERROR: /home/kczulko/Projects/kczulko/rule_based_cc_toolchain_nixpkgs_rules_nim/BUILD.bazel:76:10: Compiling hello-world.cc failed: absolute path inclusion(s) found in rule '//:bin':
the source file 'hello-world.cc' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
  '/nix/store/lcxvgkg659vbvdq86mhxa599wn48f35c-glibc-2.40-36-dev/include/stdc-predef.h'
  '/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/include/c++/13.3.0/iostream'
  '/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/include/c++/13.3.0/bits/requires_hosted.h'
  '/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/include/c++/13.3.0/x86_64-unknown-linux-gnu/bits/c++config.h'
  '/nix/store/62qjb50708fdhb4f2y7zxyqr1afir4fk-gcc-13.3.0/include/c++/13.3.0/x86_64-unknown-linux-gnu/bits/os_defines.h'
  '/nix/store/lcxvgkg659vbvdq86mhxa599wn48f35c-glibc-2.40-36-dev/include/features.h'
...

which lead me to conclusion that what I am missing here is:

"%{cxx_builtin_include_directories}": get_starlark_list(info.cxx_builtin_include_directories),
which is not exposed, I think (subject to additional check), by the rule based toolchain api. I also tried some combo with symlinkJoin/buildEnv where I could pass allowlist_include_directories but that also didn't work. cc_args with both -no-canonical-prefixes and -fno-canonical-system-headers also didn't help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 minor: not priorized type: feature request
Projects
None yet
Development

No branches or pull requests

3 participants