Bug 216213

Summary: databases/mongodb: fails to build with clang 4.0 (3 ports skipped)
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Jan Beich <jbeich>
Status: Closed FIXED    
Severity: Affects Only Me CC: ale, peter, riggs, tobik
Priority: --- Keywords: patch
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216016
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=215861
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216015
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216046
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216051
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216052
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216056
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216058
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216019
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216072
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216074
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216075
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216076
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216159
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216176
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216194
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216197
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216198
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216199
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216200
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216203
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216206
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216211
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216214
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216215
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216216
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216217
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216218
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216221
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216222
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216227
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216228
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216233
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216234
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216235
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216253
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216354
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216355
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216356
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216357
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216358
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216615
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216617
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216618
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216619
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216620
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216621
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216622
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216623
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216624
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216626
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216627
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216629
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216630
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216631
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216632
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216633
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216634
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216635
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216636
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216637
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216638
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216639
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216640
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216641
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216642
Bug Depends on:    
Bug Blocks: 216008    
Attachments:
Description Flags
mongodb.diff tobik: maintainer-approval? (ale)

Description Jan Beich freebsd_committer 2017-01-18 08:23:13 UTC
In file included from src/mongo/db/fts/fts_command.cpp:35:
In file included from src/mongo/db/fts/fts_util.h:37:
In file included from src/mongo/db/storage/record.h:35:
In file included from src/mongo/db/storage/extent.h:34:
src/mongo/db/structure/catalog/namespace.h:58:65: error: ordered comparison between pointer and zero ('const char *' and 'int')
        bool hasDollarSign() const { return strchr( buf , '$' ) > 0;  }
                                            ~~~~~~~~~~~~~~~~~~~ ^ ~
In file included from src/mongo/s/shard.cpp:33:
In file included from src/mongo/s/shard.h:35:
src/mongo/client/connpool.h:326:40: error: ordered comparison between pointer and zero ('mongo::DBClientBase *' and 'int')
        bool ok() const { return _conn > 0; }
                                 ~~~~~ ^ ~
In file included from src/mongo/s/shard.cpp:33:
src/mongo/s/shard.h:295:40: error: ordered comparison between pointer and zero ('mongo::DBClientBase *' and 'int')
        bool ok() const { return _conn > 0; }
                                 ~~~~~ ^ ~
In file included from src/mongo/db/dbcommands_generic.cpp:44:
In file included from src/mongo/db/db.h:33:
src/mongo/db/client.h:263:59: error: ordered comparison between pointer and zero ('mongo::Client *' and 'int')
    inline bool haveClient() { return currentClient.get() > 0; }
                                      ~~~~~~~~~~~~~~~~~~~ ^ ~

build log: http://sprunge.us/gicD
regressed by: https://github.com/llvm-mirror/clang/commit/4b6ad14285f3
Comment 1 Tobias Kortkamp freebsd_committer 2017-03-15 13:02:32 UTC
Created attachment 180846 [details]
mongodb.diff

Just ran into this when trying to build mongodb on 12.0-CURRENT.  With
a couple of patches mongodb can build again.

When building with LibreSSL there is an additional build failure:

build/freebsd/cc_cc/cxx_c++/ssl/use-system-pcre/use-system-snappy/use-system-v8/mongo/util/net/ssl_manager.o: In function `mongo::_mongoInitializerFunction_SSLManager(mongo::InitializerContext*)':
src/mongo/util/net/ssl_manager.cpp:(.text+0x35b): undefined reference to `FIPS_mode_set'

SConstruct checks for FIPS_mode_set (which base's OpenSSL has but
LibreSSL does not have) with base's OpenSSL in the include path and
incorrectly defines MONGO_HAVE_FIPS_MODE_SET.
Comment 2 Jan Beich freebsd_committer 2017-03-15 14:58:51 UTC
Comment on attachment 180846 [details]
mongodb.diff

> +post-patch-SSL-on:
> +.if ${SSL_DEFAULT:Mlibressl*}
> +	@${REINPLACE_CMD} 's/\([ ]*\).*MONGO_HAVE_FIPS_MODE_SET.*/\1pass/' \
> +		${WRKSRC}/SConstruct
> +.endif

I can't reproduce but maybe add USES+=localbase to fix SCons check instead.

> +-        bool ok() const { return _conn > 0; }
> ++        bool ok() const { return _conn != nullptr; }

GCC before 6.0 defaults to -std=gnu++98 but libc++ often leaks C++11 surrogates. Better take advantage of base r228918 instead.

In file included from src/mongo/s/shard.h:35:0,
                 from src/mongo/s/balancer_policy.h:37,
                 from src/mongo/s/balancer_policy.cpp:34:
src/mongo/client/connpool.h:326:9: warning: identifier 'nullptr' is a keyword in C++11 [-Wc++0x-compat]
         bool ok() const { return _conn != nullptr; }
         ^
src/mongo/client/connpool.h: In member function 'virtual bool mongo::ScopedDbConnection::ok() const':
src/mongo/client/connpool.h:326:43: error: 'nullptr' was not declared in this scope
         bool ok() const { return _conn != nullptr; }
                                           ^
Comment 3 Thomas Zander freebsd_committer 2017-04-30 14:04:14 UTC
Ping
Comment 4 commit-hook freebsd_committer 2017-07-20 09:14:32 UTC
A commit references this bug:

Author: jbeich
Date: Thu Jul 20 09:14:17 UTC 2017
New revision: 446250
URL: https://svnweb.freebsd.org/changeset/ports/446250

Log:
  databases/mongodb: unbreak with clang >= 4.0

  Convert ptr > 0 to ptr != 0. As semantics are similar no need for
  PORTREVISION bump.

  PR:		216213 220857
  Submitted by:	tobik (based on)
  Approved by:	maintainer timeout (4 months) + portmgr blanket
  Obtained from:	upstream (still under APACHE-2.0)

Changes:
  head/databases/mongodb/Makefile
  head/databases/mongodb/distinfo
Comment 5 Jan Beich freebsd_committer 2017-07-20 09:16:36 UTC
@tobik, thanks for the ping but you didn't respond to my review thus timeout. I've also found an upstream fix which seems to coincide with my opinion on NULL vs. nullptr.
Comment 6 commit-hook freebsd_committer 2017-07-20 09:18:38 UTC
A commit references this bug:

Author: jbeich
Date: Thu Jul 20 09:17:33 UTC 2017
New revision: 446252
URL: https://svnweb.freebsd.org/changeset/ports/446252

Log:
  MFH: r446250

  databases/mongodb: unbreak with clang >= 4.0

  Convert ptr > 0 to ptr != 0. As semantics are similar no need for
  PORTREVISION bump.

  PR:		216213 220857
  Submitted by:	tobik (based on)
  Approved by:	maintainer timeout (4 months) + portmgr blanket
  Obtained from:	upstream (still under APACHE-2.0)
  Approved by:	ports-secteam blanket

Changes:
_U  branches/2017Q3/
  branches/2017Q3/databases/mongodb/Makefile
  branches/2017Q3/databases/mongodb/distinfo
Comment 7 Jan Beich freebsd_committer 2017-07-20 09:20:01 UTC
*** Bug 220857 has been marked as a duplicate of this bug. ***
Comment 8 commit-hook freebsd_committer 2017-07-20 09:21:45 UTC
A commit references this bug:

Author: jbeich
Date: Thu Jul 20 09:21:03 UTC 2017
New revision: 446253
URL: https://svnweb.freebsd.org/changeset/ports/446253

Log:
  MFH: r446250

  databases/mongodb: unbreak with clang >= 4.0

  Convert ptr > 0 to ptr != 0. As semantics are similar no need for
  PORTREVISION bump.

  PR:		216213 220857
  Submitted by:	tobik (based on)
  Approved by:	maintainer timeout (4 months) + portmgr blanket
  Obtained from:	upstream (still under APACHE-2.0)
  Approved by:	ports-secteam blanket

Changes:
_U  branches/2017Q2/
  branches/2017Q2/databases/mongodb/Makefile
  branches/2017Q2/databases/mongodb/distinfo