【问题标题】:How to configure toolchain in Bazel如何在 Bazel 中配置工具链
【发布时间】:2019-04-27 03:11:23
【问题描述】:

我们计划使用 Bazel 对不同的 Arch 目标进行交叉编译,但我们遇到了一些关于工具链的问题:

根据docs,我们将工具链配置为:

toolchain_include_directories_feature = feature(
        name = "toolchain_include_directories",
        enabled = True,
        flag_sets = [
            flag_set(
                actions = [
                    "ACTION_NAMES.assemble",
                    "ACTION_NAMES.preprocess_assemble",
                    "ACTION_NAMES.linkstamp_compile",
                    "ACTION_NAMES.c_compile",
                    "ACTION_NAMES.cpp_compile",
                    "ACTION_NAMES.cpp_header_parsing",
                    "ACTION_NAMES.cpp_module_compile",
                    "ACTION_NAMES.cpp_module_codegen",
                    "ACTION_NAMES.lto_backend",
                    "ACTION_NAMES.clif_match",
                ],
                flag_groups = [
                    flag_group(
                        flags = [
                             "-isystem",
                             "/opt/buildtools/sdk/usr/include",
                        ],
                    ),
                ],
            ),
        ],
    )

我们得到错误:

ERROR: /home/project/aa/BUILD:1:1: undeclared inclusion(s) in rule '//aa:mylib':
this rule is missing dependency declarations for the following files included by 'aa/source/export.c':
  '/opt/buildtools/sdk/usr/include/stdc-predef.h'

任何想法,谢谢。

添加:环境信息

LSB Version:    n/a
Distributor ID: SUSE
Description:    SUSE Linux Enterprise Server 12 SP4
Release:        12.4
Codename:       n/a
4.12.14-94.41-default #1 SMP Wed Oct 31 12:25:04 UTC 2018 (3090901) x86_64 x86_64 x86_64 GNU/Linux

Bazel version: 0.24.1

【问题讨论】:

    标签: arm cross-compiling bazel toolchain


    【解决方案1】:

    当您使用create_cc_toolchain_config_info 创建工具链配置时,不要忘记通过添加通常的包含路径来设置其cxx_builtin_include_directories 参数,例如

    def _impl(ctx):
        #  [...]
        cxx_builtin_include_directories = [
            "/opt/buildtools/sdk/usr/include/",
            "/usr/include",
        ]
    
        return [
            cc_common.create_cc_toolchain_config_info(
                cxx_builtin_include_directories = cxx_builtin_include_directories,
                #  [...]
            ),
        ]
    

    【讨论】:

      【解决方案2】:

      动作列表中的 ACTION_NAMES 也不应该用引号括起来。看到这个:https://github.com/bazelbuild/bazel/pull/7673

      【讨论】:

        猜你喜欢
        • 2022-11-03
        • 2020-11-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-08
        • 1970-01-01
        • 2023-04-01
        • 1970-01-01
        相关资源
        最近更新 更多