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

Switch to the new C++ toolchains API #444

Open
AustinSchuh opened this issue Jan 17, 2025 · 2 comments
Open

Switch to the new C++ toolchains API #444

AustinSchuh opened this issue Jan 17, 2025 · 2 comments

Comments

@AustinSchuh
Copy link
Contributor

The new BUILD file based C++ toolchains promise to be much easier to maintain.

https://github.com/bazelbuild/rules_cc/tree/main/examples/rule_based_toolchain

What do you all think about switching over to using those? I'm happy to help.

The example makes it look like we can reuse pieces from rules_cc.

cc_toolchain(                                                                                                                           
    name = "host_clang",                                                                                                           
    args = select({                                                                                                                              
        "@platforms//os:linux": [                                                                                                                            
            "//toolchain/args:linux_sysroot",                                                                             
        ],                                                                                                                                         
        "//conditions:default": [],    
    }) + [                                                                                                                                                       
        "//toolchain/args:no_canonical_prefixes",                                                                                                   
        "//toolchain/args:warnings",                                                                                  
    ],                                                                    
    enabled_features = ["@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features"],                                                                                                  
    known_features = ["@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features"],    
    tool_map = "//toolchain/tools:all_tools",                                                                       
)                                                                                                                                                            
                                                                                                                 
toolchain(                                                                                                                         
    name = "host_cc_toolchain",                                                                                                   
    toolchain = ":host_clang",                                                                                                                                    
    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",                                                                                
)  
@keith
Copy link
Member

keith commented Jan 17, 2025

note that this repo mostly just doesn't use any of the old stuff for this either since it just shells out to the default toolchain setup code.

unix_cc_toolchain_config(

@AustinSchuh
Copy link
Contributor Author

Yup. I'm trying to upstream a bunch of fixes we've built up over the years that let us cross compile against sysroots. I'm quickly finding all the places where new flags need to be injected in very specific spots through unix_cc_toolchain_config which don't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants