【问题标题】:Specify sysroot for Bazel toolchain为 Bazel 工具链指定 sysroot
【发布时间】:2020-10-08 14:07:54
【问题描述】:

我正在使用来自unix_cc_toolchain_config.bzlcc_toolchain_config 来配置我的自定义工具链。我想指定一个自定义的 sysroot,所以我调用:

cc_toolchain_config(
  #...
  cxx_builtin_include_directories = [
    "%sysroot%/usr/include",
  ],
)

巴泽尔抱怨:

A %sysroot% prefix is only allowed if the default_sysroot option is set

我找不到对“default_sysroot”选项的引用(我认为错误消息是错误的),但cc_native.create_cc_toolchain_config_info 使用了“builtin_sysroot”选项。这是cc_toolchain_configactually uses的函数,但它没有直接指定builtin_sysroot参数。但是,它does configure 是一个“sysroot”功能,但我不知道如何使用它。我按照doc 的提示尝试了bazel build --features sysroot,但它给出了同样的错误。

如何让unix_cc_toolchain_config.bzl:cc_toolchain_config使用我指定的sysroot?

【问题讨论】:

    标签: c++ bazel toolchain


    【解决方案1】:

    截至commit da345f1unix_cc_toolchain_config.bzl:cc_toolchain_config 有一个builtin_sysroot 属性,可用于配置内置 sysroot:

    cc_toolchain_config(
      #...
      cxx_builtin_include_directories = [
        "%sysroot%/usr/include",
      ],
      builtin_sysroot = "path/to/my/sysroot",
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-03
      • 1970-01-01
      • 2011-07-03
      • 2020-06-11
      • 2019-01-08
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      相关资源
      最近更新 更多