Skip to content

Instantly share code, notes, and snippets.

@loathingKernel
Created October 31, 2017 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loathingKernel/942963c440954f6a9a689a36c9e2446b to your computer and use it in GitHub Desktop.
Save loathingKernel/942963c440954f6a9a689a36c9e2446b to your computer and use it in GitHub Desktop.
Make The Dark Mod compile on x64 Arch
#!/usr/bin/sh
export CC="ccache gcc"
export CXX="ccache g++"
export CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt -m32"
export CXXFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt -m32"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -m32"
export PKG_CONFIG_PATH='/usr/lib32/pkgconfig'
echo "Building Boost"
prevwd=$(pwd)
cd ../boost_1_57_0
./bootstrap.sh --with-toolset=gcc
./b2 --clean-all
./b2 variant=release \
debug-symbols=off \
cflags="${CPPFLAGS} ${CFLAGS} -fPIC -O3" \
cxxflags="${CPPFLAGS} ${CXXFLAGS} -std=c++11 -fPIC -O3" \
linkflags="${LDFLAGS}" \
--with-{chrono,date_time,filesystem,program_options,regex,system,thread} \
threading=multi runtime-link=static link=static toolset=gcc address-model=32 release
for i in chrono date_time filesystem program_options regex system thread; do
cp stage/lib/libboost_$i.a "$prevwd"/linux/boost/lib/
done
cd "$prevwd"
#!/usr/bin/sh
export CC="ccache gcc"
export CXX="ccache g++"
export CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt -m32"
export CXXFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt -m32"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -m32"
export PKG_CONFIG_PATH='/usr/lib32/pkgconfig'
scons -c
find build/ -type f -delete
rm site.conf
scons -j1 CC="$CC" CXX="$CXX" BUILD_GAMEPAK=1 NO_GCH=1 BUILD=release --debug=explain "$@"
diff -ur source/game/gamesys/TypeInfo.cpp source_fix/game/gamesys/TypeInfo.cpp
--- source/game/gamesys/TypeInfo.cpp 2017-03-11 00:24:12.000000000 +0200
+++ source_fix/game/gamesys/TypeInfo.cpp 2017-10-31 15:36:32.506332980 +0200
@@ -17,6 +17,28 @@
******************************************************************************/
+// As stated below, the trick of defining "private" and "protected" is pure evil.
+// We pay for it in class definitions that implicitly declare private members
+// without using the (default) private visibility declaration.
+// This becomes a real problem in code like the one found in GCC 6.2, along the lines:
+//
+// class Class {
+// struct PrivateStruct; // forward declaration
+// // ...
+// private:
+// struct PrivateStruct {}; // actual definition
+// };
+//
+// In this case, PrivateStruct is implicitly declared private, and then defined as
+// "private", that after our trick becomes "public". Joy ensues.
+// We import all the things like that before the trick takes places.
+// We lose access to some variable inspection, but we gain in compilability
+// (and a bit in sanity).
+#if defined(__GNUC__) && (__GNUC__ >= 6)
+// these were observed in GNU GCC 6.2.0 (not in 5.4.0):
+#include <sstream>
+#endif // if GCC 6+
+
// This is real evil but allows the code to inspect arbitrary class variables.
#define private public
#define protected public
diff -ur source/game/pugixml/pugixml.hpp source_fix/game/pugixml/pugixml.hpp
--- source/game/pugixml/pugixml.hpp 2017-03-11 00:24:18.000000000 +0200
+++ source_fix/game/pugixml/pugixml.hpp 2017-10-28 15:20:06.368351194 +0300
@@ -17,6 +17,9 @@
#include "pugiconfig.hpp"
#ifndef PUGIXML_NO_STL
+#if defined(__clang__) || defined(__GNUC__)
+#include <string>
+#else
namespace std
{
struct bidirectional_iterator_tag;
@@ -43,6 +46,7 @@
template <> class char_traits<char>;
#endif
}
+#endif // if not clang nor GCC
#endif
// Macro for deprecated features
diff -ur source/include/devil/IL/devil_internal_exports.h source_fix/include/devil/IL/devil_internal_exports.h
--- source/include/devil/IL/devil_internal_exports.h 2017-03-11 00:27:35.000000000 +0200
+++ source_fix/include/devil/IL/devil_internal_exports.h 2017-10-29 02:35:02.197175085 +0300
@@ -24,7 +24,7 @@
#ifndef NOINLINE
#ifndef INLINE
#if defined(__GNUC__)
- #define INLINE extern inline
+ #define INLINE static inline
#elif defined(_MSC_VER)
#define NOINLINE
#define INLINE
diff -ur source/include/devil/il_endian.h source_fix/include/devil/il_endian.h
--- source/include/devil/il_endian.h 2017-03-11 00:27:35.000000000 +0200
+++ source_fix/include/devil/il_endian.h 2017-10-30 01:42:07.250994798 +0200
@@ -56,6 +56,7 @@
#define BigDouble(d) iSwapDouble(d)
#endif
+#ifdef NOINLINE
ILvoid iSwapUShort(ILushort *s);
ILvoid iSwapShort(ILshort *s);
ILvoid iSwapUInt(ILuint *i);
@@ -86,6 +87,7 @@
ILubyte SaveBigInt(ILint i);
ILubyte SaveBigFloat(ILfloat f);
ILubyte SaveBigDouble(ILdouble d);
+#endif
#ifdef IL_ENDIAN_C
#undef NOINLINE
diff -ur source/SConstruct source_fix/SConstruct
--- source/SConstruct 2017-03-11 00:24:22.000000000 +0200
+++ source_fix/SConstruct 2017-10-31 14:51:25.763340208 +0200
@@ -297,6 +297,8 @@
BASECPPFLAGS.append( '-fmessage-length=0' )
# gcc 4.0
BASECPPFLAGS.append( '-fpermissive' )
+# C++11 features, boost needs to be rebuild with C++11 too for proper linking
+BASECPPFLAGS.append( '-std=c++11' )
if ( g_os == 'Linux' ):
# gcc 4.x option only - only export what we mean to from the game SO
@@ -335,7 +337,7 @@
# -fschedule-insns2: implicit at -O2
# no-unsafe-math-optimizations: that should be on by default really. hit some wonko bugs in physics code because of that
# greebo: Took out -Winline, this is spamming real hard
- OPTCPPFLAGS = [ '-O3', '-march=pentium3', '-ffast-math', '-fno-unsafe-math-optimizations', '-fomit-frame-pointer' ]
+ OPTCPPFLAGS = [ '-O3', '-march=native', '-ffast-math', '-fno-unsafe-math-optimizations', '-fomit-frame-pointer' ]
if ( ID_MCHECK == '0' ):
ID_MCHECK = '2'
else:
diff -ur source/sys/linux/main.cpp source_fix/sys/linux/main.cpp
--- source/sys/linux/main.cpp 2017-03-11 00:24:20.000000000 +0200
+++ source_fix/sys/linux/main.cpp 2017-10-31 13:38:30.499480808 +0200
@@ -286,7 +286,7 @@
*/
double Sys_GetClockTicks( void ) {
#if defined( __i386__ )
- unsigned long lo, hi;
+ unsigned long long lo, hi;
__asm__ __volatile__ (
"push %%ebx\n" \
diff -ur source/sys/linux/sound.cpp source_fix/sys/linux/sound.cpp
--- source/sys/linux/sound.cpp 2017-03-11 00:24:20.000000000 +0200
+++ source_fix/sys/linux/sound.cpp 2017-10-31 13:37:03.079846902 +0200
@@ -271,7 +271,7 @@
}
// instead of an exact match, do a very close to
// there is some horrible Ensonic ES1371 which replies 44101 for a 44100 request
- if ( abs( m_speed - PRIMARYFREQ ) > 5 ) {
+ if ( abs( static_cast<int>(m_speed - PRIMARYFREQ) ) > 5 ) {
common->Warning( "ioctl SNDCTL_DSP_SPEED failed to get the requested frequency %d, got %d", PRIMARYFREQ, m_speed );
InitFailed();
return false;
diff -ur source/tdm_update/SConstruct source_fix/tdm_update/SConstruct
--- source/tdm_update/SConstruct 2017-03-11 00:24:05.000000000 +0200
+++ source_fix/tdm_update/SConstruct 2017-10-31 15:07:27.859700724 +0200
@@ -188,7 +188,7 @@
# -finline-functions: implicit at -O3
# -fschedule-insns2: implicit at -O2
# no-unsafe-math-optimizations: that should be on by default really. hit some wonko bugs in physics code because of that
- OPTCPPFLAGS = [ '-O3', '-ffast-math', '-fno-unsafe-math-optimizations', '-fomit-frame-pointer' ]
+ OPTCPPFLAGS = [ '-O3', '-march=native', '-ffast-math', '-fno-unsafe-math-optimizations', '-fomit-frame-pointer' ]
else:
print 'Unknown build configuration ' + BUILD
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment