Adjust the source code and build enviornment so that Mangos Zero will build on ARM32. (#79)
This was primarily done to test the feasibility of running on a RPi4 running Debian Buster (it works quite well). Summary of changes: - Reworked patches I found on the Mangos forum, original pastebins here: https://pastebin.com/BxqCmCML - Adjusted cmake's arch detection to include ARM32/ARM64 - Adjusted compiler flags for Linux builds and supressed some extraneous notes I have played for about an hour and noticed no issues or differences from i386/x86_64 VMs. One note, currently the map extraction tools for ARM are broken. They compile but do work properly. I'll work on that next.
This commit is contained in:
parent
b103caaecc
commit
fe79b0dc29
@ -23,14 +23,21 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(XCODE)
|
if(XCODE)
|
||||||
if(PLATFORM MATCHES 32)
|
# Here we add a check for ARM32, as they can't leverage SSE/SSE2
|
||||||
|
if(PLATFORM MATCHES 32 AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm")
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES ARM32)
|
||||||
|
# Default for 32-bit left as i386
|
||||||
|
elseif(PLATFORM MATCHES 32)
|
||||||
set(CMAKE_OSX_ARCHITECTURES i386)
|
set(CMAKE_OSX_ARCHITECTURES i386)
|
||||||
|
# Check for ARM64
|
||||||
|
elseif(PLATFORM MATCHES 64 AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm")
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES ARM64)
|
||||||
|
# Default for 64-bit left as x86_64
|
||||||
else()
|
else()
|
||||||
set(CMAKE_OSX_ARCHITECTURES x86_64)
|
set(CMAKE_OSX_ARCHITECTURES x86_64)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compile definitions
|
# Compile definitions
|
||||||
#
|
#
|
||||||
@ -112,10 +119,17 @@ endif ()
|
|||||||
# GCC compiler options
|
# GCC compiler options
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||||
set(DEFAULT_COMPILE_OPTS ${DEFAULT_COMPILE_OPTS}
|
set(DEFAULT_COMPILE_OPTS ${DEFAULT_COMPILE_OPTS}
|
||||||
$<$<EQUAL:${PLATFORM},32>:
|
# Enhanced 32-bit check, now we can use the arch to specify flags
|
||||||
|
$<$<STREQUAL:${CMAKE_OSX_ARCHITECTURES},"i386">:
|
||||||
-msse2
|
-msse2
|
||||||
-mfpmath=sse
|
-mfpmath=sse
|
||||||
>
|
>
|
||||||
|
$<$<STREQUAL:${CMAKE_OSX_ARCHITECTURES},"ARM32">:
|
||||||
|
# explicit space for compiler flags
|
||||||
|
>
|
||||||
|
$<$<STREQUAL:${CMAKE_OSX_ARCHITECTURES},"ARM64">:
|
||||||
|
# explicit space for compiler flags
|
||||||
|
>
|
||||||
$<$<CONFIG:Debug>:
|
$<$<CONFIG:Debug>:
|
||||||
-W
|
-W
|
||||||
-Wall
|
-Wall
|
||||||
@ -128,6 +142,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
|||||||
|
|
||||||
$<$<CONFIG:Release>:
|
$<$<CONFIG:Release>:
|
||||||
--no-warnings
|
--no-warnings
|
||||||
|
# Suppress compiler note on parameter passing. See the following
|
||||||
|
# GCC BZ for more info: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
|
||||||
|
-Wno-psabi
|
||||||
>
|
>
|
||||||
)
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -40,6 +40,14 @@ template<class S, class D>
|
|||||||
*/
|
*/
|
||||||
void SQLStorageLoaderBase<DerivedLoader, StorageClass>::convert(uint32 /*field_pos*/, S src, D& dst)
|
void SQLStorageLoaderBase<DerivedLoader, StorageClass>::convert(uint32 /*field_pos*/, S src, D& dst)
|
||||||
{
|
{
|
||||||
|
#if defined(__arm__)
|
||||||
|
if (((unsigned) &dst) % sizeof(D)) {
|
||||||
|
//The address is not aligned. Use memcpy to avoid ARM unaligned trap
|
||||||
|
D converted(src);
|
||||||
|
memcpy((void*) &dst, (void*) &converted, sizeof(D));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
dst = D(src);
|
dst = D(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +100,14 @@ template<class D>
|
|||||||
*/
|
*/
|
||||||
void SQLStorageLoaderBase<DerivedLoader, StorageClass>::convert_from_str(uint32 /*field_pos*/, char const* /*src*/, D& dst)
|
void SQLStorageLoaderBase<DerivedLoader, StorageClass>::convert_from_str(uint32 /*field_pos*/, char const* /*src*/, D& dst)
|
||||||
{
|
{
|
||||||
|
#if defined(__arm__)
|
||||||
|
if (((unsigned) &dst) % sizeof(D)) {
|
||||||
|
//The address is not aligned. Use memcpy to avoid ARM unaligned trap
|
||||||
|
D converted(0);
|
||||||
|
memcpy((void*) &dst, (void*) &converted, sizeof(D));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
dst = 0;
|
dst = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +122,14 @@ template<class S, class D>
|
|||||||
*/
|
*/
|
||||||
void SQLStorageLoaderBase<DerivedLoader, StorageClass>::default_fill(uint32 /*field_pos*/, S src, D& dst)
|
void SQLStorageLoaderBase<DerivedLoader, StorageClass>::default_fill(uint32 /*field_pos*/, S src, D& dst)
|
||||||
{
|
{
|
||||||
|
#if defined(__arm__)
|
||||||
|
if (((unsigned) &dst) % sizeof(D)) {
|
||||||
|
//The address is not aligned. Use memcpy to avoid ARM unaligned trap
|
||||||
|
D converted(src);
|
||||||
|
memcpy((void*) &dst, (void*) &converted, sizeof(D));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
dst = D(src);
|
dst = D(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +534,13 @@ class ByteBuffer
|
|||||||
{
|
{
|
||||||
if (pos + sizeof(T) > size())
|
if (pos + sizeof(T) > size())
|
||||||
{ throw ByteBufferException(false, pos, sizeof(T), size()); }
|
{ throw ByteBufferException(false, pos, sizeof(T), size()); }
|
||||||
|
#if defined(__arm__)
|
||||||
|
// ARM has alignment issues, we need to use memcpy to avoid them
|
||||||
|
T val;
|
||||||
|
memcpy((void*)&val, (void*)&_storage[pos], sizeof(T));
|
||||||
|
#else
|
||||||
T val = *((T const*)&_storage[pos]);
|
T val = *((T const*)&_storage[pos]);
|
||||||
|
#endif
|
||||||
EndianConvert(val);
|
EndianConvert(val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user