moved HAVE_BUILTIN_POPCOUNT def to cmake

This commit is contained in:
G.E. 2024-03-12 14:22:39 +02:00
parent 226645eaf1
commit 0045a2bdc7
4 changed files with 16 additions and 6 deletions

View File

@ -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++"

View 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)

View File

@ -44,7 +44,6 @@
#endif
#ifdef __NetBSD__
#include <strings.h>
#define HAVE_LOCAL_POPCOUNT
#endif
#endif // UTIL_ARCH_X86_H_

View 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) {