Hello, I encountered the following error building security/sssd on arm64: src/util/crypto/nss/nss_sha512crypt.c:33:1: error: static declaration of 'mempcpy' follows non-static declaration mempcpy (void *dest, const void *src, size_t n) ^ /usr/include/string.h:70:7: note: previous declaration is here void *mempcpy(void * __restrict, const void * __restrict, size_t); ^ 1 error generated. Full build log attached. FreeBSD generic 13.0-STABLE FreeBSD 13.0-STABLE #0 stable/13-n246669-5f27244beb8: Thu Aug 5 03:46:10 UTC 2021 root@releng3.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC arm64 The offending prototype seems to come from /usr/include/string.h Renaming mempcpy to _sha512_mempcpy in nss_sha512crypt.c appears to fix the issue (build succeeds).
Created attachment 227226 [details] Build log
>Renaming mempcpy to _sha512_mempcpy in nss_sha512crypt.c appears to fix the issue >(build succeeds). Naturally both in the static function definition and in all uses of mempcpy within nss_sha512crypt.c ;)
Created attachment 228679 [details] Check for mempcpy The root cause of the problem is that FreeBSD-13.0 has mempcpy(3) in libc -- and declared in <string.h>, whereas the earlier versions did not. There are several other ports affected -- chromium among them (Bug #257352). The earlier solutions simply grep-ed /usr/include/string.h for mempcpy. Here I'm offering a different approach -- test for the function's using configure. It has the advantage of being (potentially) acceptable upstream.
Created attachment 228718 [details] Modified fix for this bug and Bug 258898 (In reply to Mikhail Teterin from comment #3) For me the test in configure.ac always succeeds using poudriere on 12.2 with a 12.2 jail (even though 12.2 does not have mempcpy). I think the compile results only in a warning as it looks like -Werror is not set by default. Attached is a patch that combines my modification of this fix with a patch from Bug 258898 for the package failure.
@Richard Could you separate out the modification for this issuem, obsoleting the original attachment 228718 [details] when attaching as bug 258898 is already closed @Mikhail Are you able to review Richards patch?
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=6cf646c7a526c6c4ca21b2faa9c10b3970f72850 commit 6cf646c7a526c6c4ca21b2faa9c10b3970f72850 Author: Mikhail Teterin <mi@FreeBSD.org> AuthorDate: 2022-02-23 04:59:36 +0000 Commit: Mikhail Teterin <mi@FreeBSD.org> CommitDate: 2022-02-23 04:59:36 +0000 security/sssd: implement detection of mempcpy at configure-time Newer versions of FreeBSD provide mempcpy, which conflicts with the port's own implementation -- meant for the older versions. While here, fix compilation with newer Python -- not just 3.7 -- and relax the requirement for Python-version. This necessitated bumping PORTREVISION -- because the default Python is 3.8 nowadays. Also, define TEST_TARGET -- and fix one of the test to compile. This needs further work, however. PR: 257866 security/sssd/Makefile | 6 ++-- security/sssd/files/patch-configure.ac | 25 +++++++++++-- .../files/patch-src__external__python.m4 (new) | 9 +++++ ...tch-src__tests__cmocka__test_negcache_2.c (new) | 42 ++++++++++++++++++++++ ...__util__crypto__libcrypto__crypto_sha512crypt.c | 4 ++- ...patch-src__util__crypto__nss__nss_sha512crypt.c | 4 ++- 6 files changed, 83 insertions(+), 7 deletions(-)
Thanks, Richard, for the idea!