From 44818598987a51dd2a8a4a522b4a60cca48876de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 1 Sep 2016 21:44:40 +0200 Subject: [PATCH 1/6] Fix Launchpad builds --- CMakeLists.txt | 19 +++++++++++++++---- debian/control | 4 ++-- debian/rules | 10 ++++------ src/addresses.h | 8 +++++++- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c312452b5..3abd48bf87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,9 +80,21 @@ option(FORCE64 "Force native (x86-64) build. Do not use, for experimental purpos option(DISABLE_OPENGL "Disable OpenGL support.") option(DISABLE_RCT2 "WIP: Try building without using code and data segments from vanilla.") option(USE_MMAP "Use mmap to try loading rct2's data segment into memory.") +option(LAUNCHPAD_BUILD "Sets some build system options on launchpad.net") + +if (LAUNCHPAD_BUILD) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=pointer-to-int-cast -Wno-error=int-to-pointer-cast") + endif() +else() + if (FORCE64) + set(TARGET_M "-m64") + else () + set(TARGET_M "-m32") + endif() +endif() if (FORCE64) - set(TARGET_M "-m64") set(OBJ_FORMAT "elf64-x86-64") set(LINKER_SCRIPT "ld_script_x86_64.xc") if ((APPLE OR WIN32) AND NOT USE_MMAP) @@ -90,7 +102,6 @@ if (FORCE64) set(USE_MMAP ON) endif() else () - set(TARGET_M "-m32") set(OBJ_FORMAT "elf32-i386") set(LINKER_SCRIPT "ld_script_i386.xc") endif () @@ -203,8 +214,8 @@ if (APPLE) endif (APPLE) # set necessary flags to compile code as is -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 -fno-pie -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 -fno-pie -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 -fno-pie -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 -fno-pie -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") diff --git a/debian/control b/debian/control index ee42fe1764..562e118de3 100644 --- a/debian/control +++ b/debian/control @@ -4,10 +4,10 @@ Section: misc Priority: optional Standards-Version: 3.9.2 Multi-Arch: same -Build-Depends: debhelper (>= 9), cmake, libsdl2-dev, libsdl2-ttf-dev, gcc, pkg-config, g++-multilib, gcc-multilib, libjansson4 (>= 2.7), libjansson-dev (>= 2.7), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev +Build-Depends: debhelper (>= 9), cmake, libsdl2-dev, libsdl2-ttf-dev, gcc, pkg-config, libjansson4 (>= 2.7), libjansson-dev (>= 2.7), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev Package: openrct2 -Architecture: i386 +Architecture: any Homepage: https://openrct2.website/ Vcs-Browser: https://github.com/OpenRCT2/OpenRCT2 Vcs-Git: https://github.com/OpenRCT2/OpenRCT2 diff --git a/debian/rules b/debian/rules index a3bada8c8f..7ddf0ea4e2 100755 --- a/debian/rules +++ b/debian/rules @@ -2,12 +2,10 @@ BUILDDIR=build_dir -build: - scripts/linux/install.sh - mkdir $(BUILDDIR) - cd $(BUILDDIR); cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. - make -C $(BUILDDIR) - touch build +extra_flags := $(if $(filter i386,$(DEB_HOST_ARCH)),"-DLAUNCHPAD_BUILD=on","-DLAUNCHPAD_BUILD=on -DUSE_MMAP=on -DDISABLE_RCT2=on") + +override_dh_auto_configure: + dh_auto_configure -a -- $(extra_flags) %: dh $@ diff --git a/src/addresses.h b/src/addresses.h index 914f36a907..21cf8f82c5 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -24,7 +24,13 @@ #endif #ifdef USE_MMAP - #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x200000000) + #if defined(PLATFORM_64BIT) + #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x200000000) + #elif defined(PLATFORM_32BIT) + #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x09000000) + #else + #error "Unknown platform" + #endif #else #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x8a4000) #endif From 640aaad3f8b47d2dc918e4cbaf0ab3e34785bda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 2 Sep 2016 21:06:57 +0200 Subject: [PATCH 2/6] Fix quotes --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 7ddf0ea4e2..de10dc205c 100755 --- a/debian/rules +++ b/debian/rules @@ -2,7 +2,7 @@ BUILDDIR=build_dir -extra_flags := $(if $(filter i386,$(DEB_HOST_ARCH)),"-DLAUNCHPAD_BUILD=on","-DLAUNCHPAD_BUILD=on -DUSE_MMAP=on -DDISABLE_RCT2=on") +extra_flags := $(if $(filter i386,$(DEB_HOST_ARCH)),-DLAUNCHPAD_BUILD=on,-DLAUNCHPAD_BUILD=on -DUSE_MMAP=on -DDISABLE_RCT2=on) override_dh_auto_configure: dh_auto_configure -a -- $(extra_flags) From f6e9216b7dab9bc990460a085e121f2c3890f52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 2 Sep 2016 21:23:12 +0200 Subject: [PATCH 3/6] Use PIC/pie flags to satisfy Launchpad --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3abd48bf87..eddd5bb8cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,10 +214,10 @@ if (APPLE) endif (APPLE) # set necessary flags to compile code as is -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 -fno-pie -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 -fno-pie -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 -fPIC -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 -fPIC -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M} -fpie") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} -fpie") if (MINGW) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++") From cdc447e92a974a4a91bf2e3a5ee47522aeb4c965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 3 Sep 2016 09:49:43 +0200 Subject: [PATCH 4/6] Refactor compiler flags in CMakeLists.txt --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eddd5bb8cf..997e46469d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,10 +82,14 @@ option(DISABLE_RCT2 "WIP: Try building without using code and data segments from option(USE_MMAP "Use mmap to try loading rct2's data segment into memory.") option(LAUNCHPAD_BUILD "Sets some build system options on launchpad.net") +set(COMMON_COMPILE_OPTIONS "-fPIC -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") + if (LAUNCHPAD_BUILD) if (CMAKE_SIZEOF_VOID_P EQUAL 8) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=pointer-to-int-cast -Wno-error=int-to-pointer-cast") endif() + # Launchpad turns on -Wdate-time for compilers that support it, this shouldn't break our build + set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -Wno-error=date-time") else() if (FORCE64) set(TARGET_M "-m64") @@ -214,8 +218,8 @@ if (APPLE) endif (APPLE) # set necessary flags to compile code as is -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 -fPIC -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 -fPIC -fstrict-aliasing -Werror -Wno-error=date-time -Wundef -Wmissing-declarations") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 ${COMMON_COMPILE_OPTIONS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 ${COMMON_COMPILE_OPTIONS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M} -fpie") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} -fpie") From 47e343a88d0df616a5e14fb0d18dd3d694e6518b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 3 Sep 2016 10:08:45 +0200 Subject: [PATCH 5/6] Fix PIC options for mingw --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 997e46469d..c5f4681775 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,12 @@ option(DISABLE_RCT2 "WIP: Try building without using code and data segments from option(USE_MMAP "Use mmap to try loading rct2's data segment into memory.") option(LAUNCHPAD_BUILD "Sets some build system options on launchpad.net") -set(COMMON_COMPILE_OPTIONS "-fPIC -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") +set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") + +# On mingw all code is already PIC, this will avoid compiler error on redefining this option +if(NOT MINGW) + set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fPIC") +endif() if (LAUNCHPAD_BUILD) if (CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -220,7 +225,7 @@ endif (APPLE) # set necessary flags to compile code as is set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 ${COMMON_COMPILE_OPTIONS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 ${COMMON_COMPILE_OPTIONS}") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M} -fpie") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} -fpie") if (MINGW) From 27799bc1878864cf4b3dbe0b8bdecb384e756e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 4 Sep 2016 17:28:54 +0200 Subject: [PATCH 6/6] Remove unnecessary compiler options --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5f4681775..2bb66d62e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,9 +90,6 @@ if(NOT MINGW) endif() if (LAUNCHPAD_BUILD) - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=pointer-to-int-cast -Wno-error=int-to-pointer-cast") - endif() # Launchpad turns on -Wdate-time for compilers that support it, this shouldn't break our build set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -Wno-error=date-time") else()