Bug 248540

Summary: games/minetest Minetest 5.3.0 fails to compile with multiple issues
Product: Ports & Packages Reporter: Patrick McMunn <doctorwhoguy>
Component: Individual Port(s)Assignee: Dmitry Marakasov <amdmi3>
Status: Closed FIXED    
Severity: Affects Only Me CC: wolfi
Priority: --- Flags: bugzilla: maintainer-feedback? (amdmi3)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
port config options
none
My /etc/make.conf
none
log of failed build none

Description Patrick McMunn 2020-08-08 20:27:59 UTC
While trying to troubleshoot this issue, I ran into a few other problems as well. The main problem is that it failed to link to the bundled jsoncpp for the server component. I edited the Makefile so it would link to the system jsoncpp, and it compiled successfully but did not run. However, in order to finish compiling, I also had to disable NLS because the installation failed due to the missing translation files. And that was just trying to compile the server. Enabling the client introduced a different compilation failure.

Anyway, one thing at a time. I'm running 12.1-STABLE r363327. The main issue I ran into while trying to compile the server is as follows:

ld: error: undefined symbol: Json::Value::operator=(Json::Value&&)
>>> referenced by mods.cpp
>>>               src/CMakeFiles/minetestserver.dir/content/mods.cpp.o:(ModMetadata::save(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
>>> referenced by mods.cpp
>>>               src/CMakeFiles/minetestserver.dir/content/mods.cpp.o:(ModMetadata::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
>>> referenced by c_content.cpp
>>>               src/CMakeFiles/minetestserver.dir/script/common/c_content.cpp.o:(read_json_value(lua_State*, Json::Value&, int, unsigned char))
>>> referenced by c_content.cpp
>>>               src/CMakeFiles/minetestserver.dir/script/common/c_content.cpp.o:(read_json_value(lua_State*, Json::Value&, int, unsigned char))
>>> referenced by c_content.cpp
>>>               src/CMakeFiles/minetestserver.dir/script/common/c_content.cpp.o:(read_json_value(lua_State*, Json::Value&, int, unsigned char))
>>> referenced by c_content.cpp
>>>               src/CMakeFiles/minetestserver.dir/script/common/c_content.cpp.o:(read_json_value(lua_State*, Json::Value&, int, unsigned char))
>>> referenced by l_util.cpp
>>>               src/CMakeFiles/minetestserver.dir/script/lua_api/l_util.cpp.o:(ModApiUtil::l_parse_json(lua_State*))
>>> referenced by convert_json.cpp
>>>               src/CMakeFiles/minetestserver.dir/convert_json.cpp.o:(fetchJsonValue(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*))
>>> referenced by convert_json.cpp
>>>               src/CMakeFiles/minetestserver.dir/convert_json.cpp.o:(fastWriteJson(Json::Value const&))
>>> referenced by remoteplayer.cpp
>>>               src/CMakeFiles/minetestserver.dir/remoteplayer.cpp.o:(RemotePlayer::serializeExtraAttributes(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&))
>>> referenced 41 more times
>>> did you mean: Json::Value::operator=(Json::Value)
>>> defined in: lib/jsoncpp/libjsoncpp.a(jsoncpp.cpp.o)

ld: error: undefined symbol: Json::Value::operator=(Json::Value const&)
>>> referenced by c_content.cpp
>>>               src/CMakeFiles/minetestserver.dir/script/common/c_content.cpp.o:(read_json_value(lua_State*, Json::Value&, int, unsigned char))
>>> referenced by c_content.cpp
>>>               src/CMakeFiles/minetestserver.dir/script/common/c_content.cpp.o:(read_json_value(lua_State*, Json::Value&, int, unsigned char))
>>> referenced by serverlist.cpp
>>>               src/CMakeFiles/minetestserver.dir/serverlist.cpp.o:(ServerList::getOnline())
>>> referenced by serverlist.cpp
>>>               src/CMakeFiles/minetestserver.dir/serverlist.cpp.o:(ServerList::serializeJson(std::__1::vector<Json::Value, std::__1::allocator<Json::Value> > const&))
>>> referenced by serverlist.cpp
>>>               src/CMakeFiles/minetestserver.dir/serverlist.cpp.o:(std::__1::vector<Json::Value, std::__1::allocator<Json::Value> >::insert(std::__1::__wrap_iter<Json::Value const*>, Json::Value const&))
>>> referenced by tool.cpp
>>>               src/CMakeFiles/minetestserver.dir/tool.cpp.o:(ToolGroupCap::toJson(Json::Value&) const)
>>> referenced by tool.cpp
>>>               src/CMakeFiles/minetestserver.dir/tool.cpp.o:(ToolCapabilities::serializeJson(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const)
>>> referenced by tool.cpp
>>>               src/CMakeFiles/minetestserver.dir/tool.cpp.o:(ToolCapabilities::serializeJson(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const)

ld: error: undefined symbol: Json::StreamWriterBuilder::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
>>> referenced by convert_json.cpp
>>>               src/CMakeFiles/minetestserver.dir/convert_json.cpp.o:(fastWriteJson(Json::Value const&))

ld: error: undefined symbol: Json::ValueIteratorBase::deref()
>>> referenced by serverlist.cpp
>>>               src/CMakeFiles/minetestserver.dir/serverlist.cpp.o:(ServerList::getOnline())
>>> referenced by tool.cpp
>>>               src/CMakeFiles/minetestserver.dir/tool.cpp.o:(ToolCapabilities::deserializeJson(std::__1::basic_istream<char, std::__1::char_traits<char> >&))
>>> referenced by tool.cpp
>>>               src/CMakeFiles/minetestserver.dir/tool.cpp.o:(ToolCapabilities::deserializeJson(std::__1::basic_istream<char, std::__1::char_traits<char> >&))
c++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/games/minetest
*** Error code 1

Stop.
make: stopped in /usr/ports/games/minetest
Comment 1 Patrick McMunn 2020-08-12 21:12:58 UTC
I tried building Minetest manually to see if I could troubleshoot the issue, and it still occurred. So I also filed an upstream bug report: https://github.com/minetest/minetest/issues/10289 .
Comment 2 Dmitry Marakasov freebsd_committer freebsd_triage 2020-08-23 11:16:18 UTC
I cannot reproduce any of the problems. It builds fine both with and without NLS both with and without system jsoncpp present. Please attach your options configuration, make.conf and full build log.
Comment 3 Patrick McMunn 2020-08-24 03:58:24 UTC
Created attachment 217472 [details]
port config options

For the build log I'm attaching, I just ran rmconfig and then reset to default options.
Comment 4 Patrick McMunn 2020-08-24 04:10:00 UTC
Created attachment 217473 [details]
My /etc/make.conf
Comment 5 Patrick McMunn 2020-08-24 04:15:31 UTC
Created attachment 217474 [details]
log of failed build
Comment 6 Patrick McMunn 2020-08-24 04:25:42 UTC
I attached the requested information. But in the process of getting the requested information ready to attach, I noticed something. When I ran rmconfig and recreated the port config options, they were not the defaults as I originally thought. My make.conf set some default options which, in the case of Minetest, enabled all of the database options which are normally disabled in a default configuration.

So I reset the options to the actual defaults with all the database options disabled. Minetest built just fine with no problem. I haven't tried the database options one at a time or any combination other than all of them at once, but apparently at least one of the database options is causing the problem.

Even after disabling the database options and achieving a successful build, one of my earlier finds still holds true. If the client option is disabled and only the server is built, but NLS is enabled, then Minetest will build successfully but fail to install due to missing minetest.mo files.
Comment 7 Patrick McMunn 2020-08-24 04:38:49 UTC
One last observation. I tested all the database backends. The build will fail if either PosGreSQL or SpatialIndex is enabled. LevelDB and Redis work, and Minetest will buid if either of those is enabled.
Comment 8 Patrick McMunn 2020-08-25 02:02:12 UTC
I had time to do some further testing. Minetest will build with the PostGreSQL and SpatialIndex optons enabled if -DENABLE_SYSTEM_JSONCPP=1 is passed to cmake. There is a note in the port's Makefile referencing cmake/Modules/FindJson.cmake which states that using the system jsoncpp "May cause segfaults and other memory errors!". I brought this up with upstream, and he said "That warning text is old and should probably be removed.". So it looks like enabling the system jsoncpp should be safe and will avoid these compilation errors.
Comment 9 Jonas Rinner 2020-11-27 10:36:33 UTC
I can confirm that this bug still happens for me.

This is on a newly installed RELEASE system on the latest patch level (FreeBSD 12.2-RELEASE-p0), with a fresh copy of the ports tree fetched.

First I run `make config` and activate the pgsql feature. Then I install the build-depends-list and run-depends-list via pkg (latest or quarterly doesn't make a difference).

Running `make` after that will result in the exact same error as in comment #0.
Comment 10 commit-hook freebsd_committer freebsd_triage 2020-12-03 16:18:28 UTC
A commit references this bug:

Author: amdmi3
Date: Thu Dec  3 16:18:24 UTC 2020
New revision: 556909
URL: https://svnweb.freebsd.org/changeset/ports/556909

Log:
  Fix multiple build problems

  - Remove bundled jsoncpp, it may conflict with system one
  - Fix plist (nls files are installed when both CLIENT and NLS are enabled)
  - Add patch to fix include order which causes build failure in presence of ${LOCALBASE}/include/event.h

  PR:		248540
  Reported by:	doctorwhoguy@gmail.com, wolfi@karpador.xyz

Changes:
  head/games/minetest/Makefile
  head/games/minetest/files/patch-src_CMakeLists.txt
  head/games/minetest/pkg-plist
Comment 11 Dmitry Marakasov freebsd_committer freebsd_triage 2020-12-03 18:09:15 UTC
Fix for two described problems committed as well as for another one I've ran into during testing. Please confirm.
Comment 12 Jonas Rinner 2020-12-03 19:22:54 UTC
I can confirm that I can compile it correctly now (setting PGSQL to on, CLIENT to off, which is what I need on my server). The postgres connection works as well, I just tested it.