diff --git a/BUILD.bazel b/BUILD.bazel index 4e40b718b..395008cc2 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -10,6 +10,20 @@ exports_files([ "LICENSE", ]) +config_setting( + name = "platform_freebsd", + constraint_values = [ + "@platforms//os:freebsd", + ], +) + +config_setting( + name = "platform_openbsd", + constraint_values = [ + "@platforms//os:openbsd", + ], +) + # Public flatc library to compile flatbuffer files at runtime. cc_library( name = "flatbuffers", diff --git a/src/BUILD.bazel b/src/BUILD.bazel index d41d0fc52..a1cad077f 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -17,6 +17,15 @@ cc_library( "util.cpp", ], hdrs = ["//:public_headers"], + linkopts = select({ + # TODO: Bazel uses `clang` instead of `clang++` to link + # C++ code on BSD. Temporarily adding these linker flags while + # we wait for Bazel to resolve + # https://github.com/bazelbuild/bazel/issues/12023. + "//:platform_freebsd": ["-lm"], + "//:platform_openbsd": ["-lm"], + "//conditions:default": [], + }), strip_include_prefix = "/include", visibility = ["//:__pkg__"], )