Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmake/DaemonArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ endif()

daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${NACL_ARCH}\"")

# NaCl runtime is only available on architectures that have a NaCl loader.
set(NACL_RUNTIME_ARCH amd64 i686 armhf)
if (NACL_ARCH IN_LIST NACL_RUNTIME_ARCH)
add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED)
endif()

option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON)
mark_as_advanced(USE_ARCH_INTRINSICS)

Expand All @@ -111,6 +117,7 @@ set_arch_intrinsics(${ARCH})

set(amd64_PARENT "i686")
set(arm64_PARENT "armhf")
set(ppc64el_PARENT "ppc64")

if (${ARCH}_PARENT)
set_arch_intrinsics(${${ARCH}_PARENT})
Expand Down
17 changes: 17 additions & 0 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,18 @@ elseif (NOT NACL)
set(GCC_GENERIC_ARCH "armv6")
# There is no generic tuning option for armv6.
unset(GCC_GENERIC_TUNE)
elseif (ARCH STREQUAL "ppc64el")
# POWER8 minimum (first little-endian POWER).
# GCC uses -mcpu instead of -march/-mtune for POWER.
unset(GCC_GENERIC_ARCH)
unset(GCC_GENERIC_TUNE)
set(GCC_GENERIC_CPU "power8")
elseif (ARCH STREQUAL "ppc64")
# POWER5 minimum (first 64-bit POWER in wide use).
# GCC uses -mcpu instead of -march/-mtune for POWER.
unset(GCC_GENERIC_ARCH)
unset(GCC_GENERIC_TUNE)
set(GCC_GENERIC_CPU "power5")
else()
message(WARNING "Unknown architecture ${ARCH}")
endif()
Expand All @@ -676,6 +688,11 @@ elseif (NOT NACL)
if (GCC_GENERIC_TUNE)
try_c_cxx_flag_werror(MTUNE "-mtune=${GCC_GENERIC_TUNE}")
endif()

# POWER architectures use -mcpu instead of -march/-mtune.
if (GCC_GENERIC_CPU)
try_c_cxx_flag_werror(MCPU "-mcpu=${GCC_GENERIC_CPU}")
endif()
endif()

if (USE_CPU_RECOMMENDED_FEATURES)
Expand Down
5 changes: 5 additions & 0 deletions cmake/DaemonNacl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ else()
add_definitions( -DNACL_BUILD_SUBARCH=32 )
elseif( NACL_ARCH STREQUAL "armhf" )
add_definitions( -DNACL_BUILD_ARCH=arm )
elseif( NACL_ARCH STREQUAL "ppc64el" OR NACL_ARCH STREQUAL "ppc64" )
# NaCl does not support PPC, but these defines must be set for native
# builds. Use dummy x86 values as PNaCl does for arch-independent builds.
add_definitions( -DNACL_BUILD_ARCH=x86 )
add_definitions( -DNACL_BUILD_SUBARCH=64 )
else()
message(WARNING "Unknown architecture ${NACL_ARCH}")
endif()
Expand Down
19 changes: 19 additions & 0 deletions src/engine/framework/VirtualMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ static Cvar::Cvar<int> vm_timeout(
"Receive timeout in seconds",
Cvar::NONE, 2);

#if defined(DAEMON_NACL_RUNTIME_ENABLED)
static Cvar::Cvar<bool> vm_nacl_available(
"vm.nacl.available",
"Whether NaCl runtime is available on this platform",
Cvar::ROM, true);
#else
static Cvar::Cvar<bool> vm_nacl_available(
"vm.nacl.available",
"Whether NaCl runtime is available on this platform",
Cvar::ROM, false);
#endif

namespace VM {

// https://github.com/Unvanquished/Unvanquished/issues/944#issuecomment-744454772
Expand Down Expand Up @@ -497,6 +509,13 @@ void VMBase::Create()
std::pair<IPC::Socket, IPC::Socket> pair = IPC::Socket::CreatePair();

IPC::Socket rootSocket;
#if !defined(DAEMON_NACL_RUNTIME_ENABLED)
if (type == TYPE_NACL || type == TYPE_NACL_LIBPATH) {
Sys::Error("NaCl VM is not supported on this platform. "
"Set vm.cgame.type and vm.sgame.type to 3 (native DLL) "
"and use devmap instead of map.");
}
#endif
if (type == TYPE_NACL || type == TYPE_NACL_LIBPATH) {
std::tie(processHandle, rootSocket) = CreateNaClVM(std::move(pair), name, params.debug.Get(), type == TYPE_NACL, params.debugLoader.Get());
} else if (type == TYPE_NATIVE_EXE) {
Expand Down