From 69a3f21e5d048e4a0cf8000d31f5e9148495ad8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Gro=C3=9F?= Date: Tue, 6 Apr 2021 03:50:36 +0200 Subject: [PATCH] Initial partial linux aarch64 support --- CMakeLists.txt | 9 ++- cmake/externals/steamworks/CMakeLists.txt | 2 +- cmake/macros/SetupHifiLibrary.cmake | 2 +- cmake/ports/hifi-client-deps/CONTROL | 2 +- cmake/ports/nvtt/0001-Build-on-aarch64.patch | 37 ++++++++++ ...include-sysctl.h-to-build-on-linux-a.patch | 25 +++++++ cmake/ports/nvtt/portfile.cmake | 7 ++ hifi_qt.py | 74 ++++++++++++++----- hifi_vcpkg.py | 11 ++- plugins/CMakeLists.txt | 7 +- 10 files changed, 150 insertions(+), 26 deletions(-) create mode 100644 cmake/ports/nvtt/0001-Build-on-aarch64.patch create mode 100644 cmake/ports/nvtt/0002-Hack-remove-include-sysctl.h-to-build-on-linux-a.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index f111f482ae..6abd8735f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,15 @@ endif() file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_env/EXTERNAL_BUILD_ASSETS.txt" "${EXTERNAL_BUILD_ASSETS}") MESSAGE(STATUS "EXTERNAL_BUILD_ASSETS: ${EXTERNAL_BUILD_ASSETS}") +# read USE_GLES enviroment variable and sets it as GLES option +# TODO still gets overwritten by "use GLES on linux aarch64" set(GLES_OPTION "$ENV{USE_GLES}") +# use GLES on linux aarch64 +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + set(GLES_OPTION ON) +endif() + # Will affect VCPKG dependencies file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/_env/USE_GLES.txt" "${GLES_OPTION}") MESSAGE(STATUS "GLES_OPTION: ${GLES_OPTION}") @@ -187,7 +194,7 @@ else () set(PLATFORM_QT_COMPONENTS WebEngine Xml) endif () -if (USE_GLES AND (NOT ANDROID)) +if (USE_GLES AND (NOT ANDROID AND NOT UNIX)) set(DISABLE_QML_OPTION ON) endif() diff --git a/cmake/externals/steamworks/CMakeLists.txt b/cmake/externals/steamworks/CMakeLists.txt index 1ec72d7d28..f418b82ab5 100644 --- a/cmake/externals/steamworks/CMakeLists.txt +++ b/cmake/externals/steamworks/CMakeLists.txt @@ -54,7 +54,7 @@ elseif(APPLE) LOG 1 ) -elseif(NOT ANDROID) +elseif(NOT ANDROID AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") # FIXME need to account for different architectures set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${SOURCE_DIR}/redistributable_bin/linux64/libsteam_api.so CACHE STRING INTERNAL) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 108786a651..0689b36f60 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -30,7 +30,7 @@ macro(SETUP_HIFI_LIBRARY) foreach(SRC ${AVX2_SRCS}) if (WIN32) set_source_files_properties(${SRC} PROPERTIES COMPILE_FLAGS /arch:AVX2) - elseif (APPLE OR (UNIX AND NOT ANDROID)) + elseif (APPLE OR (UNIX AND NOT ANDROID AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")) set_source_files_properties(${SRC} PROPERTIES COMPILE_FLAGS "-mavx2 -mfma") endif() endforeach() diff --git a/cmake/ports/hifi-client-deps/CONTROL b/cmake/ports/hifi-client-deps/CONTROL index 4a8a2bc44e..3a8c4693b3 100644 --- a/cmake/ports/hifi-client-deps/CONTROL +++ b/cmake/ports/hifi-client-deps/CONTROL @@ -1,4 +1,4 @@ Source: hifi-client-deps Version: 0.1 Description: Collected dependencies for High Fidelity applications -Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr (linux|windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator +Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr ((linux&!arm)|windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator diff --git a/cmake/ports/nvtt/0001-Build-on-aarch64.patch b/cmake/ports/nvtt/0001-Build-on-aarch64.patch new file mode 100644 index 0000000000..4f737f78c4 --- /dev/null +++ b/cmake/ports/nvtt/0001-Build-on-aarch64.patch @@ -0,0 +1,37 @@ +commit 8909ba06ea1893a6e028836fbade28fd115ee1cc +Author: Julian Groß +Date: Wed Feb 17 04:51:49 2021 +0100 + + Enable building on aarch64 according to https://github.com/castano/nvidia-texture-tools/pull/309 and https://github.com/castano/nvidia-texture-tools/pull/322 + +diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp +index 9ab4525..e335f97 100644 +--- a/src/nvcore/Debug.cpp ++++ b/src/nvcore/Debug.cpp +@@ -1008,6 +1008,13 @@ void debug::dumpInfo() + #endif + } + ++static va_list getEmptyVAList(va_list list, ...) ++{ ++ va_start(list, list); ++ va_end(list); ++ return list; ++} ++ + /// Dump callstack using the specified handler. + void debug::dumpCallstack(MessageHandler *messageHandler, int callstackLevelsToSkip /*= 0*/) + { +@@ -1020,8 +1027,11 @@ void debug::dumpCallstack(MessageHandler *messageHandler, int callstackLevelsToS + Array lines; + writeStackTrace(trace, size, callstackLevelsToSkip + 1, lines); // + 1 to skip the call to dumpCallstack + ++ va_list empty; ++ empty = getEmptyVAList(empty); ++ + for (uint i = 0; i < lines.count(); i++) { +- messageHandler->log(lines[i], NULL); ++ messageHandler->log(lines[i], empty); + delete lines[i]; + } + } diff --git a/cmake/ports/nvtt/0002-Hack-remove-include-sysctl.h-to-build-on-linux-a.patch b/cmake/ports/nvtt/0002-Hack-remove-include-sysctl.h-to-build-on-linux-a.patch new file mode 100644 index 0000000000..78e92d38b8 --- /dev/null +++ b/cmake/ports/nvtt/0002-Hack-remove-include-sysctl.h-to-build-on-linux-a.patch @@ -0,0 +1,25 @@ +From 84dc6af45b1176a2b82d089239665cb3dc1584de Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Julian=20Gro=C3=9F?= +Date: Wed, 23 Dec 2020 07:33:39 +0100 +Subject: [PATCH] Hack: remove #include to build on + linux-aarch64 + +--- + src/nvthread/nvthread.cpp | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/nvthread/nvthread.cpp b/src/nvthread/nvthread.cpp +index 2b3abe6..cec9f4f 100644 +--- a/src/nvthread/nvthread.cpp ++++ b/src/nvthread/nvthread.cpp +@@ -11,7 +11,6 @@ + #include + #elif NV_OS_UNIX + #include +-#include + #include + #elif NV_OS_DARWIN + #import +-- +2.17.1 + diff --git a/cmake/ports/nvtt/portfile.cmake b/cmake/ports/nvtt/portfile.cmake index b21bb5609c..9088b62046 100644 --- a/cmake/ports/nvtt/portfile.cmake +++ b/cmake/ports/nvtt/portfile.cmake @@ -15,6 +15,13 @@ vcpkg_from_github( HEAD_REF master ) +if(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) + vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-Build-on-aarch64.patch" "${CMAKE_CURRENT_LIST_DIR}/0002-Hack-remove-include-sysctl.h-to-build-on-linux-a.patch" + ) +endif() + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} OPTIONS diff --git a/hifi_qt.py b/hifi_qt.py index 48e9b337a6..d2c56d0a34 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -53,6 +53,7 @@ endif() # OS dependent information system = platform.system() + cpu_architecture = platform.machine() if 'Windows' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-windows3.tar.gz%3FversionId=5ADqP0M0j5ZfimUHrx4zJld6vYceHEsI' @@ -62,27 +63,64 @@ endif() import distro dist = distro.linux_distribution() - if distro.id() == 'ubuntu': - u_major = int( distro.major_version() ) - u_minor = int( distro.minor_version() ) + if 'x86_64' == cpu_architecture: + if distro.id() == 'ubuntu': + u_major = int( distro.major_version() ) + u_minor = int( distro.minor_version() ) - if u_major == 16: - self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz' - elif u_major == 18: - self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-18.04.tar.gz' - elif u_major == 19 and u_minor == 10: - self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.6-ubuntu-19.10.tar.xz' - elif u_major > 19: - print("We don't support " + distro.name(pretty=True) + " yet. Perhaps consider helping us out?") - raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + if u_major == 16: + self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz' + elif u_major == 18: + self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-18.04.tar.gz' + elif u_major == 19 and u_minor == 10: + self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.6-ubuntu-19.10.tar.xz' + elif u_major > 19: + print("We don't support " + distro.name(pretty=True) + " on x86_64 yet. Perhaps consider helping us out?") + raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + else: + print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); + raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') else: - print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); - raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') + print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.") + print("It's also possible to build Qt for your distribution, please see the documentation at:") + print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") + raise Exception('UNKNOWN LINUX VERSION!!!') + elif 'aarch64' == cpu_architecture: + if distro.id() == 'ubuntu': + u_major = int( distro.major_version() ) + u_minor = int( distro.minor_version() ) + + if u_major == 18: + self.qtUrl = 'http://motofckr9k.ddns.net/vircadia_packages/qt5-install-5.15.2-ubuntu-18.04-aarch64_test.tar.xz' + elif u_major > 19: + print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") + raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + else: + print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); + raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') + + elif distro.id() == 'debian': + u_major = int( distro.major_version() ) + u_minor = int( distro.minor_version() ) + + if u_major == 10: + #self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz' + print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") + raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + elif u_major > 10: + print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") + raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + else: + print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); + raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') + else: + print("Sorry, " + distro.name(pretty=True) + " is not supported on aarch64. Please consider helping us out.") + print("It's also possible to build Qt for your distribution, please see the documentation at:") + print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") + raise Exception('UNKNOWN LINUX VERSION!!!') else: - print("Sorry, " + distro.name(pretty=True) + " is not supported. Please consider helping us out.") - print("It's also possible to build Qt for your distribution, please see the documentation at:") - print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") - raise Exception('UNKNOWN LINUX VERSION!!!') + raise Exception('UNKNOWN CPU ARCHITECTURE!!!') + else: print("System : " + platform.system()) print("Architecture: " + platform.architecture()) diff --git a/hifi_vcpkg.py b/hifi_vcpkg.py index ebdfb6c972..fb77fd2507 100644 --- a/hifi_vcpkg.py +++ b/hifi_vcpkg.py @@ -44,13 +44,14 @@ endif() self.assets_url = self.readVar('EXTERNAL_BUILD_ASSETS') # The noClean flag indicates we're doing weird dependency maintenance stuff - # i.e. we've got an explicit checkout of vcpkg and we don't want the script to - # do stuff it might otherwise do. It typically indicates that we're using our + # i.e. we've got an explicit checkout of vcpkg and we don't want the script to + # do stuff it might otherwise do. It typically indicates that we're using our # own git checkout of vcpkg and manually managing it self.noClean = False # OS dependent information system = platform.system() + machine = platform.machine() if 'HIFI_VCPKG_PATH' in os.environ: self.path = os.environ['HIFI_VCPKG_PATH'] @@ -105,6 +106,12 @@ endif() self.bootstrapEnv['CXXFLAGS'] = '-D_CTERMID_H_' if usePrebuilt: self.prebuiltArchive = self.assets_url + "/dependencies/vcpkg/builds/vcpkg-osx.tgz%3FversionId=6JrIMTdvpBF3MAsjA92BMkO79Psjzs6Z" + elif 'Linux' == system and 'aarch64' == machine: + self.exe = os.path.join(self.path, 'vcpkg') + self.bootstrapCmds = [ os.path.join(self.path, 'bootstrap-vcpkg.sh'), '-disableMetrics' ] + self.vcpkgUrl = 'http://motofckr9k.ddns.net/vircadia_packages/vcpkg-2020.11-1_arm64.tar.xz' + self.vcpkgHash = 'f39fa1c34d2ba820954b8ce4acc05e3d0ce5fa5efe5440516ba910ff222c85c658ba4bbfc92b3fa6cbb594f99be115cda69ebe44ed38d4d3988058fb1faefbb3' + self.hostTriplet = 'arm64-linux' else: self.exe = os.path.join(self.path, 'vcpkg') self.bootstrapCmds = [ os.path.join(self.path, 'bootstrap-vcpkg.sh'), '-disableMetrics' ] diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index a72371f544..195021e2fe 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -47,11 +47,14 @@ endif() # server-side plugins set(DIR "pcmCodec") add_subdirectory(${DIR}) -set(DIR "hifiCodec") -add_subdirectory(${DIR}) set(DIR "opusCodec") add_subdirectory(${DIR}) +if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + set(DIR "hifiCodec") + add_subdirectory(${DIR}) +endif() + # example plugins set(DIR "JSAPIExample") add_subdirectory(${DIR})