diff --git a/CMakeLists.txt b/CMakeLists.txt index e339747def..35cf7fa5f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -465,7 +465,6 @@ endif() include(DaemonNacl) if (NACL) add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE}) - set_target_properties(srclibs-nacl-module PROPERTIES POSITION_INDEPENDENT_CODE ${GAME_PIE} FOLDER "libs") set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module) else() add_library(srclibs-nacl-native EXCLUDE_FROM_ALL ${NACLLIST_NATIVE}) diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index 868be61185..7cbb964c73 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -363,14 +363,12 @@ else() endif() if (NACL AND USE_NACL_SAIGO AND SAIGO_ARCH STREQUAL "arm") - # This should be set for every build type because build type flags - # are set after the other custom flags and then have the last word. - # DEBUG should already use -O0 anyway. + # Saigo produces broken arm builds when optimizing them. # See: https://github.com/Unvanquished/Unvanquished/issues/3297 - set_c_cxx_flag("-O0" DEBUG) - set_c_cxx_flag("-O0" RELEASE) - set_c_cxx_flag("-O0" RELWITHDEBINFO) - set_c_cxx_flag("-O0" MINSIZEREL) + # When setting this clang-specific option, we don't have to care + # about the ordering of -O options that may be introduced, + # all -O options added to the command line are ignored. + set_c_cxx_flag("-Xclang -disable-llvm-passes") endif() # Extra debug flags. @@ -476,7 +474,16 @@ else() # Don't set _FORTIFY_SOURCE in debug builds. endif() - try_c_cxx_flag(FPIC "-fPIC") + if (NOT NACL) + # Saigo reports weird errors when building some cgame and sgame arm nexe with PIC: + # > error: Cannot represent a difference across sections + # > error: expected relocatable expression + # Google-built Saigo crashes when building amd64 cgame with PIC: + # > UNREACHABLE executed at llvm/lib/Target/X86/X86ISelLowering.cpp + # Self-built Saigo doesn't crash, maybe because assertions are disabled. + # PIC is not useful with NaCl under any circumstances, so we don't use PIC with NaCl. + try_c_cxx_flag(FPIC "-fPIC") + endif() if (USE_HARDENING) # PNaCl accepts the flags but does not define __stack_chk_guard and __stack_chk_fail. @@ -491,7 +498,7 @@ else() try_c_cxx_flag(FNO_STRICT_OVERFLOW "-fno-strict-overflow") try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector") - if (NOT NACL OR (NACL AND GAME_PIE)) + if (NOT NACL) # The -pie flag requires -fPIC: # > ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC # This flag isn't used on macOS: diff --git a/cmake/DaemonPlatform.cmake b/cmake/DaemonPlatform.cmake index be8f5f1c81..a951f2ad47 100644 --- a/cmake/DaemonPlatform.cmake +++ b/cmake/DaemonPlatform.cmake @@ -40,14 +40,5 @@ else() message( FATAL_ERROR "Platform not supported" ) endif() -if (NACL AND USE_NACL_SAIGO) - # Saigo clang reports weird errors when building some cgame and sgame arm nexe with PIE. - # Saigo clang crashes when building amd64 cgame with PIE, sgame builds properly though. - set(GAME_PIE 0) -else() - set(GAME_PIE 1) -endif() - - include(DaemonArchitecture) include(DaemonCompiler) diff --git a/src/shared/VMMain.cpp b/src/shared/VMMain.cpp index a63574eed2..5c0ab8c68c 100644 --- a/src/shared/VMMain.cpp +++ b/src/shared/VMMain.cpp @@ -34,6 +34,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "common/StackTrace.h" +#if defined(__native_client__) +#include +#endif + IPC::Channel VM::rootChannel; #ifdef BUILD_VM_NATIVE_EXE