From d76a08e9f6042f4c2c07bdf638b41e598fa2c1be Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Fri, 24 Jan 2020 23:52:21 +0000 Subject: [PATCH 1/2] Fix flatbuffers link error This commit: https://github.com/tensorflow/tensorflow/commit/adf6e22e4af83afd55e0da3caa7e7959def1e6b6#diff-4bdae93a605044a27f9df49a92bcf398L129 Removed the linkopts section from the cc_binary 'flatc' from third_party/flatbuffers/BUILD.bazel. That caused builds to fail with: /usr/bin/ld: bazel-out/host/bin/external/flatbuffers/src/libflatbuffers.a(idl_parser.o): undefined reference to symbol 'cos@@GLIBC_2.17' /dt7/lib/powerpc64le-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status (This is GPU builds on ppc64le) I tried passing `--linkopt=-lm` on the bazel build command but it still failed. Restoring the original linkopts section does resolve this problem. (and it seems better to have the linkopt here than globally for the entire build) A simple `linkopts = ["-lm"],` works for ppc64le, but I figured for windows and other platforms it was better to restore the original values. --- third_party/flatbuffers/BUILD.bazel | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/third_party/flatbuffers/BUILD.bazel b/third_party/flatbuffers/BUILD.bazel index 06f0cd210bd..08b4b7a750b 100644 --- a/third_party/flatbuffers/BUILD.bazel +++ b/third_party/flatbuffers/BUILD.bazel @@ -50,6 +50,16 @@ cc_library( # Public flatc compiler. cc_binary( name = "flatc", + linkopts = select({ + ":freebsd": [ + "-lm", + ], + ":windows": [], + "//conditions:default": [ + "-lm", + "-ldl", + ], + }), deps = [ "@flatbuffers//src:flatc", ], From 03e04c6010e9a26f09f52a95239d2fccbd60ea3b Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Mon, 27 Jan 2020 14:15:34 +0000 Subject: [PATCH 2/2] Restore freebsd and windows keys so they can be used in the flatc link options --- third_party/flatbuffers/BUILD.bazel | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/third_party/flatbuffers/BUILD.bazel b/third_party/flatbuffers/BUILD.bazel index 08b4b7a750b..b3991ea1462 100644 --- a/third_party/flatbuffers/BUILD.bazel +++ b/third_party/flatbuffers/BUILD.bazel @@ -8,6 +8,17 @@ exports_files(["LICENSE.txt"]) licenses(["notice"]) +config_setting( + name = "freebsd", + values = {"cpu": "freebsd"}, + visibility = ["//visibility:public"], +) + +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") # Public flatc library to compile flatbuffer files at runtime.