Bug 209019 - net/mosh: Fix build with libc++ 3.8.0
Summary: net/mosh: Fix build with libc++ 3.8.0
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
Depends on:
Blocks: 208158
  Show dependency treegraph
Reported: 2016-04-24 20:56 UTC by Dimitry Andric
Modified: 2016-11-30 08:21 UTC (History)
3 users (show)

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

Fix net/mosh build with libc++ 3.8.0 (1.52 KB, patch)
2016-04-24 20:56 UTC, Dimitry Andric
no flags Details | Diff
Revised upstream patch, adding #include "config.h" (1.88 KB, patch)
2016-05-09 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 2016-04-24 20:56:57 UTC
Created attachment 169642 [details]
Fix net/mosh build with libc++ 3.8.0

During the exp-run in bug 208158, it was found that net/mosh gives errors with libc++ 3.8.0 [1]:

ocb.cc:111:26: error: expected ')'
         static inline uint64_t bswap64(uint64_t x) {
/usr/include/sys/endian.h:61:20: note: expanded from macro 'bswap64'
#define bswap64(x)      __bswap64(x)
/usr/include/x86/endian.h:80:27: note: expanded from macro '__bswap64'
        (__builtin_constant_p(x) ?      \

I'm not completely sure why this is suddenly a problem when building with a newer libc++, other than maybe a different include order.  In any case, mosh tries to redefine its own flavor of bswap64() here, and its configure script fails to properly detect __builtin_bswap64(), which should really be used.

Therefore, add ac_cv_have_decl___builtin_bswap64=yes (and ac_cv_have_decl___builtin_ctz=yes) to the configure arguments, and also add #include "config.h" to ocb.cc, since it didn't include that file yet.

[1] http://package18.nyi.freebsd.org/data/headamd64PR208158-default/2016-03-22_18h30m05s/logs/errors/mosh-1.2.5.log
Comment 1 Ryan Steinmetz freebsd_committer freebsd_triage 2016-05-09 12:16:33 UTC
Upstream committed a fix:
Comment 2 commit-hook freebsd_committer 2016-05-09 12:23:44 UTC
A commit references this bug:

Author: zi
Date: Mon May  9 12:23:00 UTC 2016
New revision: 414841
URL: https://svnweb.freebsd.org/changeset/ports/414841

  - Fix build with libc++ 3.8.0

  PR:		209019
  Submitted by:	dim@
  Obtained from:	upstream commit 9073983df3ff23f2230f941e525aa167ece50ddd

Comment 3 Dimitry Andric freebsd_committer 2016-05-09 18:51:45 UTC
Hm, I still get the same errors after r414841:

--- ocb.o ---
ocb.cc:118:10: warning: 'bswap32' macro redefined [-Wmacro-redefined]
        #define bswap32(x)                                              \
/usr/include/sys/endian.h:60:9: note: previous definition is here
#define bswap32(x)      __bswap32(x)
ocb.cc:122:26: error: expected ')'
         static inline uint64_t bswap64(uint64_t x) {
/usr/include/sys/endian.h:61:20: note: expanded from macro 'bswap64'
#define bswap64(x)      __bswap64(x)
/usr/include/x86/endian.h:80:27: note: expanded from macro '__bswap64'
        (__builtin_constant_p(x) ?      \
ocb.cc:122:26: note: to match this '('
/usr/include/sys/endian.h:61:20: note: expanded from macro 'bswap64'
#define bswap64(x)      __bswap64(x)
/usr/include/x86/endian.h:80:2: note: expanded from macro '__bswap64'
        (__builtin_constant_p(x) ?      \
ocb.cc:122:26: error: static declaration of '__builtin_constant_p' follows non-static declaration
         static inline uint64_t bswap64(uint64_t x) {
/usr/include/sys/endian.h:61:20: note: expanded from macro 'bswap64'
#define bswap64(x)      __bswap64(x)
/usr/include/x86/endian.h:80:3: note: expanded from macro '__bswap64'
        (__builtin_constant_p(x) ?      \
/usr/include/x86/endian.h:122:10: note: previous implicit declaration is here
        return (__bswap64_gen(_x));
/usr/include/x86/endian.h:70:16: note: expanded from macro '__bswap64_gen'
        (((__uint64_t)__bswap32((x) & 0xffffffff) << 32) | __bswap32((x) >> 32))
/usr/include/x86/endian.h:77:3: note: expanded from macro '__bswap32'
        (__builtin_constant_p(x) ?      \
1 warning and 2 errors generated.
Comment 4 Dimitry Andric freebsd_committer 2016-05-09 18:59:46 UTC
Created attachment 170155 [details]
Revised upstream patch, adding #include "config.h"

Ok, so the problem is that in ocb.cc, config.h was *still* not included, so while HAVE_DECL_BSWAP64 was properly detected by configure, the define didn't arrive in the right place...

Here's a revised upstream patch, adding #include "config.h" at the top of the file.
Comment 5 Dave Cottlehuber freebsd_committer 2016-06-29 11:10:15 UTC
Dimitry thanks I confirm this latest patch works for 10.3R and 11.0-CURRENT. https://github.com/skunkwerks/ports/commit/a9ec56f448f07d425b69031d6ddbd55d8b320220.patch
Comment 6 Benedict Reuschling freebsd_committer 2016-07-01 10:15:08 UTC
This also works for me, it compiles without error and mosh is running fine on my 11-CURRENT machine now. Thanks for the patch!
Comment 7 Michael Galati 2016-07-19 06:54:44 UTC
The patch from #4 also worked for me on stable/11 (r302977).  Thanks!
Comment 8 Dave Cottlehuber freebsd_committer 2016-08-08 08:14:26 UTC
This short diff silences the USES_OPENSSL deprecation warning from ports framework:

diff --git a/net/mosh/Makefile b/net/mosh/Makefile
index 969e31b..1153b7d 100644
--- a/net/mosh/Makefile
+++ b/net/mosh/Makefile
@@ -20,8 +20,7 @@ CONFIGURE_ARGS=       --with-utempter --without-ncurses
 INSTALL_TARGET=        install-strip
-USES=          autoreconf:autoconf ncurses perl5 pkgconfig
+USES=          autoreconf:autoconf ncurses perl5 pkgconfig ssl

 CONFLICTS_INSTALL=     mosh-0.[2-9].*

diff --git a/net/mosh/distinfo b/net/mosh/distinfo
index 146d26f..0c8a350 100644
--- a/net/mosh/distinfo
+++ b/net/mosh/distinfo
@@ -1,2 +1,3 @@
+TIMESTAMP = 1470643539
 SHA256 (mosh-1.2.5.tar.gz) = 1af809e5d747c333a852fbf7acdbf4d354dc4bbc2839e3afe5cf798190074be3
 SIZE (mosh-1.2.5.tar.gz) = 308857

zi@ AFAICT this BZ could be closed now, since r419315