git.iko.soy/typeable/nixpkgs
on master help sign in
dwarf-fortress.dfhack: enable 64-bit build, fix segfault
commit714cf7803c8c0ac3785b6486eeb30b79d7a10e17 authorNikolay Amiantov <ab@fmap.me> dateThu 24 Nov 2016, 02:51 (10 years ago) parent79ea04c
6 files changed+37−130
pkgs/games/dwarf-fortress/default.nix+1−3 pkgs/games/dwarf-fortress/dfhack/default.nix+14−6 pkgs/games/dwarf-fortress/dfhack/skip-ruby.patch+16 pkgs/games/dwarf-fortress/dfhack/use-system-libraries.patch−113 pkgs/games/dwarf-fortress/unfuck.nix+3 pkgs/games/dwarf-fortress/wrapper/default.nix+3−8
pkgs/games/dwarf-fortress/default.nix+1−3
@@ -3,15 +3,13 @@
33let
44 callPackage = pkgs.newScope self;
55 callPackage_i686 = pkgsi686Linux.newScope self;
6+ oldAbiStdenv = pkgs.overrideInStdenv pkgs.stdenv [ pkgs.useOldCXXAbi ];
67
78 self = rec {
89 dwarf-fortress-original = callPackage ./game.nix { };
910
1011 dfhack = callPackage ./dfhack {
1112 inherit (pkgs.perlPackages) XMLLibXML XMLLibXSLT;
12− protobuf = with pkgs; protobuf.override {
13− stdenv = overrideInStdenv stdenv [ useOldCXXAbi ];
14− };
1513 };
1614
1715 dwarf-fortress-unfuck = callPackage ./unfuck.nix { };
pkgs/games/dwarf-fortress/dfhack/default.nix+14−6
@@ -1,7 +1,6 @@
11{ stdenv, fetchgit, cmake, writeScriptBin
22, perl, XMLLibXML, XMLLibXSLT
33, zlib
4−, jsoncpp, protobuf, tinyxml
54}:
65
76let
@@ -15,6 +14,11 @@ let
1514 # revision of library/xml submodule
1615 xmlRev = "84f6e968a9ec5515f9dbef96b445e3fc83f83e8b";
1716
17+ arch =
18+ if stdenv.system == "x86_64-linux" then "64"
19+ else if stdenv.system == "i686-linux" then "32"
20+ else throw "Unsupported architecture";
21+
1822 fakegit = writeScriptBin "git" ''
1923 #! ${stdenv.shell}
2024 if [ "$*" = "describe --tags --long" ]; then
@@ -41,13 +45,17 @@ in stdenv.mkDerivation rec {
4145 inherit rev sha256;
4246 };
4347
44− patches = [ ./use-system-libraries.patch ];
48+ patches = [ ./skip-ruby.patch ];
4549
4650 nativeBuildInputs = [ cmake perl XMLLibXML XMLLibXSLT fakegit ];
47− # we can't use native Lua; upstream uses private headers
48− buildInputs = [ zlib jsoncpp protobuf tinyxml ];
51+ # We don't use system libraries because dfhack needs old C++ ABI.
52+ buildInputs = [ zlib ];
53+
54+ preBuild = ''
55+ export LD_LIBRARY_PATH="$PWD/depends/protobuf:$LD_LIBRARY_PATH"
56+ '';
4957
50− cmakeFlags = [ "-DEXTERNAL_TINYXML=ON" ];
58+ cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" ];
5159
5260 enableParallelBuilding = true;
5361
@@ -57,7 +65,7 @@ in stdenv.mkDerivation rec {
5765 description = "Memory hacking library for Dwarf Fortress and a set of tools that use it";
5866 homepage = "https://github.com/DFHack/dfhack/";
5967 license = licenses.zlib;
60− platforms = [ "i686-linux" ];
68+ platforms = [ "x86_64-linux" "i686-linux" ];
6169 maintainers = with maintainers; [ robbinch a1russell abbradar ];
6270 };
6371}
pkgs/games/dwarf-fortress/dfhack/skip-ruby.patchnew file+16
@@ -0,0 +1,16 @@
1+diff -ru3 dfhack-ae59b4f/plugins/ruby/CMakeLists.txt dfhack-ae59b4f-new/plugins/ruby/CMakeLists.txt
2+--- dfhack-ae59b4f/plugins/ruby/CMakeLists.txt 1970-01-01 03:00:01.000000000 +0300
3++++ dfhack-ae59b4f-new/plugins/ruby/CMakeLists.txt 2016-11-23 15:29:09.907286546 +0300
4+@@ -1,3 +1,4 @@
5++IF(FALSE)
6+ IF (APPLE)
7+ SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/osx${DFHACK_BUILD_ARCH}/libruby.dylib)
8+ SET(RUBYLIB_INSTALL_NAME "libruby.dylib")
9+@@ -48,6 +49,7 @@
10+ "482c1c418f4ee1a5f04203eee1cda0ef")
11+ ENDIF()
12+ ENDIF()
13++ENDIF()
14+
15+ IF (APPLE OR UNIX)
16+ SET(RUBYAUTOGEN ruby-autogen-gcc.rb)
pkgs/games/dwarf-fortress/dfhack/use-system-libraries.patchdeleted−113
@@ -1,113 +0,0 @@
1−diff -ru3 dfhack-ae59b4f/CMakeLists.txt dfhack-ae59b4f-new/CMakeLists.txt
2−--- dfhack-ae59b4f/CMakeLists.txt 1970-01-01 03:00:01.000000000 +0300
3−+++ dfhack-ae59b4f-new/CMakeLists.txt 2016-11-23 15:21:56.134538785 +0300
4−@@ -202,8 +202,6 @@
5− SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od")
6− ENDIF()
7−
8−-# use shared libraries for protobuf
9−-ADD_DEFINITIONS(-DPROTOBUF_USE_DLLS)
10− ADD_DEFINITIONS(-DLUA_BUILD_AS_DLL)
11−
12− if(APPLE)
13−@@ -297,10 +295,8 @@
14− endif()
15−
16− find_package(ZLIB REQUIRED)
17−-include_directories(depends/protobuf)
18− include_directories(depends/lua/include)
19− include_directories(depends/md5)
20−-include_directories(depends/jsoncpp)
21−
22− # Support linking against external tinyxml
23− # If we find an external tinyxml, set the DFHACK_TINYXML variable to "tinyxml"
24−diff -ru3 dfhack-ae59b4f/depends/CMakeLists.txt dfhack-ae59b4f-new/depends/CMakeLists.txt
25−--- dfhack-ae59b4f/depends/CMakeLists.txt 1970-01-01 03:00:01.000000000 +0300
26−+++ dfhack-ae59b4f-new/depends/CMakeLists.txt 2016-11-23 15:21:56.134538785 +0300
27−@@ -1,7 +1,6 @@
28− #list depends here.
29− add_subdirectory(lua)
30− add_subdirectory(md5)
31−-add_subdirectory(protobuf)
32−
33− # Don't build tinyxml if it's being externally linked against.
34− if(NOT TinyXML_FOUND)
35−@@ -9,7 +8,6 @@
36− endif()
37−
38− add_subdirectory(tthread)
39−-add_subdirectory(jsoncpp)
40− # build clsocket static and only as a dependency. Setting those options here overrides its own default settings.
41− OPTION(CLSOCKET_SHARED "Build clsocket lib as shared." OFF)
42− OPTION(CLSOCKET_DEP_ONLY "Build for use inside other CMake projects as dependency." ON)
43−diff -ru3 dfhack-ae59b4f/library/CMakeLists.txt dfhack-ae59b4f-new/library/CMakeLists.txt
44−--- dfhack-ae59b4f/library/CMakeLists.txt 1970-01-01 03:00:01.000000000 +0300
45−+++ dfhack-ae59b4f-new/library/CMakeLists.txt 2016-11-23 15:22:24.995519136 +0300
46−@@ -236,14 +236,14 @@
47−
48− ADD_CUSTOM_COMMAND(
49− OUTPUT ${PROJECT_PROTO_TMP_FILES}
50−- COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
51−+ COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
52− --cpp_out=dllexport_decl=DFHACK_EXPORT:${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
53− ${PROJECT_PROTOS}
54− COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/depends/copy-if-different.pl
55− ${PROJECT_PROTO_TMP_FILES}
56− ${CMAKE_CURRENT_SOURCE_DIR}/proto/
57− COMMENT "Generating core protobufs"
58−- DEPENDS protoc-bin ${PROJECT_PROTOS}
59−+ DEPENDS ${PROJECT_PROTOS}
60− )
61−
62− ADD_CUSTOM_TARGET(generate_proto_core DEPENDS ${PROJECT_PROTO_TMP_FILES})
63−diff -ru3 dfhack-ae59b4f/plugins/CMakeLists.txt dfhack-ae59b4f-new/plugins/CMakeLists.txt
64−--- dfhack-ae59b4f/plugins/CMakeLists.txt 1970-01-01 03:00:01.000000000 +0300
65−+++ dfhack-ae59b4f-new/plugins/CMakeLists.txt 2016-11-23 15:22:47.291503960 +0300
66−@@ -60,7 +60,7 @@
67−
68− ADD_CUSTOM_COMMAND(
69− OUTPUT ${PROJECT_PROTO_TMP_FILES}
70−- COMMAND protoc-bin -I=${dfhack_SOURCE_DIR}/library/proto/
71−+ COMMAND protoc -I=${dfhack_SOURCE_DIR}/library/proto/
72− -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
73− --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/tmp/
74− ${PROJECT_PROTOS}
75−@@ -68,7 +68,7 @@
76− ${PROJECT_PROTO_TMP_FILES}
77− ${CMAKE_CURRENT_SOURCE_DIR}/proto/
78− COMMENT "Generating plugin protobufs"
79−- DEPENDS protoc-bin ${PROJECT_PROTOS}
80−+ DEPENDS ${PROJECT_PROTOS}
81− )
82− ADD_CUSTOM_TARGET(generate_proto DEPENDS ${PROJECT_PROTO_TMP_FILES})
83−
84−diff -ru3 dfhack-ae59b4f/plugins/ruby/CMakeLists.txt dfhack-ae59b4f-new/plugins/ruby/CMakeLists.txt
85−--- dfhack-ae59b4f/plugins/ruby/CMakeLists.txt 1970-01-01 03:00:01.000000000 +0300
86−+++ dfhack-ae59b4f-new/plugins/ruby/CMakeLists.txt 2016-11-23 15:29:09.907286546 +0300
87−@@ -1,3 +1,4 @@
88−+IF(FALSE)
89− IF (APPLE)
90− SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/osx${DFHACK_BUILD_ARCH}/libruby.dylib)
91− SET(RUBYLIB_INSTALL_NAME "libruby.dylib")
92−@@ -48,6 +49,7 @@
93− "482c1c418f4ee1a5f04203eee1cda0ef")
94− ENDIF()
95− ENDIF()
96−+ENDIF()
97−
98− IF (APPLE OR UNIX)
99− SET(RUBYAUTOGEN ruby-autogen-gcc.rb)
100−diff -ru3 dfhack-ae59b4f/plugins/stockpiles/CMakeLists.txt dfhack-ae59b4f-new/plugins/stockpiles/CMakeLists.txt
101−--- dfhack-ae59b4f/plugins/stockpiles/CMakeLists.txt 1970-01-01 03:00:01.000000000 +0300
102−+++ dfhack-ae59b4f-new/plugins/stockpiles/CMakeLists.txt 2016-11-23 15:21:56.134538785 +0300
103−@@ -33,8 +33,8 @@
104− #Generate sources from our proto files and store them in the source tree
105− ADD_CUSTOM_COMMAND(
106− OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
107−-COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
108−-DEPENDS protoc-bin ${PROJECT_PROTOS}
109−+COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
110−+DEPENDS ${PROJECT_PROTOS}
111− )
112−
113− IF(WIN32)
pkgs/games/dwarf-fortress/unfuck.nix+3
@@ -30,6 +30,9 @@ stdenv.mkDerivation {
3030
3131 enableParallelBuilding = true;
3232
33+ # Breaks dfhack because of inlining.
34+ hardeningDisable = [ "fortify" ];
35+
3336 passthru.dfVersion = "0.43.05";
3437
3538 meta = with stdenv.lib; {
pkgs/games/dwarf-fortress/wrapper/default.nix+3−8
@@ -17,17 +17,12 @@ let
1717
1818 env = buildEnv {
1919 name = "dwarf-fortress-env-${dwarf-fortress-original.dfVersion}";
20+
2021 paths = pkgs;
22+ pathsToLink = [ "/" "/hack" ];
2123 ignoreCollisions = true;
24+
2225 postBuild = lib.optionalString enableDFHack ''
23− # #4621
24− if [ -L "$out/hack" ]; then
25− rm $out/hack
26− mkdir $out/hack
27− for i in ${dfhack}/hack/*; do
28− ln -s $i $out/hack
29− done
30− fi
3126 rm $out/hack/symbols.xml
3227 substitute ${dfhack}/hack/symbols.xml $out/hack/symbols.xml \
3328 --replace $(cat ${dwarf-fortress-original}/hash.md5.orig) \