build: Update to support multi-arch builds.
This commit is contained in:
parent
0e325255f3
commit
a8848cce43
25 changed files with 114 additions and 66 deletions
|
@ -54,6 +54,8 @@ add_custom_command(OUTPUT scm_rev.cpp
|
|||
)
|
||||
|
||||
add_library(common STATIC
|
||||
aarch64/cpu_detect.cpp
|
||||
aarch64/cpu_detect.h
|
||||
alignment.h
|
||||
announce_multiplayer_room.h
|
||||
archives.h
|
||||
|
@ -124,34 +126,21 @@ add_library(common STATIC
|
|||
timer.h
|
||||
vector_math.h
|
||||
web_result.h
|
||||
x64/cpu_detect.cpp
|
||||
x64/cpu_detect.h
|
||||
x64/xbyak_abi.h
|
||||
x64/xbyak_util.h
|
||||
zstd_compression.cpp
|
||||
zstd_compression.h
|
||||
)
|
||||
|
||||
if(ARCHITECTURE_x86_64)
|
||||
target_sources(common
|
||||
PRIVATE
|
||||
x64/cpu_detect.cpp
|
||||
|
||||
x64/cpu_detect.h
|
||||
x64/xbyak_abi.h
|
||||
x64/xbyak_util.h
|
||||
)
|
||||
elseif(ARCHITECTURE_arm64)
|
||||
target_sources(common
|
||||
PRIVATE
|
||||
aarch64/cpu_detect.cpp
|
||||
aarch64/cpu_detect.h
|
||||
)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(common)
|
||||
|
||||
target_link_libraries(common PUBLIC fmt::fmt microprofile Boost::boost Boost::serialization)
|
||||
target_link_libraries(common PRIVATE libzstd_static)
|
||||
set_target_properties(common PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
|
||||
|
||||
if (ARCHITECTURE_x86_64)
|
||||
if ("x86_64" IN_LIST ARCHITECTURE)
|
||||
target_link_libraries(common PRIVATE xbyak)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/arch.h"
|
||||
#if CITRA_ARCH(arm64)
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
@ -110,3 +113,5 @@ const CPUCaps& GetCPUCaps() {
|
|||
}
|
||||
|
||||
} // namespace Common
|
||||
|
||||
#endif // CITRA_ARCH(arm64)
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/arch.h"
|
||||
#if CITRA_ARCH(arm64)
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Common {
|
||||
|
@ -29,3 +32,5 @@ struct CPUCaps {
|
|||
const CPUCaps& GetCPUCaps();
|
||||
|
||||
} // namespace Common
|
||||
|
||||
#endif // CITRA_ARCH(arm64)
|
||||
|
|
13
src/common/arch.h
Normal file
13
src/common/arch.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2023 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <boost/predef.h>
|
||||
|
||||
#define CITRA_ARCH(NAME) (CITRA_ARCH_##NAME)
|
||||
|
||||
#define CITRA_ARCH_x86_64 BOOST_ARCH_X86_64
|
||||
#define CITRA_ARCH_arm64 \
|
||||
(BOOST_ARCH_ARM >= BOOST_VERSION_NUMBER(8, 0, 0) && BOOST_ARCH_WORD_BITS == 64)
|
|
@ -5,8 +5,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "common/arch.h"
|
||||
|
||||
#if !defined(ARCHITECTURE_x86_64)
|
||||
#if !CITRA_ARCH(x86_64)
|
||||
#include <cstdlib> // for exit
|
||||
#endif
|
||||
#include "common/common_types.h"
|
||||
|
@ -36,7 +37,7 @@
|
|||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
#ifdef ARCHITECTURE_x86_64
|
||||
#if CITRA_ARCH(x86_64)
|
||||
#define Crash() __asm__ __volatile__("int $3")
|
||||
#else
|
||||
#define Crash() exit(1)
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include "common/arch.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/telemetry.h"
|
||||
|
||||
#ifdef ARCHITECTURE_x86_64
|
||||
#if CITRA_ARCH(x86_64)
|
||||
#include "common/x64/cpu_detect.h"
|
||||
#endif
|
||||
|
||||
|
@ -54,7 +55,7 @@ void AppendBuildInfo(FieldCollection& fc) {
|
|||
}
|
||||
|
||||
void AppendCPUInfo(FieldCollection& fc) {
|
||||
#ifdef ARCHITECTURE_x86_64
|
||||
#if CITRA_ARCH(x86_64)
|
||||
fc.AddField(FieldType::UserSystem, "CPU_Model", Common::GetCPUCaps().cpu_string);
|
||||
fc.AddField(FieldType::UserSystem, "CPU_BrandString", Common::GetCPUCaps().brand_string);
|
||||
fc.AddField(FieldType::UserSystem, "CPU_Extension_x64_AES", Common::GetCPUCaps().aes);
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/arch.h"
|
||||
#if CITRA_ARCH(x86_64)
|
||||
|
||||
#include <cstring>
|
||||
#include "common/common_types.h"
|
||||
#include "common/x64/cpu_detect.h"
|
||||
|
@ -144,3 +147,5 @@ const CPUCaps& GetCPUCaps() {
|
|||
}
|
||||
|
||||
} // namespace Common
|
||||
|
||||
#endif // CITRA_ARCH(x86_64)
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/arch.h"
|
||||
#if CITRA_ARCH(x86_64)
|
||||
|
||||
namespace Common {
|
||||
|
||||
/// x86/x64 CPU capabilities that may be detected by this module
|
||||
|
@ -33,3 +36,5 @@ struct CPUCaps {
|
|||
const CPUCaps& GetCPUCaps();
|
||||
|
||||
} // namespace Common
|
||||
|
||||
#endif // CITRA_ARCH(x86_64)
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/arch.h"
|
||||
#if CITRA_ARCH(x86_64)
|
||||
|
||||
#include <bitset>
|
||||
#include <initializer_list>
|
||||
#include <xbyak/xbyak.h>
|
||||
|
@ -228,3 +231,5 @@ inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::bits
|
|||
}
|
||||
|
||||
} // namespace Common::X64
|
||||
|
||||
#endif // CITRA_ARCH(x86_64)
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/arch.h"
|
||||
#if CITRA_ARCH(x86_64)
|
||||
|
||||
#include <type_traits>
|
||||
#include <xbyak/xbyak.h>
|
||||
#include "common/x64/xbyak_abi.h"
|
||||
|
@ -45,3 +48,5 @@ inline void CallFarFunction(Xbyak::CodeGenerator& code, const T f) {
|
|||
}
|
||||
|
||||
} // namespace Common::X64
|
||||
|
||||
#endif // CITRA_ARCH(x86_64)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue