Created attachment 245744 [details] Git patch By default this port builds with the -march=native compiler flag. This is defined upstream. This setting makes sense for those who intend to use the software to mine but has virtually no benefit for those who simply want to use it as a node. However, it causes problems to whoever is building ports on a dedicated system to use on other systems with different CPUs. In that case the port may not run normally (a few seconds after the monerod service starts a monerod.core files is created and it up to roughly the size of the database and then the service quits). I fixed this issue by creating a new option PORTABLE where the user can choose whether to build portable binaries that will work other systems of the same architecture but different CPUs by removing the -march=native compiler flag. The flag is removed by applying a patch to the CMakeLists.txt upstream file similar to what is done to compile on OpenBSD. Probably this is not the most elegant solution but, with my very limited knowledge, that's the best I could come up with. If you have any suggestions on how to improve this I'd appreciate the input.
Thank you for catching that. As per ยง 13.14.4 Porter's Handbook, -march=native must not be enabled by default. Your patch is good, but please rename the option to NATIVE (this is the standard name in ports for such an option, you can omit NATIVE_DESC as it is provided in bsd.options.desc.mk) and make it enable -march=native with the flag being off by default. I think it might be possible to avoid the patch to CMakeLists.txt by using NATIVE_CMAKE_ON= -DARCH=native NATIVE_CMAKE_OFF= -DARCH=default but I'm not super familiar with cmake, so please check for yourself. Also please increment PORTREVISION by only 1 for each update.
Thanks for the feedback! Yeah, this issue almost drove me crazy because when building with 13.1 there was no problem. It only started to happen with 13.2 and it took me a long time to figure out what was going on. I'll investigate your suggestion and see if it works. If not, I'll adjust the option and apply the patch by default making NATIVE off the default.
Disable it permanently, if you want to have arch specific binaries you should utilize CPUTYPE variable.
Created attachment 245748 [details] Revised git patch With your help it was fast. Everything is working fine and this is a much more elegant solution.
(In reply to Daniel Engberg from comment #3) Hi Daniel. The current patch has the -march=native flag disabled by default. As it is one can enable it globally with CPUTYPE=native in the make.conf or just on this port via the NATIVE option. To me it seems an adequate solution. Is there any drawback that I'm not seeing? But I'm curious about one thing. Is there any option that can be set in the make.conf that overrides the -march=native flag set at the port level? Maybe it was just a coincidence, but the official FreeBSD package build of the previous version of this port ran fine on my system even though the port had the -march=native flag set by default.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=e994ff64ad7065e1927e6123c309586dcff99d38 commit e994ff64ad7065e1927e6123c309586dcff99d38 Author: Toni B <tonidasbabes88@gmail.com> AuthorDate: 2023-10-19 17:55:47 +0000 Commit: Robert Clausecker <fuz@FreeBSD.org> CommitDate: 2023-10-23 01:51:27 +0000 net-p2p/monero-cli: disable -march=native by default A new option NATIVE is provided to enable -march=native if desired. PR: 274595 net-p2p/monero-cli/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Thank you for your contribution. I have also applied a fix in a separate commit to unbreak the port on i386.