]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
moved HAVE_BUILTIN_POPCOUNT def to cmake
authorG.E. <gregory.economou@vectorcamp.gr>
Tue, 12 Mar 2024 12:22:39 +0000 (14:22 +0200)
committerG.E. <gregory.economou@vectorcamp.gr>
Tue, 12 Mar 2024 12:22:39 +0000 (14:22 +0200)
README.md
cmake/cflags-generic.cmake
src/util/arch.h
src/util/popcount.h

index 5dafd0ea3abae14923881173078327378e8c4a1e..2ecc0961e03f2115948a7d6b63a068d753658431 100644 (file)
--- a/README.md
+++ b/README.md
@@ -115,6 +115,8 @@ Assuming an existing HomeBrew installation:
 
 ### *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: 
 ```
@@ -123,7 +125,11 @@ export CXX="/usr/pkg/gcc12/bin/g++"
 ```
 
 
-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++"
index 93fa789da210cf13ce6908527f323907f7b0cf1f..35bbe9f480366f6fd539e80b71a24379a2b6698f 100644 (file)
@@ -31,6 +31,11 @@ if(FREEBSD OR NETBSD)
     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)
index 9a9dde1bdf9867595e106b2eff231ecf15fe0ba2..1963b4051a362fdf5696ff01e038bf55c474098e 100644 (file)
@@ -44,7 +44,6 @@
 #endif
 #ifdef __NetBSD__
 #include <strings.h>
-#define HAVE_LOCAL_POPCOUNT
 #endif
 
 #endif // UTIL_ARCH_X86_H_
index a02e3bc56075a8dbefab2bbd7bc6c9434d0dfd4c..34f386b714765272af7931fd29dd2c09326845ab 100644 (file)
@@ -37,7 +37,7 @@
 #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);
@@ -52,7 +52,7 @@ u32 popcount32(u32 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) {
@@ -63,7 +63,7 @@ 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);
@@ -84,7 +84,7 @@ u32 popcount64(u64a x) {
 //     return popcount32(x >> 32) + popcount32(x);
 // #endif
 }
-#endif /* HAVE_LOCAL_POPCOUNT */
+#endif /* HAVE_BUILTIN_POPCOUNT */
 
 static really_inline
 u32 popcount64x4(u64a const *x) {