Bug 276159 - net/mosh: fix build with clang 18
Summary: net/mosh: fix build with clang 18
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Ryan Steinmetz
URL:
Keywords:
Depends on:
Blocks: 276104
  Show dependency treegraph
 
Reported: 2024-01-06 18:58 UTC by Dimitry Andric
Modified: 2024-01-06 19:46 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (zi)


Attachments
net/mosh: fix build with clang 18 (3.26 KB, patch)
2024-01-06 18:59 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2024-01-06 18:58:35 UTC
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.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2024-01-06 18:59:56 UTC
Created attachment 247494 [details]
net/mosh: fix build with clang 18
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-01-06 19:46:31 UTC
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(-)