[Bug 276159] net/mosh: fix build with clang 18

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 06 Jan 2024 18:58:35 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276159

            Bug ID: 276159
           Summary: net/mosh: fix build with clang 18
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: zi@FreeBSD.org
          Reporter: dim@FreeBSD.org
          Assignee: zi@FreeBSD.org
             Flags: maintainer-feedback?(zi@FreeBSD.org)

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.