This guide gives a brief overview of the Morello GNU Toolchain and how to make use of it within the context of the Morello SDK.
For more information about the Morello GNU toolchain please see Arm Developer.
The Morello SDK includes a binary release of the Morello GNU toolchain: this includes ports of GCC, binutils, and glibc for Morello.
To build a hello world program for pure-capability Morello using the GNU toolchain, set up the docker image as described in the introduction.
At this point create the following file and directory structure:
workspace/
|-> helloworld/
|-> main.c
with main.c
as follows:
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
int main(void)
{
printf("Hello from Morello!\n");
return 0;
}
and then in the helloworld
directory run:
source /morello/env/morello-sdk
to set up the environment, and finally:
aarch64-none-linux-gnu-gcc -o helloworld -march=morello+c64 -mabi=purecap -static main.c
to build a statically-linked helloworld
program. You should then be
able to run the program on any Morello Linux system.
If you prefer, you can use the following Makefile to build the above hello world example, which could serve as the starting point for a larger project:
# SPDX-License-Identifier: BSD-3-Clause
CC=aarch64-none-linux-gnu-gcc
OUT=bin
all: ${OUT} ${OUT}/helloworld
${OUT}:
mkdir -p ${OUT}
${OUT}/main.o : main.c
${CC} -o $@ -c -march=morello+c64 -mabi=purecap $<
${OUT}/helloworld : ${OUT}/main.o
${CC} -o $@ -static -march=morello+c64 -mabi=purecap $^
.PHONY: clean
clean:
rm -rf ${OUT}
Saving this as Makefile
in the helloworld
directory, so we now have
the following tree:
workspace/
|-> helloworld/
|-> main.c
|-> Makefile
you can run make
, which should produce an equivalent binary in
bin/helloworld
.