### *BSD
In NetBSD you will almost certainly need to have a newer compiler installed.
+This will not replace the one in the standard base distribution, and
+cmake will probably find the wrong compiler when it checks automatically.
Using the example of gcc12 from pkgsrc, one will need to set two
environment variables before starting:
```
```
-In FreeBSD similarly, using gcc12 from pkg
+In FreeBSD similarly, if you install another compiler, cmake might not
+find the right one. Worse is if it finds, say, g++ and configures it for
+C++ but leaves cc for C - FreeBSD's default cc is clang, and the binaries
+generated between g++ and clang will not play nicely together.
+Using the example of gcc12 from pkg:
```
export CC="/usr/local/bin/gcc"
export CXX="/usr/local/bin/g++"
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -gdwarf-4")
endif()
+if(NETBSD)
+ set(EXTRA_C_FLAGS "${EXTRA_CXX_FLAGS} -DHAVE_BUILTIN_POPCOUNT")
+ set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -DHAVE_BUILTIN_POPCOUNT")
+endif()
+
# these end up in the config file
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAS_C_HIDDEN)
CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden HAS_CXX_HIDDEN)
#endif
#ifdef __NetBSD__
#include <strings.h>
-#define HAVE_LOCAL_POPCOUNT
#endif
#endif // UTIL_ARCH_X86_H_
#include "ue2common.h"
#include "util/arch.h"
-#ifndef HAVE_LOCAL_POPCOUNT
+#ifndef HAVE_BUILTIN_POPCOUNT
static really_inline
u32 popcount32(u32 x) {
return __builtin_popcount(x);
// return (((x + (x >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;
// #endif
}
-#endif /* HAVE_LOCAL_POPCOUNT */
+#endif /* HAVE_BUILTIN_POPCOUNT */
static really_inline
u32 popcount32x4(u32 const *x) {
return sum;
}
-#ifndef HAVE_LOCAL_POPCOUNT
+#ifndef HAVE_BUILTIN_POPCOUNT
static really_inline
u32 popcount64(u64a x) {
return __builtin_popcountll(x);
// return popcount32(x >> 32) + popcount32(x);
// #endif
}
-#endif /* HAVE_LOCAL_POPCOUNT */
+#endif /* HAVE_BUILTIN_POPCOUNT */
static really_inline
u32 popcount64x4(u64a const *x) {