Bug 230629

Summary: net/zerotier: fails to build with libc++ 7
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Dave Cottlehuber <dch>
Status: Closed FIXED    
Severity: Affects Only Me Keywords: needs-patch
Priority: --- Flags: bugzilla: maintainer-feedback? (dch)
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230630
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230631
Bug Depends on:    
Bug Blocks: 230355    
Attachments:
Description Flags
minimal fix none

Description Jan Beich freebsd_committer freebsd_triage 2018-08-14 21:10:12 UTC
$ poudriere jail -cj clang7 -a amd64 -v projects/clang700-import -m svn+https
$ poudriere testport -j clang7 net/zerotier
[...]
In file included from controller/EmbeddedNetworkController.cpp:40:
In file included from controller/EmbeddedNetworkController.hpp:39:
In file included from controller/../osdep/OSUtils.hpp:58:
controller/../ext/json/json.hpp:1360:9: error: static_assert failed "could not find from_json() method in T's namespace"
        static_assert(sizeof(BasicJsonType) == 0,
        ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~
controller/../ext/json/json.hpp:1375:16: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::call<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long, unsigned long, double, std::allocator, adl_serializer>, std::__1::basic_string_view<char, std::__1::char_traits<char> > >' requested here
        return call(j, val, priority_tag<1> {});
               ^
controller/../ext/json/json.hpp:6923:9: note: in instantiation of function template specialization 'nlohmann::detail::from_json_fn::operator()<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long, unsigned long, double, std::allocator, adl_serializer>, std::__1::basic_string_view<char, std::__1::char_traits<char> > >' requested here
        ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
        ^
controller/../ext/json/json.hpp:9678:36: note: in instantiation of function template specialization 'nlohmann::adl_serializer<std::__1::basic_string_view<char, std::__1::char_traits<char> >, void>::from_json<const nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long, unsigned long, double, std::allocator, adl_serializer> &, std::__1::basic_string_view<char, std::__1::char_traits<char> > >' requested here
        JSONSerializer<ValueType>::from_json(*this, ret);
                                   ^
controller/../ext/json/json.hpp:9939:16: note: in instantiation of function template specialization 'nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long, unsigned long, double, std::allocator, adl_serializer>::get<std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 0>' requested here
        return get<ValueType>();
               ^
/usr/include/c++/v1/string:875:29: note: in instantiation of function template specialization 'nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long, unsigned long, double, std::allocator, adl_serializer>::operator basic_string_view<std::__1::basic_string_view<char, std::__1::char_traits<char> >, 0>' requested here
        {__self_view __sv = __t; return assign(__sv);}
                            ^
controller/EmbeddedNetworkController.cpp:552:13: note: in instantiation of function template specialization 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::operator=<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long, unsigned long, double, std::allocator, adl_serializer>, void>' requested here
                                                                mid = (*member)["id"];
                                                                    ^
1 error generated.

http://package18.nyi.freebsd.org/data/headamd64PR230355-default/2018-08-11_19h01m06s/logs/errors/zerotier-1.2.10_1.log
Comment 1 Jan Beich freebsd_committer freebsd_triage 2018-08-14 21:11:36 UTC
Regressed by https://reviews.llvm.org/rL336132 and fixed by https://github.com/nlohmann/json/commit/8165707990e4. ZeroTierOne-1.2.10 bundles json-3.0.1, so you'll need to backport.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2018-08-14 21:50:16 UTC
Or maybe unbundle json, see ports r477206.
Comment 3 Dave Cottlehuber freebsd_committer freebsd_triage 2018-08-24 08:41:36 UTC
see https://reviews.freebsd.org/D16880 for patch.

jbeich: the json patch fails to build on 10.4R i386 without the newer libc++ & clang versions, can you re-test your clang update branch with my patch and see if you have those failures? thanks! 

Stack dump:
0.	Program arguments: /usr/bin/clang++ -cc1 -triple i386-unknown-freebsd10.4 -emit-obj -disable-free -disable-llvm-verifier -main-file-name OSUtils.cpp -mrelocation-model pic -pic-level 2 -pie-level 2 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -mconstructor-aliases -target-cpu i486 -gdwarf-2 -coverage-file /tmp/usr/ports/net/zerotier/work/ZeroTierOne-1.2.10/osdep/OSUtils.o -resource-dir /usr/bin/../lib/clang/3.4.1 -D NDEBUG -D ZT_BUILD_PLATFORM=7 -D ZT_BUILD_ARCHITECTURE=1 -D ZT_SOFTWARE_UPDATE_DEFAULT="disable" -D NDEBUG -D ZT_BUILD_PLATFORM=7 -D ZT_BUILD_ARCHITECTURE=1 -D ZT_SOFTWARE_UPDATE_DEFAULT="disable" -D ZT_TRACE -D ZT_BUILD_PLATFORM=7 -D ZT_BUILD_ARCHITECTURE=1 -D ZT_SOFTWARE_UPDATE_DEFAULT="disable" -internal-isystem /usr/include/c++/v1 -O2 -Wall -Wall -Wall -Werror -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /tmp/usr/ports/net/zerotier/work/ZeroTierOne-1.2.10 -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -pthread -stack-protector 1 -mstackrealign -fno-rtti -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o osdep/OSUtils.o -x c++ osdep/OSUtils.cpp 
1.	osdep/../ext/json/json.hpp:18807:52: current parser token 'value'
2.	osdep/../ext/json/json.hpp:18798:1: parsing namespace 'std'
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: i386-unknown-freebsd10.4
Thread model: posix
clang++: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
clang++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /tmp/OSUtils-fb8083.cpp
clang++: note: diagnostic msg: /tmp/OSUtils-fb8083.sh
clang++: note: diagnostic msg: 

********************
Comment 4 Jan Beich freebsd_committer freebsd_triage 2018-08-24 08:58:13 UTC
review D16880 builds fine with libc++ 7 (https://ptpb.pw/NQY4) and 10.4 i386 (https://ptpb.pw/oswu).

10.4 amd64 crashes (https://ptpb.pw/xHmd) due to -fPIE and can be worked around via USES=compiler:c++14-lang but the port doesn't respect CXX.
https://www.freebsd.org/doc/en/books/porters-handbook/dads-cc.html
Comment 5 Jan Beich freebsd_committer freebsd_triage 2018-08-24 09:02:44 UTC
Don't forget to drop BROKEN_powerpc64 after fixing ${CXX} issue as the port builds fine with USE_GCC (tested on amd64).
Comment 6 Jan Beich freebsd_committer freebsd_triage 2018-08-24 09:18:20 UTC
Created attachment 196495 [details]
minimal fix

If you don't want to update json try this patch instead.
Comment 7 Jan Beich freebsd_committer freebsd_triage 2018-08-24 09:25:42 UTC
Comment on attachment 196495 [details]
minimal fix

Nevermind. 10.4 amd64 hangs trying to compile service/OneService.cpp.
Comment 8 commit-hook freebsd_committer freebsd_triage 2018-08-24 19:13:26 UTC
A commit references this bug:

Author: dch
Date: Fri Aug 24 19:12:40 UTC 2018
New revision: 477979
URL: https://svnweb.freebsd.org/changeset/ports/477979

Log:
  net/zerotier: update 1.2.10 to 1.2.12

  also:

  - compile against libc++7 reported broken in PR230629
  - correct combined LICENSEs to match source code

  PR:		230629
  Reported by:	jbeich
  Approved by:	jrm
  Differential Revision:	https://reviews.freebsd.org/D16880

Changes:
  head/net/zerotier/Makefile
  head/net/zerotier/distinfo
  head/net/zerotier/files/patch-ext_json_json.hpp
  head/net/zerotier/files/patch-node_Packet.cpp
Comment 9 Dave Cottlehuber freebsd_committer freebsd_triage 2018-08-24 19:14:47 UTC
NB now marked as BROKEN for 10.4_i386 which only has ~ 2 months of official support anyway.