-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Note: This issue was copied from ggml-org#16658
Original Author: @DevGitPit
Original Issue Number: ggml-org#16658
Created: 2025-10-19T00:26:08Z
Git commit
Operating systems
Other? (Please let us know in description)
GGML backends
CPU
Problem description & steps to reproduce
Asked AI to prep this-
Bug Report: Linker Crash with Tagged Pointer Truncation on Android 15 (Termux/aarch64)
Summary
Building llama.cpp natively on Android 15 in Termux fails during the linking stage of certain binaries (llama-quantize, test binaries) with a linker crash related to tagged pointer truncation. The error only affects specific targets while others (llama-cli, llama-server) link successfully.
Error Message
Pointer tag for 0x652760ba5e was truncated, see 'https://source.android.com/devices/tech/debug/tagged-pointers'.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
c++: error: unable to execute command: Aborted
c++: error: linker command failed due to signal (use -v to see invocation)
make[2]: *** [tools/quantize/CMakeFiles/llama-quantize.dir/build.make:108: bin/llama-quantize] Error 1
Environment
Device Information
- Device: realme RMX3853
- Android Version: 15
- Kernel:
6.1.118-android14-11-o-g8c6105bdb579 #1 SMP PREEMPT - Architecture: aarch64 (arm64-v8a only)
CPU Features
fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
Termux Information
- Termux Version: 0.118.3
- APK Release: F_DROID
- Package Manager: apt
- Build System: cmake
- Compiler: Clang 21.1.3
llama.cpp Information
- Version: 0.9.4
- Commit: ee09828
Steps to Reproduce
1. Setup Termux Environment
pkg update && pkg upgrade
pkg install git cmake clang ccache2. Clone Repository
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp3. Build with Default Configuration
cmake -B build -DBUILD_SHARED_LIBS=OFF
cmake --build build --config Release -j $(nproc)4. Observe Failure
Build progresses to approximately 94% completion, successfully compiling all source files. The failure occurs during the linking stage of llama-quantize:
[ 94%] Linking CXX executable ../../bin/llama-quantize
Pointer tag for 0x652760ba5e was truncated
c++: error: unable to execute command: Aborted
c++: error: linker command failed due to signal (use -v to see invocation)
Build Configuration Details
CMake Configuration Output (relevant sections)
-- CMAKE_SYSTEM_PROCESSOR: aarch64
-- GGML_SYSTEM_ARCH: ARM
-- Found OpenMP_C: -fopenmp=libomp (found version "5.1")
-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.1")
-- ARM detected
-- ARM -mcpu not found, -mcpu=native will be used
-- Performing Test GGML_MACHINE_SUPPORTS_dotprod - Success
-- Performing Test GGML_MACHINE_SUPPORTS_i8mm - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_noi8mm - Success
-- Performing Test GGML_MACHINE_SUPPORTS_sve - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_nosve - Success
-- Performing Test GGML_MACHINE_SUPPORTS_sme - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_nosme - Success
-- ARM feature DOTPROD enabled
-- ARM feature FMA enabled
-- ARM feature FP16_VECTOR_ARITHMETIC enabled
-- Adding CPU backend variant ggml-cpu: -mcpu=native+dotprod+noi8mm+nosve+nosme
Compiler Flags Used
- Default cmake
RelWithDebInfobuild type -mcpu=native+dotprod+noi8mm+nosve+nosme(auto-detected)
Observations
Pattern of Failures
- ✅ Successful: Compilation of all
.cand.cppfiles - ✅ Successful: Linking of simpler binaries:
llama-clillama-serverllama-simplellama-embedding- Most example binaries
- ❌ Failed: Linking of specific binaries:
llama-quantize(consistently fails)test-grammar-parser(when building with tests enabled)- Other test binaries (intermittent)
Timing
- Failure occurs at ~94-96% build completion
- Only happens during the linking phase, never during compilation
- Appears to be related to binary size or complexity
Tagged Pointers Context
Android 15 implements Memory Tagging Extension (MTE) for enhanced memory safety. This feature uses the top byte of 64-bit pointers for tagging, which may cause compatibility issues with certain linker operations.
Attempted Workarounds
✅ Successful Workaround #1: Build Only Required Targets
cmake -B build -DBUILD_SHARED_LIBS=OFF
cmake --build build --target llama-cli llama-server -j $(nproc)Result: Successfully builds llama-cli and llama-server without errors.
✅ Successful Workaround #2: Disable Tools and Tests
cmake -B build \
-DBUILD_SHARED_LIBS=OFF \
-DLLAMA_BUILD_TOOLS=OFF \
-DLLAMA_BUILD_TESTS=OFF
cmake --build build --config Release -j $(nproc)Result: Successfully builds core binaries and examples.
✅ Successful Workaround #3: Manual Optimization Flags
cmake -B build \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-O3 -march=armv8.2-a+fp16+dotprod" \
-DCMAKE_CXX_FLAGS="-O3 -march=armv8.2-a+fp16+dotprod" \
-DGGML_NATIVE=OFF \
-DLLAMA_CURL=OFF
cmake --build build --target llama-cli llama-server -j $(nproc)Result: Successfully builds with full optimizations and avoids linker crash.
❌ Unsuccessful: Building All Targets
Any attempt to build llama-quantize or test binaries results in the linker crash.
Performance Note
Binaries built with the manual optimization flags (Workaround #3) show significantly better performance than those built with default settings:
- Manual flags: Proper use of NEON, FMA, FP16, DOTPROD optimizations
- Better vectorization and aggressive compiler optimizations from
-O3
Additional Context
Comparison with Other Android Versions
- Android 12 (tested on separate device): Same build configuration works without issues
- Android 14: Unknown (not tested)
- Android 15: Consistent linker crashes as described
Suspected Root Cause
This appears to be an interaction between:
- Clang 21.x linker (LLD)
- Android 15's Memory Tagging Extension
- Binary size/complexity thresholds
- Possibly related to LLVM's handling of tagged pointers in the linker
The selective nature of failures (simple binaries succeed, complex ones fail) suggests a threshold effect rather than a fundamental incompatibility.
Requests for Assistance
- Is this a known issue with Clang 21.x on Android 15?
- Should this be reported to LLVM's issue tracker as well?
- Are there linker flags that could disable memory tagging checks during linking?
- Can the build system be modified to handle this more gracefully (e.g., detect Android 15 and apply workarounds)?
Suggested Solutions
Short-term (for users)
- Use targeted builds:
cmake --build build --target llama-cli llama-server - Apply manual optimization flags as shown in Workaround Update documentation to specify C++23 compiler requirements (MBA-133) #3
Long-term (for llama.cpp)
- Detect Android 15 and automatically disable problematic build targets
- Add documentation about this issue for Termux/Android 15 users
- Investigate linker flags that might resolve the tagged pointer issue
- Consider adding a build option like
-DANDROID15_WORKAROUND=ON
System Information Dump
Full Termux System Info
Termux Variables:
TERMUX_API_VERSION=0.53.0
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=1109
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.3
TERMUX__HOME=/data/data/com.termux/files/home
TERMUX__PREFIX=/data/data/com.termux/files/usr
Packages CPU architecture:
aarch64
Subscribed repositories:
deb https://termux.danyael.xyz/termux/termux-main stable main
deb https://termux.danyael.xyz/termux/termux-x11 x11 main
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
Kernel build information:
Linux localhost 6.1.118-android14-11-o-g8c6105bdb579 #1 SMP PREEMPT Fri Aug 29 14:30:37 UTC 2025 aarch64 Android
Device: realme RMX3853
Android version: 15
Supported ABIs: arm64-v8a (64-bit only)
Note: The workarounds allow successful builds of essential binaries, so this issue does not block usage of llama.cpp on Android 15. However, it does prevent building the complete toolset and may indicate a broader compatibility concern with Android 15's memory tagging feature.
First Bad Commit
No response
Compile command
cmake -B build -DBUILD_SHARED_LIBS=OFF
cmake --build build --config Release -j $(nproc)Relevant log output
---above--