gridcoin-community / Gridcoin-Research

Gridcoin-Research
MIT License
585 stars 173 forks source link

fix build on FreeBSD #2770

Closed wilkart closed 1 week ago

wilkart commented 2 weeks ago

Fix building on FreeBSD.

[ 73%] Building CXX object src/CMakeFiles/gridcoin_util.dir/pbkdf2.cpp.o
/home/wilkart/Gridcoin-Research/src/pbkdf2.cpp:20:1: error: redefinition of 'be32enc'
be32enc(void *pp, uint32_t x)
^
/usr/include/sys/endian.h:128:1: note: previous definition is here
be32enc(void *pp, uint32_t u)
^
1 error generated.
gmake[2]: *** [src/CMakeFiles/gridcoin_util.dir/build.make:972: src/CMakeFiles/gridcoin_util.dir/pbkdf2.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:249: src/CMakeFiles/gridcoin_util.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

Additionally remove #include <linux/random.h> according to upstream.

This requires a linux kernel of 3.17.0+, which seems entirely
reasonable. 3.17 went EOL in 2015, and the last supported 3.x kernel
(3.16) went EOL > 4 years ago, in 2020. For reference, the current
oldest maintained kernel is 4.14 (released 2017, EOL Jan 2024).
Support for getrandom() (and getentropy()) was added to
glibc 2.25, https://sourceware.org/legacy-ml/libc-alpha/2017-02/msg00079.html,
and we already require 2.27+.
All that being said, I don't think you would encounter a current day
system, running with kernel headers older than 3.17 (released 2014) but
also having a glibc of 2.27+ (released 2018).
wilkart commented 2 weeks ago

@jamescowens @div72 Dear collegues, maybe you could review my changes and advice how to pass the test-linux-minimal.

I am trying to solve problem of building on FreeBSD 14. I am running 2 instances now for verification, built with gmake on amd64 and with cmake on arm64.

div72 commented 2 weeks ago

@wilkart Was the <linux/random.h> include causing problems for FreeBSD? If so, did you check if it was CMake-only or reproducable with automake? I remember CMake setting some HAVE_* flags to 0 when it shouldn't have been defined in the first place.

wilkart commented 2 weeks ago

@div72 I confirm it is CMake-only error.

[ 75%] Building CXX object src/CMakeFiles/gridcoin_util.dir/random.cpp.o
/root/Gridcoin-Research/src/random.cpp:34:10: fatal error: 'linux/random.h' file not found
#include <linux/random.h>
         ^~~~~~~~~~~~~~~~
1 error generated.

Solution, I simply took from bitcoin repository as upstream.