Merge pull request #3405 from cirosec/feature/fix-android-cross-compilation

Fix build issues with Android NDK
This commit is contained in:
Iceman
2026-07-03 19:11:31 +07:00
committed by GitHub
7 changed files with 44 additions and 10 deletions
+17 -1
View File
@@ -501,6 +501,22 @@ set (TARGET_SOURCES
${CMAKE_BINARY_DIR}/version_pm3.c
)
# Enable AVX2 support for x86/x64
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|i.86")
set_source_files_properties(
src/loclass/cipher_bs_avx2.c
PROPERTIES COMPILE_OPTIONS "-mavx2"
)
endif()
# Enable AVX 512 support for x64
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
set_source_files_properties(
src/loclass/cipher_bs_avx512.c
PROPERTIES COMPILE_OPTIONS "-mavx512f"
)
endif()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/version_pm3.c
COMMAND sh ${PM3_ROOT}/tools/mkversion.sh ${CMAKE_BINARY_DIR}/version_pm3.c || ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c
@@ -826,7 +842,7 @@ if ((NOT SKIPQT EQUAL 1) AND Qt6_FOUND)
target_include_directories(proxmark3 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endif()
target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
target_compile_options(proxmark3 PUBLIC -Wall -Werror -Wno-missing-braces -O3)
if (EMBED_READLINE)
if (NOT SKIPREADLINE EQUAL 1)
add_dependencies(proxmark3 ncurses readline)
+1 -1
View File
@@ -19,7 +19,7 @@ target_link_libraries(pm3rrg_rdv4_amiibo PRIVATE
m
pm3rrg_rdv4_mbedtls)
target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_amiibo PRIVATE -Wall -Werror -Wno-missing-braces -O3)
set_property(TARGET pm3rrg_rdv4_amiibo PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(pm3rrg_rdv4_amiibo PRIVATE amiitool
+1 -1
View File
@@ -5,7 +5,7 @@ add_library(pm3rrg_rdv4_id48 STATIC
id48/src/id48_generator.c
id48/src/id48_recover.c
)
target_compile_options( pm3rrg_rdv4_id48 PRIVATE -Wpedantic -Wall -Werror -O3 -Wno-unknown-pragmas -Wno-inline -Wno-unused-function -DID48_NO_STDIO)
target_compile_options( pm3rrg_rdv4_id48 PRIVATE -Wpedantic -Wall -Werror -O3 -Wno-unknown-pragmas -Wno-inline -Wno-unused-function -Wno-missing-braces -DID48_NO_STDIO)
target_include_directories(pm3rrg_rdv4_id48 PRIVATE id48/public)
target_include_directories(pm3rrg_rdv4_id48 INTERFACE id48/public)
set_property(TARGET pm3rrg_rdv4_id48 PROPERTY POSITION_INDEPENDENT_CODE ON)
+1 -1
View File
@@ -52,5 +52,5 @@ if (NOT MINGW)
endif (NOT MINGW)
target_include_directories(pm3rrg_rdv4_lua INTERFACE liblua)
target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -Wno-missing-braces -Wno-deprecated-declarations -O3)
set_property(TARGET pm3rrg_rdv4_lua PROPERTY POSITION_INDEPENDENT_CODE ON)
+18
View File
@@ -30,6 +30,24 @@
# include "pthread_spin_lock_shim.h" // spinlock shim for OSX ..
#endif
#ifdef __ANDROID__
//Spinlock patch for building with Android NDK
typedef pthread_mutex_t pthread_spinlock_t;
#define pthread_spin_init(lock, pshared) \
pthread_mutex_init(lock, NULL)
#define pthread_spin_lock(lock) \
pthread_mutex_lock(lock)
#define pthread_spin_unlock(lock) \
pthread_mutex_unlock(lock)
#define pthread_spin_destroy(lock) \
pthread_mutex_destroy(lock)
#endif
#define MAX_PM3_INPUT_ARGS_LENGTH 4096
bool AlwaysAvailable(void) {
+3 -3
View File
@@ -18,7 +18,7 @@
#include <immintrin.h>
#if defined(__GNUC__) || defined(__clang__)
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ANDROID__)
#pragma GCC push_options
#pragma GCC target("avx2")
#endif
@@ -263,14 +263,14 @@ void doMAC_brute_match256(const uint64_t y_bits_bs[96 * BS256_WORDS],
_mm256_storeu_si256((__m256i *)match_out, mac_match);
}
#if defined(__GNUC__) || defined(__clang__)
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ANDROID__)
#pragma GCC pop_options
#endif
bool bs_avx2_supported(void) {
static int cached = -1;
if (cached < 0) {
#if defined(__GNUC__) || defined(__clang__)
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ANDROID__)
__builtin_cpu_init();
cached = __builtin_cpu_supports("avx2") ? 1 : 0;
#else
+3 -3
View File
@@ -19,7 +19,7 @@
#include <immintrin.h>
#if defined(__GNUC__) || defined(__clang__)
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ANDROID__)
#pragma GCC push_options
#pragma GCC target("avx512f")
#endif
@@ -291,14 +291,14 @@ void doMAC_brute_match512(const uint64_t y_bits_bs[96 * BS512_WORDS],
_mm512_storeu_si512((void *)match_out, mac_match);
}
#if defined(__GNUC__) || defined(__clang__)
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ANDROID__)
#pragma GCC pop_options
#endif
bool bs_avx512_supported(void) {
static int cached = -1;
if (cached < 0) {
#if defined(__GNUC__) || defined(__clang__)
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__ANDROID__)
__builtin_cpu_init();
cached = __builtin_cpu_supports("avx512f") ? 1 : 0;
#else