Skip to content

Instantly share code, notes, and snippets.

@jnettlet
Created September 19, 2020 12:29
Show Gist options
  • Save jnettlet/4c454b93f6856965f1f8929f0be566e1 to your computer and use it in GitHub Desktop.
Save jnettlet/4c454b93f6856965f1f8929f0be566e1 to your computer and use it in GitHub Desktop.
Unvanquished_aarch64.diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 08d3ceb8..27678144 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -428,10 +428,6 @@ if (NACL)
add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE})
set_target_properties(srclibs-nacl-module PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module)
-else()
- add_library(srclibs-nacl-native EXCLUDE_FROM_ALL ${NACLLIST_NATIVE})
- set_target_properties(srclibs-nacl-native PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs")
- set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-native)
endif()
# Base OS libs
diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake
index cb44b4d8..1f30ec33 100644
--- a/cmake/DaemonFlags.cmake
+++ b/cmake/DaemonFlags.cmake
@@ -171,6 +171,9 @@ else()
set_c_cxx_flag("-msse2")
set_c_cxx_flag("-mtune=generic")
try_c_cxx_flag_werror(MFPMATH_SSE "-mfpmath=sse")
+ elseif (ARCH STREQUAL "aarch64")
+ set_c_cxx_flag("-mtune=native")
+ try_c_cxx_flag_werror(MCX16 "-mcx16")
elseif (ARCH STREQUAL "x86_64")
set_c_cxx_flag("-m64")
set_c_cxx_flag("-mtune=generic")
diff --git a/cmake/DaemonPlatform.cmake b/cmake/DaemonPlatform.cmake
index 98552dfd..66b59976 100644
--- a/cmake/DaemonPlatform.cmake
+++ b/cmake/DaemonPlatform.cmake
@@ -42,9 +42,31 @@ endif()
# Determine architecture
################################################################################
-# When adding a new architecture, look at all the places ARCH is used
-if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
- set( ARCH "x86_64" )
+if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+ set(ARCH "x86_64")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
+ set(ARCH "x86_64")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
+ # cmake reports AMD64 on Windows, but we might be building for 32-bit.
+ if (CMAKE_CL_64)
+ set(ARCH "x86_64")
+ else()
+ set(ARCH "x86")
+ endif()
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
+ set(ARCH "x86")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
+ set(ARCH "x86")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
+ set(ARCH "x86")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
+ set(ARCH "arm")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv6")
+ set(ARCH "arm")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7-a")
+ set(ARCH "arm")
+elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
+ set(ARCH "aarch64")
else()
- set( ARCH "x86" )
+ message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
endif()
diff --git a/libs/nacl/native_client/src/include/portability.h b/libs/nacl/native_client/src/include/portability.h
index f101608e..250877e3 100644
--- a/libs/nacl/native_client/src/include/portability.h
+++ b/libs/nacl/native_client/src/include/portability.h
@@ -75,7 +75,7 @@
* http://www.agner.org/optimize/calling_conventions.pdf
* r with gcc, run: "echo | gcc -E -dM -"
*/
-#if defined(_M_X64) || defined(__x86_64__)
+#if defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__)
#define NACL_HOST_WORDSIZE 64
#elif defined(_M_IX86) || defined(__i386__)
#define NACL_HOST_WORDSIZE 32
diff --git a/src/common/Compiler.h b/src/common/Compiler.h
index 0c2dac5c..2bf6c199 100644
--- a/src/common/Compiler.h
+++ b/src/common/Compiler.h
@@ -72,7 +72,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Raise an exception and break in the debugger
#if defined(__i386__) || defined(__x86_64__)
#define BREAKPOINT() __asm__ __volatile__("int $3\n\t")
-#elif defined(__pnacl__)
+#elif defined(__pnacl__) || defined(__aarch64__)
// TODO find how to implement breakpoint on PNaCl
#define BREAKPOINT()
#else
diff --git a/src/common/Platform.h b/src/common/Platform.h
index 44577990..6d09361c 100644
--- a/src/common/Platform.h
+++ b/src/common/Platform.h
@@ -62,6 +62,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#undef __x86_64__
#define __x86_64__ 1
#define ARCH_STRING "x86_64"
+#elif defined(__aarch64__)
+#define ARCH_STRING "aarch64"
#elif defined(__pnacl__)
#define ARCH_STRING "PNaCl"
#else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment