Skip to content

Commit 4928f0b

Browse files
authored
Add big-endian build docs (#558)
1 parent 36aacfa commit 4928f0b

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

Docs/Building-BE.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Building Big Endian ASTC Encoder
2+
3+
**NOTE:** The current code is _NOT_ BE compatible, but we plan to fix this!
4+
5+
We don't officially support a big-endian compressor build, but ensuring the
6+
code is BE-compatible is good practice and some of the open source
7+
distributions still support BE platforms.
8+
9+
Even though Arm64 can run in a BE mode, it's now very rare in practice. It's no
10+
longer supported out of the box in the latest Arm upstream compiler releases,
11+
and getting hold of a sysroot is increasingly painful. To test BE builds I
12+
therefore cross-compile Linux builds for MIPS64 and use `qemu-user` to run
13+
them. This doesn't use a real sysroot, so everything must be compiled with
14+
`-static` linkage.
15+
16+
## Host software
17+
18+
Install the following host software:
19+
20+
```bash
21+
# Compiler
22+
sudo apt-get install g++-mips64-linux-gnuabi64
23+
24+
# Multi-arch libraries
25+
sudo apt-get install g++-multilib-mips64-linux-gnuabi64
26+
27+
# QEMU
28+
sudo apt-get install qemu-user-static
29+
sudo mkdir /etc/qemu-binfmt
30+
sudo ln -s /usr/mips64-linux-gnuabi64 /etc/qemu-binfmt/mips64
31+
```
32+
33+
## CMake toolchain file
34+
35+
Cross-compiling needs an correctly configured CMake, and the easiest way to
36+
do this consistently is to use a toolchain file. Create a `CMake-BE.toolchain`
37+
file with the following content in the root of the project:
38+
39+
```
40+
# Operating system
41+
set(CMAKE_SYSTEM_NAME Linux)
42+
43+
# Cross-compilers for C and C++
44+
set(CMAKE_C_COMPILER mips64-linux-gnuabi64-gcc)
45+
set(CMAKE_CXX_COMPILER mips64-linux-gnuabi64-g++)
46+
47+
# Compiler environment
48+
set(CMAKE_FIND_ROOT_PATH /usr/mips64-linux-gnuabi64)
49+
50+
# Default compiler and linker flags to use
51+
set(CMAKE_C_FLAGS_INIT -static)
52+
set(CMAKE_CXX_FLAGS_INIT -static)
53+
set(CMAKE_EXE_LINKER_FLAGS_INIT -static)
54+
set(CMAKE_SHARED_LINKER_FLAGS_INIT -static)
55+
set(CMAKE_MODULE_LINKER_FLAGS_INIT -static)
56+
57+
# Never match host tools
58+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
59+
60+
# Only match headers and libraries in the compiler environment
61+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
62+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
63+
```
64+
65+
## Build astcenc
66+
67+
Building uses CMake as normal, with the additional specification of the
68+
toolchain file to configure the build for cross-compilation.
69+
70+
```
71+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DASTCENC_ISA_NONE=ON -DCMAKE_TOOLCHAIN_FILE=../CMake-BE.toolchain ..
72+
```
73+
74+
## Run astcenc
75+
76+
The cross-compiled `astcenc` binary runs as normal, and can access host files, but must run through QEMU to do the instruction-set translation.
77+
78+
```
79+
qemu-mips64 ./bin/astcenc-none ...
80+
```
81+
82+
- - -
83+
84+
_Copyright © 2025, Arm Limited and contributors._

0 commit comments

Comments
 (0)