Skip to content

Commit 2d1326f

Browse files
committed
add ppc64le/ppc64 architecture support
Add build and runtime support for ppc64el (little-endian) and ppc64 (big-endian) POWER architectures: - cmake/DaemonNacl.cmake: add ppc64el/ppc64 case with dummy x86 NaCl defines since NaCl has no PPC support - cmake/DaemonFlags.cmake: add -mcpu=power8 (ppc64el) and -mcpu=power5 (ppc64) compiler flags using new GCC_GENERIC_CPU variable, as GCC on POWER uses -mcpu instead of -march/-mtune - cmake/DaemonArchitecture.cmake: define ppc64el parent architecture as ppc64, and add DAEMON_NACL_RUNTIME_ENABLED compile-time define that is only set on architectures with a NaCl loader (amd64, i686, armhf) - src/engine/framework/VirtualMachine.h: default VM type to native DLL mode on architectures without NaCl runtime support, so the engine does not attempt to load nonexistent .nexe files Tested on ppc64le with GCC 16.0.1: builds daemon, daemonded, daemon-tty, cgame-native-dll.so, and sgame-native-dll.so successfully.
1 parent bd2e006 commit 2d1326f

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

cmake/DaemonArchitecture.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ endif()
9191

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

94+
# NaCl runtime is only available on architectures that have a NaCl loader.
95+
set(NACL_RUNTIME_ARCH amd64 i686 armhf)
96+
if (NACL_ARCH IN_LIST NACL_RUNTIME_ARCH)
97+
add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED=1)
98+
endif()
99+
94100
option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON)
95101
mark_as_advanced(USE_ARCH_INTRINSICS)
96102

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

112118
set(amd64_PARENT "i686")
113119
set(arm64_PARENT "armhf")
120+
set(ppc64el_PARENT "ppc64")
114121

115122
if (${ARCH}_PARENT)
116123
set_arch_intrinsics(${${ARCH}_PARENT})

cmake/DaemonFlags.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,18 @@ elseif (NOT NACL)
659659
set(GCC_GENERIC_ARCH "armv6")
660660
# There is no generic tuning option for armv6.
661661
unset(GCC_GENERIC_TUNE)
662+
elseif (ARCH STREQUAL "ppc64el")
663+
# POWER8 minimum (first little-endian POWER).
664+
# GCC uses -mcpu instead of -march/-mtune for POWER.
665+
unset(GCC_GENERIC_ARCH)
666+
unset(GCC_GENERIC_TUNE)
667+
set(GCC_GENERIC_CPU "power8")
668+
elseif (ARCH STREQUAL "ppc64")
669+
# POWER5 minimum (first 64-bit POWER in wide use).
670+
# GCC uses -mcpu instead of -march/-mtune for POWER.
671+
unset(GCC_GENERIC_ARCH)
672+
unset(GCC_GENERIC_TUNE)
673+
set(GCC_GENERIC_CPU "power5")
662674
else()
663675
message(WARNING "Unknown architecture ${ARCH}")
664676
endif()
@@ -676,6 +688,11 @@ elseif (NOT NACL)
676688
if (GCC_GENERIC_TUNE)
677689
try_c_cxx_flag_werror(MTUNE "-mtune=${GCC_GENERIC_TUNE}")
678690
endif()
691+
692+
# POWER architectures use -mcpu instead of -march/-mtune.
693+
if (GCC_GENERIC_CPU)
694+
try_c_cxx_flag_werror(MCPU "-mcpu=${GCC_GENERIC_CPU}")
695+
endif()
679696
endif()
680697

681698
if (USE_CPU_RECOMMENDED_FEATURES)

cmake/DaemonNacl.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ else()
7171
add_definitions( -DNACL_BUILD_SUBARCH=32 )
7272
elseif( NACL_ARCH STREQUAL "armhf" )
7373
add_definitions( -DNACL_BUILD_ARCH=arm )
74+
elseif( NACL_ARCH STREQUAL "ppc64el" OR NACL_ARCH STREQUAL "ppc64" )
75+
# NaCl does not support PPC, but these defines must be set for native
76+
# builds. Use dummy x86 values as PNaCl does for arch-independent builds.
77+
add_definitions( -DNACL_BUILD_ARCH=x86 )
78+
add_definitions( -DNACL_BUILD_SUBARCH=64 )
7479
else()
7580
message(WARNING "Unknown architecture ${NACL_ARCH}")
7681
endif()

src/engine/framework/VirtualMachine.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ enum vmType_t {
9595
struct VMParams {
9696
VMParams(std::string name, int vmTypeFlags)
9797
: logSyscalls("vm." + name + ".logSyscalls", "dump all the syscalls in the " + name + ".syscallLog file", Cvar::NONE, false),
98+
#ifdef DAEMON_NACL_RUNTIME_ENABLED
9899
vmType("vm." + name + ".type", "how the vm should be loaded for " + name, vmTypeFlags,
99100
Util::ordinal(vmType_t::TYPE_NACL), 0, Util::ordinal(vmType_t::TYPE_END) - 1),
101+
#else
102+
vmType("vm." + name + ".type", "how the vm should be loaded for " + name, vmTypeFlags,
103+
Util::ordinal(vmType_t::TYPE_NATIVE_DLL), 0, Util::ordinal(vmType_t::TYPE_END) - 1),
104+
#endif
100105
debug("vm." + name + ".debug", "run a gdbserver on localhost:4014 to debug the VM", Cvar::NONE, false),
101106
debugLoader("vm." + name + ".debugLoader", "make nacl_loader dump information to " + name + "-nacl_loader.log", Cvar::NONE, 1, 0, 5) {
102107
}
@@ -111,7 +116,11 @@ struct VMParams {
111116
class VMBase {
112117
public:
113118
VMBase(std::string name_, int vmTypeCvarFlags)
119+
#ifdef DAEMON_NACL_RUNTIME_ENABLED
114120
: processHandle(Sys::INVALID_HANDLE), name(name_), type(TYPE_NACL), params(name_, vmTypeCvarFlags) {}
121+
#else
122+
: processHandle(Sys::INVALID_HANDLE), name(name_), type(TYPE_NATIVE_DLL), params(name_, vmTypeCvarFlags) {}
123+
#endif
115124

116125
// Create the VM for the named module. This will automatically free any existing VM.
117126
void Create();

0 commit comments

Comments
 (0)