最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to condition Bazel transition on target OS? - Stack Overflow

programmeradmin5浏览0评论

Is it possible to know about target platform constrains from-inside the transition implementation?

The problem comes from building a TensorFlow extension that apart from a few extra flags requires to transition to libstd if built on Linux. The main codebase is built with libc++ via LLVM.

Generally, I try to modify this code to fit multi-platform build: .bzl

Originally, it was written only for Linux. And attempt to extend it for macOS met an issue of conditioning those libstd lines on Linux only:

if (target_is_linux):
    cxxopts.append("-stdlib=libstdc++")
    linkopts.append("-stdlib=libstdc++")

What is the best way to approch it?

Bazel version: 7.5.0


Taking the transition is defined as inbound, I consider modifying the native_binary rule inside the [tf_custom_op_library]((.bzl#L111)) macros to execute a select on any of its attributes to resolve it before the transition invocation, and then access its value through atrs.

Although it seems to be the only way I've found so far, I wonder, if there is a better way? Or should the whole thing be redesigned for a milti-OS use? Or is there a way to pass constraints into transition as inputs?

发布评论

评论列表(0)

  1. 暂无评论