Closed bedwardly-down closed 2 years ago
Wow, this is awesome, thanks!
Laminar compiles with clang under Linux so I guess it should also work on FreeBSD. Is it a matter of the dependencies like libinotify
not coming in a clang flavour? If clang is the preferred compiler then it would be great to get that working
I may have miscommunicated. The issue isn’t libinotify or any library you’ve used so far. The issue has to do with how FreeBSD’s standard C library that Clang uses handles shared_ptr’s. I’m not home right now but I can easily grab the error code when I get back.
On a side note: how are you compiling with Clang? That might give some hints to figure out a workaround. Thanks
Clang error:
In file included from /root/git/laminar/src/laminar.h:22:
In file included from /root/git/laminar/src/run.h:22:
In file included from /usr/include/c++/v1/string:506:
In file included from /usr/include/c++/v1/string_view:175:
In file included from /usr/include/c++/v1/__string:57:
In file included from /usr/include/c++/v1/algorithm:643:
/usr/include/c++/v1/memory:3455:7: error: exception specification of overriding function is more lax than base version
class __shared_ptr_emplace```
How I've been configuring cmake with it:
`cmake ../laminar/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/opt/laminar -DCMAKE_C_FLAGS="-pthread -I/usr/local/include -Wno-deprecated-declarations" -DCMAKE_CXX_FLAGS="-pthread -I/usr/local/include -Wno-deprecated-declarations" -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/lib" -DCMAKE_C_COMPILER_TARGET="x86_64-unknown-freebsd13.0" -DCMAKE_CXX_COMPILER_TARGET="x86_64-unknown-freebsd13.0" -DCMAKE_C_COMPILER="/usr/local/bin/clang-cpp14" -DCMAKE_CXX_COMPILER="/usr/local/bin/clang++14"`
The -Wno-deprecated-declarations flag was to ignore Clang specific errors that are not actual problems. When compiling with Clang 7 (the oldest currently supported one, the shared_ptr_emplace error above is the only one that's thrown due to some changes made in Clang's error handling.
To compile with clang I just use cmake -DCMAKE_CXX_COMPILER=clang++
. My clang is 13.0.1
and it compiles without any warnings or errors. Note that cmake adds -std=gnu++17
- I hope that makes it through? For example, when I run make VERBOSE=1
, an example line is
[ 88%] Building CXX object CMakeFiles/laminarc.dir/src/version.cpp.o
/usr/bin/clang++ -DLAMINAR_VERSION=1.2-3-g99e2e629 -I/home/og/dev/laminar/build-clang -I/home/og/dev/laminar -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -std=gnu++17 -MD -MT CMakeFiles/laminarc.dir/src/version.cpp.o -MF CMakeFiles/laminarc.dir/src/version.cpp.o.d -o CMakeFiles/laminarc.dir/src/version.cpp.o -c /home/og/dev/laminar/src/version.cpp
The actual error you posted doesn't make any sense to me. The only context from laminar source is #include <string>
- is there some missing information?
There's a new full release of FreeBSD that just dropped today with an upgraded version of Clang and the standard-C library so I'm going to start over from scratch here since most of these issues may have been fixed in it. It's also very possible that my server configuration is just messed up in some form, so I'll try for building in a more clean environment. :D
And he was never seen again...
Turns out that getting it ported over wasn't all that difficult. Most of the code and dependencies have already been ported over to FreeBSD. It's not perfect, though.
To compile with GCC:
1) Install all of the libraries from the Debian Bullseye instructions + the libinotify port and gcc12 2) Run
mkdir build
in the laminar root directory and cd into it (this is a common practice when using cmake) 3) Runcmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_COMPILER="/usr/local/bin/g++12" -DCMAKE_C_COMPILER="/usr/local/bin/gcc12" -DCMAKE_CXX_FLAGS="-I/usr/local/include -Wl,-rpath=/usr/local/lib/gcc12 -L/usr/local/lib -lpthread -linotify -lgtest -lgmock" -DBUILD_TESTS=TRUE
FreeBSD defaults to using clang for everything unless you explicitly tell it otherwise and needs some extra flags to get everything configured correctly 4) Runcmake --build . -j $(nproc)
and hopefully everything will go without issues.Current issues:
1) FreeBSD's standard library seems to have issues with how the shared_ptrs are used; all supported versions of Clang have problems handling them while GCC is fine. 2) GCC is no longer officially supported or the recommended compiler for FreeBSD but multiple versions of it compiled the code and tests fine. There may be bugs long term. 3) The server seems to segfault due to library permission issues if built within a jail with hardened settings configured (can sort of be partially solved by building with
-static-libgcc -static-libstdc++
in the -DCMAKE_CXX_FLAGS string from above but I'm not sure how problematic that can be yet.Tested on:
FreeBSD 13.1-RC6 (main official release coming in the next day or two) 3-core 2.6GHz Intel Xeon server processor 4GB DDR4 RAM Built inside of a BastilleBSD jail (think FreeBSD native version of Docker with some twists)