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

Link against lexecinfo on FreeBSD #423

Closed
zoq opened this issue Mar 20, 2015 · 4 comments
Closed

Link against lexecinfo on FreeBSD #423

zoq opened this issue Mar 20, 2015 · 4 comments

Comments

@zoq
Copy link
Member

zoq commented Mar 20, 2015

The build on FreeBSD results with the error: "undefined reference to 'backtrace_symbols'". We need to link against -lexecinfo at least on 10.0 and 10.1 to get it working.

We can fix the problem with:

if(CMAKE_SYSTEM_NAME MATCHES "BSD")
  find_library(execinfo execinfo "/usr/local/lib" "/usr/lib")
  target_link_libraries(mlpack ${execinfo})
endif(CMAKE_SYSTEM_NAME MATCHES "BSD")

I'm not an CMake expert so maybe there is better solution or a better place to fix the issue.

@rcurtin
Copy link
Member

rcurtin commented Mar 20, 2015

As is typical when I'm out of town, I can't connect to my BSD build slave (I'm looking forward to the day where I'm forced to actually come up with a more stable and reliable build server configuration...). I took a look through the offerings of CMake, and there's no find_package script for execinfo, so what you've written seems to be the best option. The only change I'd make is that variable name execinfo to EXECINFO_LIBRARY, but that's only for the sake of making it look more like the rest of the CMake code.

If you want to try that and test it, then (assuming it works, which it should) push it, feel free. I saw some threads where people were having trouble getting execinfo to work on BSD, so if you want to write a quick test program to trigger a Log::Assert() call too, that would be nice (if not, I'll handle it when I get home a week from now or so).

@rcurtin rcurtin added this to the mlpack 1.1.0 milestone Mar 20, 2015
@zoq
Copy link
Member Author

zoq commented Mar 22, 2015

It turns out the solution doesn't work on all platforms (e.g. NetBSD). So instead of writing our own solution, we can just use the CMake FindBacktrace Module shipped with CMake 3+. I've backported the functionality so that we can use the module without requiring CMake 3+.

In case the backtrace() functionality is not available, we use the already existing fallback.

@rcurtin
Copy link
Member

rcurtin commented Mar 24, 2015

I made a couple of simple changes; feel free to revert them if you like. execinfo.h is no longer included in the mlpack namespace, execinfo is only linked against the mlpack target (since it's only used in log.cpp and not anywhere else), and I also provided a default backtrace.hpp file so that users don't get confused before it's configured. (That file will be overwritten during the configuration process.) If you think that's okay, then I think this issue is fixed.

@zoq
Copy link
Member Author

zoq commented Mar 24, 2015

Looks good to me. Patched in 2adbba4, bff92b7 and 02a4f44.

@zoq zoq closed this as completed Mar 24, 2015
@zoq zoq added the s: fixed label Mar 25, 2015
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