sparcians / map

Modeling Architectural Platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmake files linking to `-lpthread` but not passing `-pthread` option isn't correct for GCC. Need `find_module(Threads REQUIRED)`

timsnyder opened this issue · comments

set (Sparta_LIBS sparta simdb HDF5::HDF5 sqlite3 yaml-cpp ZLIB::ZLIB pthread

(and the same thing in simdb-config.cmake)

Mean that whenever someone builds with GCC instead of clang, we're doing the wrong thing. I haven't seen problematic behavior yet, I'm just scrubbing the build scripts to resolve some issues in my downstream model.

The way pthread is being included in the build is maybe not 100% correct for GCC. We're passing -lpthread to linking but not passing the -pthread option to compile. This means that the _REENTRANT and _USE_REENTRANT macros are not defined and I read somewhere (that of course I'm having trouble finding again) that not having those macros defined at compile time means that appropriate locking isn't happening and I really have no clue why this isn't manifesting with ugly issues. Perhaps I'm not really pushing the concurrency features of Sparta hard? As I've mentioned elsewhere, I'm not using simdb yet.

https://stackoverflow.com/questions/23250863/difference-between-pthread-and-lpthread-while-compiling explains some of this stuff.

https://stackoverflow.com/questions/1620918/cmake-and-libpthread describes the "correct" way to configure cmake to use pthread so that the compile-time option is included as well as the link-time option and would react to different toolchains being used.

I'll try to push a PR for this but didn't want to hold off on filing a ticket capturing the issue.