Bug 265210 - databases/mongodb50: Potential improvements
Summary: databases/mongodb50: Potential improvements
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Daniel Engberg
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2022-07-14 11:00 UTC by Daniel Engberg
Modified: 2023-01-20 09:52 UTC (History)
3 users (show)

See Also:
ronald-lists: maintainer-feedback+


Attachments
Patch for mongodb50 (6.02 KB, patch)
2022-08-04 22:06 UTC, Daniel Engberg
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Engberg freebsd_committer freebsd_triage 2022-07-14 11:00:35 UTC
Looking at Gentoo's repo it seems like we can rely on a few more system libraries?
https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mongodb/mongodb-5.0.5-r2.ebuild

"13.9. Respect CFLAGS" - Porters Handbook
Currently the build somewhat overrides CPUFLAGS (mtune at least) which isn't optimal, https://github.com/mongodb/mongo/blob/r5.0.9/SConstruct#L2530
Comment 1 Fernando Apesteguía freebsd_committer freebsd_triage 2022-07-18 06:41:26 UTC
^Triage: reporter is committer, assign accordinly.
Comment 2 Ronald Klop 2022-07-28 16:41:31 UTC
- no patch
- too generic subject
- no real problem mentioned
Comment 3 Daniel Engberg freebsd_committer freebsd_triage 2022-08-04 22:06:22 UTC
Created attachment 235682 [details]
Patch for mongodb50

Hi Roland,

First if of all there are some concerns attached to this topic, 
https://docs.freebsd.org/en/books/porters-handbook/book/#bundled-libs explains those.

So far it seems like we can at least use these (compiles fine on my 13.1-RELEASE test box and in 12.3-RELEASE using Poudriere both being amd64):

--use-system-boost	--> devel/boost-libs	(patches obtained from Gentoo [1])
--use-system-stemmer	--> textproc/snowballstemmer
--use-system-libunwind	--> devel/libunwind
--use-system-yaml	--> devel/yaml-cpp
--use-system-zstd	--> archivers/zstd

abseil doesn't work out of the box but I haven't looked into why ( /usr/ports/devel/abseil )
Using system ICU ( devel/icu ) would be very nice and save quite a bit of time but Gentoo has this note [2] Fairly old version though so I'm not sure if its still valid.
I've also removed the mtune option on amd64 as it potentially overrides CPUTYPE set by ports framework

References: 
[1] https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mongodb/files/mongodb-4.4.1-boost.patch
    https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mongodb/files/mongodb-5.0.2-boost-1.79.patch
[2] https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mongodb/mongodb-5.0.5.ebuild#n110

I'm not a user of mongodb so it would be nice if you could at least verify this.

Best regards,
Daniel
Comment 4 Ronald Klop 2022-08-08 09:27:38 UTC
(In reply to Daniel Engberg from comment #3)
Hi Daniel,

I'm not that impressed by that part of the porters handbook. Although I understand the general message of it. In this case upstream is pretty responsive to security issues. And using the bundled code makes sure we use more of the guarantees of the QA of the mongodb company because we keep it closer to the binaries released by MongoDB. (What if mongodb makes an important change in a third party library? Or a change in their own code to be compatible with a specific bundled library version which is incompatible with our version of that library?)

Plus Mongodb is often used on a standalone server/jail/VM so in practice sharing these libraries does not give much gain in resource sharing.

Having said that. I'm ok with your patch if your really think it will benefit anybody.
Comment 5 Ronald Klop 2022-08-08 09:30:27 UTC
BTW: I compile tested the patch on aarch64/14-current also. It builds fine.
Comment 6 commit-hook freebsd_committer freebsd_triage 2022-08-15 20:28:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cdca8109d6d09b7f7b8ddcba55f9e1eb09332161

commit cdca8109d6d09b7f7b8ddcba55f9e1eb09332161
Author:     Daniel Engberg <diizzy@FreeBSD.org>
AuthorDate: 2022-08-15 20:23:37 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2022-08-15 20:27:40 +0000

    databases/mongodb50: Use more external libraries

    Make use of following libraries in tree:
    devel/boost-libs
    textproc/snowballstemmer
    devel/libunwind
    devel/yaml-cpp
    archivers/zstd

    While at it remove mtune option on amd64 as it potentially overrides
    CPUTYPE set by ports framework

    References:
    [1] https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mongodb/files/mongodb-4.4.1-boost.patch
        https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mongodb/files/mongodb-5.0.2-boost-1.79.patch

    PR:             265210
    Reviewed by:    Ronald Klop <ronald-lists@klop.ws> (maintainer)

 databases/mongodb50/Makefile                       | 24 +++++++-
 databases/mongodb50/files/patch-SConstruct         |  9 +++
 .../mongodb50/files/patch-boost-179-compat (new)   | 70 ++++++++++++++++++++++
 .../mongodb50/files/patch-boost-179-link-fix (new) | 21 +++++++
 4 files changed, 122 insertions(+), 2 deletions(-)
Comment 7 Ronald Klop 2022-08-19 09:19:26 UTC
(In reply to commit-hook from comment #6)
thanks for your work on this
Comment 8 Ronald Klop freebsd_committer freebsd_triage 2023-01-20 09:52:56 UTC
In bug #269024 I'm handling an issue with the upgrade to boost 1.81.0.
I don't have the time and interest to debug mongodb+boost. I expect upstream to do that work with paid developers.
For now I'm going back to compiling the in-source boost version of MongoDB.
Just a note here to let you know. If somebody wants to create a new patch please attach it to the other issue.