From 9e52982f0e8ce1c99f48d51e38f843323427750c Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 30 Jul 2016 14:22:18 +0100 Subject: Change CROSSCOMPILE flag to NO_NATIVE_OPTIMIZATION (#3279) * Change CROSSCOMPILE flag to NOMARCHNATIVE. The old name was confusing, the new name describes exactly what it does. This fixes issue #3272 * Break configuration when using CROSSCOMPILE. This stops any old build scripts from producing broken builds. * Use NO_NATIVE_OPTIMIZATION rather than NOMARCHNATIVE. Addresses @madmaxoft's concerns. --- CMakeLists.txt | 16 +++++----------- COMPILING.md | 20 ++++++++------------ SetFlags.cmake | 6 +++++- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aaaac1e1f..1cee91c93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,11 @@ # Use CMake to generate the build files for your platform # # This script supports some configuration through CMake arguments (-Dparam=val syntax): -# BUILD_TOOLS=1 sets up additional executables to be built along with the server (ProtoProxy, GrownBiomeGenVisualiser, MCADefrag) -# BUILD_UNSTABLE_TOOLS=1 sets up yet more executables to be built, these can be broken and generally are obsolete (GeneratorPerformanceTest) -# CROSSCOMPILE=1 marks the build as a crosscompile (doesn't include optimizations for current platform) -# DISABLE_SYSTEM_LUA=1 disables the use of system Lua interpreter; the tolua executable will be built and used instead. Incompatible with cross-compiling -# SELF_TEST=1 enables testing code to be built +# BUILD_TOOLS=1 sets up additional executables to be built along with the server (ProtoProxy, GrownBiomeGenVisualiser, MCADefrag) +# BUILD_UNSTABLE_TOOLS=1 sets up yet more executables to be built, these can be broken and generally are obsolete (GeneratorPerformanceTest) +# NO_NATIVE_OPTIMIZATION=1 disables CPU-specific optimisations for the current machine, allows use on other CPUs of the same platform +# DISABLE_SYSTEM_LUA=1 disables the use of system Lua interpreter; the tolua executable will be built and used instead. Incompatible with cross-compiling +# SELF_TEST=1 enables testing code to be built @@ -118,16 +118,10 @@ if (NOT(DISABLE_SYSTEM_LUA)) message(STATUS "Lua 5.1 has been found in your system and will be used for the build.") set(USE_SYSTEM_LUA 1) else() - if (CROSSCOMPILE) - message(FATAL "To crosscompile, you need to have Lua 5.1 installed in your system and available in PATH.") - endif() message(STATUS "Lua 5.1 has NOT been found in your system, the build will use its own Lua implementation.") unset(USE_SYSTEM_LUA) endif() else() - if (CROSSCOMPILE) - message(FATAL "CMake parameter mismatch: CROSSCOMPILE is mutually exclusive with DISABLE_SYSTEM_LUA") - endif() message(STATUS "System Lua is disabled via CMake command-line parameters. The build will use its own Lua implementation.") endif() diff --git a/COMPILING.md b/COMPILING.md index 3c6653293..c1366d893 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -142,33 +142,29 @@ This is useful if you want to compile Cuberite on an x64 (64-bit Intel) machine to your cmake command and 32 bit will be forced. -### Compiling for another computer ### +### Compiling for another computer of the same architecture ### -When cross-compiling for another computer it is important to set cross compiling mode. This tells the compiler not to optimise for your machine. This switch can be used with debug or release mode. To enable, simply add: +When cross-compiling for another computer of the same architecture it is important to set the NO_NATIVE_OPTIMIZATION flag. This tells the compiler not to optimise for your machine. This switch can be used with debug or release mode. To enable, simply add: - -DCROSSCOMPILE=1 + -DNO_NATIVE_OPTIMIZATION=1 to your cmake command. -Note that real cross-compilation is hard at this moment, because an executable generated during the build process is required for later stages, so if your computer cannot run executables it generates the build will not work. - ### List of all build flags ### Cuberite's build process supports a large number of flags for customising the builds. Use these flags by adding `-DFlag_name=Value` to the cmake configuration command. For example to enable test generation using the `SELF_TEST` flag add: `-DSELF_TEST=ON` ###### BUILD_TOOLS -Adds the Cuberite tools to the build. At the moment only MCADefrag and ProtoProxy are added. Define as ON to enable. Define as OFF to disable. +Adds the Cuberite tools to the build. At the moment only MCADefrag and ProtoProxy are added. Define as ON to enable. Define as OFF to disable. ###### BUILD_UNSTABLE_TOOLS -Adds tools that are not working yet to the build. Currently this is only the Generator Performance Test. Used for developing these tools. Define as ON to enable. Define as OFF to disable. +Adds tools that are not working yet to the build. Currently this is only the Generator Performance Test. Used for developing these tools. Define as ON to enable. Define as OFF to disable. ###### SELF_TEST -Enables generation of tests and self-test startup code. Tests can be run with ctest and with makefiles make test. Define as ON to enable. Define as OFF to disable. +Enables generation of tests and self-test startup code. Tests can be run with ctest and with makefiles make test. Define as ON to enable. Define as OFF to disable. ###### FORCE_32 Forces the build to use 32 bit builds on *nix systems. Define as ON to enable. Define as OFF to disable. - -###### CROSSCOMPILE -Disables optimizations for the build host. This is important when building on a different machine from the one you will run Cuberite on as the build machine may support instructions the final machine does not. This flag only has any effect on linux. Define as ON to enable. Define as OFF to disable. - +###### NO_NATIVE_OPTIMIZATION +Disables optimizations for the build host. This is important when building on a different machine from the one you will run Cuberite on as the build machine may support instructions the final machine does not. This flag only has any effect on linux. Define as ON to enable. Define as OFF to disable. diff --git a/SetFlags.cmake b/SetFlags.cmake index bde3be549..357cb9e7c 100644 --- a/SetFlags.cmake +++ b/SetFlags.cmake @@ -124,10 +124,14 @@ macro(set_flags) # Have the compiler generate code specifically targeted at the current machine on Linux - if(LINUX AND NOT CROSSCOMPILE) + if(LINUX AND NOT NO_NATIVE_OPTIMIZATION) add_flags_cxx("-march=native") endif() + if(CROSSCOMPILE) + message(FATAL_ERROR "The CROSSCOMPILE flag has been renamed to NO_NATIVE_OPTIMIZATION. Please update your build scripts to compile Cuberite.") + endif() + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") get_clang_version() endif() -- cgit v1.2.3