Compiling older versions of crawl on newer linux

Hi all,
I’m trying to compile the ancient version 0.18.2 on more recent Linux versions, but I’m running into problems, and since I’m not a C++ programmer at all, it’s got me stumped. I’ve even tried spinning up older Linux releases like Debian 10 to compile there, since I would assume the various libraries are also older. This is me just doing a full install using the directions in the INSTALL file. I’m also looking at the versions in the submodules, maybe there’s newer stuff in there screwing up the build? I notice that each release just refers to the latest submodule release, which might not be a good strategy going forward, even if that code doesn’t change.

I’m also looking to compile just the console version, no tiles or anything like that. Any hint or suggestions on what I should do would be helpful.

cat /etc/os-release
PRETTY_NAME=“Debian GNU/Linux 10 (buster)”
NAME=“Debian GNU/Linux”
VERSION_ID=“10”
VERSION=“10 (buster)”
VERSION_CODENAME=buster

$ git branch

  • 0.18.2
    0.19.2
    0.29.1
    master

john@clarence-home:~/tmp/crawl/crawl-ref/source$ make

  • If you experience any problems building Crawl, please take a second look
  • at INSTALL.txt: the solution to your problem just might be in there!
    • rebuilding crawl: new build flags or prefix
      TRACK_CFLAGS = x86_64-linux-gnu-gcc x86_64-linux-gnu-g++ -O2 -pipe -Wall -Wformat-security -Wundef L
      OLD_CFLAGS = #EOL
      util/art-data.pl
      Generating art-data.h
      Generating art-enum.h
      Generating dc-unrand.txt
      Generating tiledef-unrand.cc
      GEN config.h
      GEN mon-mst.h
      make -C rltiles all ARCH=x86_64-linux-gnu TILES=
      make[1]: Entering directory ‘/home/john/tmp/crawl/crawl-ref/source/rltiles’
    • rebuilding tilegen: new build flags or prefix
      HOSTCXX tool/tile_colour.o
      HOSTCXX tool/tile.o
      tool/tile.cc: In member function ‘void tile::copy(const tile&)’:
      tool/tile.cc:294:76: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of ty]
      memcpy(m_pixels, img.m_pixels, m_width * m_height * sizeof(tile_colour));
      ^
      In file included from tool/tile.h:4,
      from tool/tile.cc:1:
      tool/tile_colour.h:28:7: note: ‘class tile_colour’ declared here
      class tile_colour
      ^~~~~~~~~~~
      HOSTCXX tool/tile_page.o
      HOSTCXX tool/tile_list_processor.o
      HOSTCXX tool/main.o
      HOSTLINK tool/tilegen.elf
      GEN tiledef-main.h
      GEN tiledef-dngn.h
      GEN tiledef-floor.h
      GEN tiledef-wall.h
      GEN tiledef-feat.h
      GEN tiledef-player.h
      GEN tiledef-gui.h
      GEN tiledef-icons.h
      make[1]: Leaving directory ‘/home/john/tmp/crawl/crawl-ref/source/rltiles’
      CXX ability.o
      In file included from ability.cc:28:
      describe.h:57:36: error: ‘function’ has not been declared
      bool describe_item(item_def &item, function<void (string&)> fixup_desc = nullptr);
      ^~~~~~~~
      ^~~~~~~~
      describe.h:57:44: error: expected ‘,’ or ‘…’ before ‘<’ token
      bool describe_item(item_def &item, function<void (string&)> fixup_desc = nullptr);
      ^
      In file included from directn.h:10,
      from ability.cc:29:
      mon-info.h:372:9: error: ‘function’ does not name a type; did you mean ‘union’?
      typedef function<vector (const monster_info& mi)> (desc_filter);
      ^~~~~~~~
      union
      In file included from ability.cc:29:
      directn.h:55:5: error: ‘desc_filter’ does not name a type; did you mean ‘message_filter’?
      desc_filter get_desc_func; // Function to add relevant descriptions
      ^~~~~~~~~~~
      message_filter
      directn.h:94:5: error: ‘desc_filter’ does not name a type; did you mean ‘message_filter’?
      desc_filter get_desc_func;
      ^~~~~~~~~~~
      message_filter
      directn.h: In constructor ‘direction_chooser_args::direction_chooser_args()’:
      directn.h:109:9: error: class ‘direction_chooser_args’ does not have any field named ‘get_desc_func’
      get_desc_func(nullptr),
      ^~~~~~~~~~~~~
      In file included from monster.h:6,
      from env.h:8,
      from dungeon.h:14,
      from ability.cc:30:
      spl-util.h: At global scope:
      spl-util.h:97:9: error: ‘function’ does not name a type; did you mean ‘union’?
      typedef function<int (coord_def where)> cell_func;
      ^~~~~~~~
      union
      spl-util.h:98:9: error: ‘function’ does not name a type; did you mean ‘union’?
      typedef function<int (monster* mon)> monster_func;
      ^~~~~~~~
      union
      spl-util.h:103:24: error: ‘cell_func’ was not declared in this scope
      int apply_area_visible(cell_func cf, const coord_def& where);
      ^~~~~~~~~
      spl-util.h:103:24: note: suggested alternative: ‘cloud_func’
      int apply_area_visible(cell_func cf, const coord_def& where);
      ^~~~~~~~~
      cloud_func

I haven’t tried this specific thing but I’d guess what could be happening here is that this code needs a specific c++ standard version to compile, maybe exactly c++11?. function should be defined in modern-ish c++ with #include <functional> but maybe it was happening in a different way back then. I’m not 100% sure which standard 0.18 would be on, but it does still compile on servers with c++11, so try forcing -std=c++11 somehow? (This will require editing the Makefile I think, add it to CFLAGS perhaps.)

The main Makefile already has that defined…

Which C++ standard to support

STDFLAG = -std=c++11

CFOTHERS := -pipe $(EXTERNAL_FLAGS)

so now I’m trying to spin up docker to try and run compiles inside there. God that’s sucking big time too. I’ve been looking at other threads on this as well, like this one:

I-cannot-post-links//crawl.develz.org/tavern/viewtopic.php?f=9&t=26353
#Request for help getting old versions to compile on Mint 19 • View topic • The Tavern

But this one might be the answer:

https://crawl.develz.org/mantis/view.php?id=10926

I just have to add
#include
in a bunch of source files. We will see.

This patch does the trick and lets it compile again. I wish someone would release a 0.18.3 with this patch.

$ git diff
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h
index 3fc209874b…eabe60a25c 100644
— a/crawl-ref/source/AppHdr.h
+++ b/crawl-ref/source/AppHdr.h
@@ -21,6 +21,11 @@

#include “platform.h”
#include <stdint.h>
+
+
+/* hack to compile older Crawl on newer linux */
+#include
+
namespace std {}
using namespace std;

diff --git a/crawl-ref/source/domino.h b/crawl-ref/source/domino.h
index 57b2250903…5c8ff6dbdf 100644
— a/crawl-ref/source/domino.h
+++ b/crawl-ref/source/domino.h
@@ -48,6 +48,7 @@
#include
#include <stdint.h>
#include
+#include

namespace domino {

Blech, my initial patch was corrupted when I pasted it in here. The basic idea was to just put an:

#include

into AppHdr.h, but I did re-work the patch to just put it into all the various .cc files which needed it. Some needed it earlier, some later. Quite annoying .

For domino.h I needed to add

#include

at the end of all the other <> incoludes.

but now it still blows up on me when I go down a level, I get a crash like this:

#####.##/home/john/.crawl/…/dat/des/portals/bailey.des:368: Couldn’t find a map for bailey_axe

so I’m obviously in a strange state here. I thought I had purged all the various crawl newer version files and such, but who knows? Time to chase this down some more with better debugging.

This is version 0.18.2 with my patches, on Debian 11 bullseye. using gcc 10.2.1 and now trying to compile using clang:

export GCC=clang
export GXX=clang++
make -j 16

$ ./crawl --version
Crawl version 0.18.3
Save file version 34.169
Compiled with GCC 10.2.1 20210110 on Sep 5 2023 at 17:15:24
Build platform: x86_64-linux-gnu
Platform: x86_64-linux-gnu
CFLAGS: -O2 -pipe -Wall -Wformat-security -Wundef -Wno-array-bounds -Wno-format-zero-length -Wmissing-declarations -Wredundant-decls -Wno-parentheses -Wwrite-strings -Wshadow -pedantic -Wuninitialized -Iutil -I. -isystem /usr/include/lua5.1 -Irltiles -DWIZARD -DASSERTS -DCLUA_BINDINGS -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
LDFLAGS: -rdynamic -fuse-ld=gold -O2

$ git diff 0.18.2 0.18.3
warning: refname '0.18.2' is ambiguous.
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h
index 3fc209874b..eabe60a25c 100644
--- a/crawl-ref/source/AppHdr.h
+++ b/crawl-ref/source/AppHdr.h
@@ -21,6 +21,11 @@

 #include "platform.h"
 #include <stdint.h>
+
+
+/* hack to compile older Crawl on newer linux */
+#include <functional>
+
 namespace std {}
 using namespace std;

diff --git a/crawl-ref/source/domino.h b/crawl-ref/source/domino.h
index 57b2250903..5c8ff6dbdf 100644
--- a/crawl-ref/source/domino.h
+++ b/crawl-ref/source/domino.h
@@ -48,6 +48,7 @@
 #include <set>
 #include <stdint.h>
 #include <vector>
+#include <ostream>

 namespace domino {

...


is what I keep trying to post, I'm a markdown moron obviously.   Sorry for the noise all!
1 Thank

Thanks! After looking at this a bit more I believe this is the specific patch that fixed this build issue (which is dependent on gcc version, not standard): https://github.com/crawl/crawl/commit/5e19f30c998b7066edc6c7e0037d5f9f703ec6f5

Edit: I think that also for the ostream include, this is likely the commit that (indirectly) caused it to get included (via coord-def.h, which is included in a chain from AppHdr.h): Fix includes for some commonly used header files · crawl/crawl@35ab613 · GitHub

Possibly this could be worth backporting. I’d guess that it’s entirely possible to spin up a vm/docker instance with that old gcc version, but at this point you’d have to go back very far or do it explicitly.

Edit: also, if you are still getting the bailey error, you should reset the des cache (which I couldn’t 100% say where it is on linux, but near wherever your saves are).

I have backported the two commits I found as well as a macos-specific build fix to stone_soup-0.18 as a sort of proof of concept. I haven’t actually tested this on gcc (if anyone does, feel free to update this thread), but I have verified that console builds and runs on relatively current macos in clang.

(The contribs have definitely been updated since then, so I suspect that local tiles is unlikely to build without a bunch more work. Webtiles builds but crashes immediately; I’d guess this is mac-specific though.)

1 Thank