Skip to content

Commit 8b8f657

Browse files
6by9pelwell
authored andcommitted
buildme: Add option for ARM64 builds via either native or cross compile
Supports native builds on aarch64 machines. Supports making a 64-bit build via either cross compiling, or on aarch64 machines. Both options require the addition of --aarch64 to the command line, otherwise 32-bit libraries will be built. Cross compiling requires the aarch64-linux-gnu- compile tools to be installed (packages gcc-5-aarch64-linux-gnu and g++-aarch64-linux-gnu on Ubuntu).
1 parent 0b1293c commit 8b8f657

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ This repository contains the source code for the ARM side libraries used on Rasp
22
These typically are installed in /opt/vc/lib and includes source for the ARM side code to interface to:
33
EGL, mmal, GLESv2, vcos, openmaxil, vchiq_arm, bcm_host, WFC, OpenVG.
44

5-
Use buildme to build. It requires cmake to be installed and an arm cross compiler. It is set up to use this one:
5+
Use buildme to build. It requires cmake to be installed and an arm cross compiler. For 32 bit cross compiliation it is set up to use this one:
66
https://github.com/raspberrypi/tools/tree/master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian
77

8+
Whilst 64 bit userspace is not officially supported, some of the libraries will work for it. To cross compile, install gcc-aarch64-linux-gnu and g++-aarch64-linux-gnu first. For both native and cross compiles, add the option ```--aarch64``` to the buildme command.
9+
810
Note that this repository does not contain the source for the edidparser and vcdbg binaries due to licensing restrictions.

buildme

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
#!/bin/bash
22
BUILDTYPE=Release
3+
ARCH=`arch`
4+
ARM64=OFF
5+
CMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake
36

47
if [ "$1" = "--debug" ]; then
58
BUILDTYPE=Debug
69
shift
710
fi
811

12+
if [ "$1" = "--arm64" ]; then
13+
ARM64=ON
14+
CMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/aarch64-linux-gnu.cmake
15+
shift
16+
fi
17+
918
BUILDSUBDIR=`echo $BUILDTYPE | tr '[A-Z]' '[a-z]'`;
1019

11-
if [ "armv6l" = `arch` ] || [ "armv7l" = `arch` ]; then
20+
if [ $ARCH = "armv6l" ] || [ $ARCH = "armv7l" ] || [ $ARCH = "aarch64" ]; then
1221
# Native compile on the Raspberry Pi
1322
mkdir -p build/raspberry/$BUILDSUBDIR
1423
pushd build/raspberry/$BUILDSUBDIR
15-
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../..
16-
if [ "armv6l" = `arch` ]; then
24+
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 ../../..
25+
if [ $ARCH = "armv6l" ]; then
1726
make
1827
else
1928
make -j4
@@ -34,7 +43,7 @@ else
3443
# Cross compile on a more capable machine
3544
mkdir -p build/arm-linux/$BUILDSUBDIR
3645
pushd build/arm-linux/$BUILDSUBDIR
37-
cmake -DCMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../..
46+
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 ../../..
3847
make -j `nproc`
3948

4049
if [ "$1" != "" ]; then
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
#
3+
# CMake defines to cross-compile to ARM/Linux on BCM2708 using glibc.
4+
#
5+
6+
SET(CMAKE_SYSTEM_NAME Linux)
7+
SET(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
8+
SET(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
9+
SET(CMAKE_ASM_COMPILER aarch64-linux-gnu-gcc)
10+
SET(CMAKE_SYSTEM_PROCESSOR arm)
11+
12+
#ADD_DEFINITIONS("-march=armv6")
13+
#add_definitions("-mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -marm")
14+
15+
# rdynamic means the backtrace should work
16+
IF (CMAKE_BUILD_TYPE MATCHES "Debug")
17+
add_definitions(-rdynamic)
18+
ENDIF()
19+
20+
# avoids annoying and pointless warnings from gcc
21+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE")
22+
SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -c")

0 commit comments

Comments
 (0)