I download the source code of tensorflow-2.17.0 from github, then i run ‘configure’ and build with bazel-6.5.0 successfully,
> bazel build //tensorflow/core:tensorflow
then i create a folder ‘test’ and add a file named ‘test.cc’ with an empty main function
int main(int argc, const char** argv) {
return 0
}
the BUILD file:
cc_binary(
name="test",
srcs=["test.cc"],
linkopts = [
"-lpthread",
"-lrt",
"-ldl",
"-lnsl",
"-latomic",
],
linkstatic = 1,
deps=[
"//tensorflow/core:tensorflow"
],
)
but when i run ‘bazel build //test:test’, there are a lot of link errors:
external/com_google_absl/absl/base/casts.h:161:42: error: no type named 'type' in 'struct std::enable_if<false, int>'
int>::type = 0>
^
In file included from external/local_xla/xla/shape.h:29,
from external/local_xla/xla/index_util.h:24,
from external/local_xla/xla/literal.h:45,
from external/local_xla/xla/literal.cc:16:
external/local_xla/xla/literal.h: In instantiation of 'bool xla::LiteralBase::DeserializeState<InputIterator>::ReadElements(absl::lts_20230802::Span<NativeT>) [with NativeT = ml_dtypes::float8_internal::float8_e4m3fn; InputIterator = const char*]':
external/local_xla/xla/literal.h:1528:44: required from 'bool xla::LiteralBase::Piece::DeserializeData(xla::LiteralBase::DeserializeState<InputIterator>&) [with NativeT = ml_dtypes::float8_internal::float8_e4m3fn; InputIterator = const char*]'
external/local_xla/xla/literal.h:1587:3: required from 'xla::Literal::Deserialize(InputIterator, InputIterator) [with InputIterator = const char*]::<lambda(const xla::ShapeIndex&, xla::LiteralBase::Piece*)>::<lambda(auto:5)> [with auto:5 = std::integral_constant<xla::PrimitiveType, (xla::PrimitiveType)20>]'
external/local_xla/xla/primitive_util.h:432:34: required from 'constexpr R xla::primitive_util::FloatingPointTypeSwitch(F&&, xla::PrimitiveType) [with R = bool; F = xla::Literal::Deserialize(InputIterator, InputIterator) [with InputIterator = const char*]::<lambda(const xla::ShapeIndex&, xla::LiteralBase::Piece*)>::<lambda(auto:5)>]'
external/local_xla/xla/primitive_util.h:480:40: required from 'constexpr R xla::primitive_util::ArrayTypeSwitch(F&&, xla::PrimitiveType) [with R = bool; F = xla::Literal::Deserialize(InputIterator, InputIterator) [with InputIterator = const char*]::<lambda(const xla::ShapeIndex&, xla::LiteralBase::Piece*)>::<lambda(auto:5)>]'
external/local_xla/xla/literal.h:1587:3: required from 'static absl::lts_20230802::StatusOr<xla::Literal> xla::Literal::Deserialize(InputIterator, InputIterator) [with InputIterator = const char*]'
external/local_xla/xla/literal.h:1390:62: required from here
external/local_xla/xla/literal.h:684:64: in 'constexpr' expansion of 'xla::primitive_util::BitWidth(((xla::PrimitiveType)primitive_type))'
external/local_xla/xla/primitive_util.h:568:54: error: 'constexpr int xla::primitive_util::internal::WidthForType(xla::PrimitiveType) [with const std::array<int, 28>& kWidths = xla::primitive_util::internal::kBitWidths]' called in a constant expression
return internal::WidthForType<internal::kBitWidths>(type);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from external/local_xla/xla/literal.cc:16:
external/local_xla/xla/literal.h:686:23: error: static assertion failed
static_assert(!primitive_util::IsFloatingPointType(primitive_type));
i don’t know why i build a library with ‘//tensorflow/core:tensorflow’ successfully but the binary command executes failed, here’s some params of my environment:
system: Ubuntu-20.04 x64
gcc: 8.4.0