Clang 18 is more strict about how builtin functions are used, resulting in an error building net/mosh: ocb_internal.cc:752:22: error: use of undeclared identifier 'bswap64' 752 | ctx->KtopStr[0] = bswap64(ctx->KtopStr[0]); | ^ ocb_internal.cc:753:22: error: use of undeclared identifier 'bswap64' 753 | ctx->KtopStr[1] = bswap64(ctx->KtopStr[1]); | ^ The problem is that __builtin_bswap64 is not being detected correctly by the configure script (the existence of the regular bswap64 is forced via ac_cv_have_decl_bswap64=yes in CONFIGURE_ENV): checking whether be64toh is declared... yes checking whether betoh64 is declared... no checking whether bswap64 is declared... (cached) yes checking whether __builtin_bswap64 is declared... no This is because configure attempts to detect __builtin_bswap64 via the following C fragment: int main (void) { #ifndef __builtin_bswap64 #ifdef __cplusplus (void) __builtin_bswap64; #else (void) __builtin_bswap64; #endif #endif which results in an error: conftest.cpp:80:10: error: builtin functions must be directly called 80 | (void) __builtin_bswap64; | ^ Work around it by adding ac_cv_have_decl___builtin_bswap64=yes to CONFIGURE_ENV too. While here, swap around the HAVE_DECL___BUILTIN_BSWAP64 and HAVE_DECL_BSWAP64 blocks in src/crypto/ocb_internal.cc, so it prefers to use the builtin before calling any external function or macro.
Created attachment 247494 [details] net/mosh: fix build with clang 18
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=2af16d130db46aeb4a579c27715fa82ad9562a69 commit 2af16d130db46aeb4a579c27715fa82ad9562a69 Author: Ryan Steinmetz <zi@FreeBSD.org> AuthorDate: 2024-01-06 19:43:06 +0000 Commit: Ryan Steinmetz <zi@FreeBSD.org> CommitDate: 2024-01-06 19:45:20 +0000 net/mosh: Fix build with clang 18 PR: 276159 Submitted by: dim@ net/mosh/Makefile | 3 ++- net/mosh/files/patch-src_crypto_ocb__internal.cc (new) | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)