Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] undefined references to lround, log, pow: benchmark uses math.h/cmath but doesn't specify the -lm linker flag on FreeBSD/OpenBSD when using Bazel #1031

Open
yesudeep opened this issue Aug 27, 2020 · 3 comments

Comments

@yesudeep
Copy link
Contributor

Describe the bug

❯ bazel build //test/...
WARNING: /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/ffbd632d168ee0cddab7ac9029ce644e/external/remote_java_tools_linux/BUILD:671:11: in hdrs attribute of cc_library rule @remote_java_tools_linux//:combiners: Artifact 'external/remote_java_tools_linux/java_tools/src/tools/singlejar/zip_headers.h' is duplicated (through '@remote_java_tools_linux//:transient_bytes' and '@remote_java_tools_linux//:zip_headers'). Since this rule was created by the macro 'cc_library', the error might have been caused by the macro implementation
INFO: Analyzed 30 targets (0 packages loaded, 0 targets configured).
INFO: Found 30 targets...
ERROR: /usr/home/yesudeep/code/yesudeep/benchmark/test/BUILD:40:12: Linking of rule '//test:args_product_test' failed (Exit 1) clang failed: error executing command /usr/bin/clang -o bazel-out/freebsd-fastbuild/bin/test/args_product_test '-Wl,-rpath,$ORIGIN/../_solib_freebsd/' -Lbazel-out/freebsd-fastbuild/bin/_solib_freebsd ... (remaining 10 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
ld: error: bazel-out/freebsd-fastbuild/bin/_solib_freebsd/liblibbenchmark.so: undefined reference to lround
ld: error: bazel-out/freebsd-fastbuild/bin/_solib_freebsd/liblibbenchmark.so: undefined reference to log
ld: error: bazel-out/freebsd-fastbuild/bin/_solib_freebsd/liblibbenchmark.so: undefined reference to pow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
INFO: Elapsed time: 0.437s, Critical Path: 0.25s
INFO: 1 process: 1 processwrapper-sandbox.
FAILED: Build did NOT complete successfully

System
Which OS, compiler, and compiler version are you using:

  • OS: FreeBSD 12.1-STABLE (GhostBSD 20.08.20 XFCE)
  • Compiler and version: clang version 12.0.0

To reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/google/benchmark
  2. bazel build //test/...

Expected behavior
Expected to build and run benchmarks without linker errors.

@yesudeep yesudeep changed the title [BUG] undefined references to lround, log, pow: googletest uses math.h/cmath but doesn't specify the -lm linker flag on FreeBSD/OpenBSD when using Bazel [BUG] undefined references to lround, log, pow: benchmark uses math.h/cmath but doesn't specify the -lm linker flag on FreeBSD/OpenBSD when using Bazel Aug 28, 2020
@yesudeep
Copy link
Contributor Author

Fixed by 4475ff6

@yesudeep
Copy link
Contributor Author

Turns out that 4475ff6 isn't the correct fix for this problem. Bazel apparently uses /usr/bin/clang to link C++ code, when it should be using /usr/bin/clang++. Sending a PR to revert this change.

@yesudeep yesudeep reopened this Aug 30, 2020
@yesudeep
Copy link
Contributor Author

Here's a reference to the actual problem: bazelbuild/bazel#12023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants