Skip to content

Commit 96c5875

Browse files
authored
Implement AArch64 support (#18)
1 parent be224c7 commit 96c5875

File tree

4 files changed

+779
-8
lines changed

4 files changed

+779
-8
lines changed

build.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function build_gcc() {
1616
fi
1717

1818
# Use our own config that sets a legacy glibc.
19-
cp ./crosstool-ng-config $CURRENT_DIR/crosstool-ng/.config
19+
cp ./crosstool-ng-config-$MACHINE $CURRENT_DIR/crosstool-ng/.config
2020

2121
if [[ ! -f $CURRENT_DIR/crosstool-ng/ct-ng ]]; then
2222
( cd $CURRENT_DIR/crosstool-ng; \
@@ -104,7 +104,7 @@ function build_llvm() {
104104

105105
function build_compiler-rt-builtins() {
106106

107-
if [[ ! -e ${install_dir}/lib/linux/libclang_rt.builtins-x86_64.a ]]; then
107+
if [[ ! -e ${install_dir}/lib/linux/libclang_rt.builtins-$MACHINE.a ]]; then
108108

109109
( cd $LLVM_SRC && \
110110
mkdir -p ${build_folder} && \
@@ -224,6 +224,18 @@ function make_symlink_real() {
224224

225225
set -e
226226

227+
MACHINE="$(uname -m)"
228+
if [ "$MACHINE" = "x86_64" ]
229+
then
230+
LLVM_MACHINE="X86"
231+
elif [ "$MACHINE" = "aarch64" ]
232+
then
233+
LLVM_MACHINE="AArch64"
234+
else
235+
echo "Unspported architecture" 1>&2
236+
exit 1
237+
fi
238+
227239
source ./config
228240

229241
TOOLCHAIN_DIR=$1
@@ -314,7 +326,7 @@ cc_compiler="gcc" \
314326
cxx_compiler="g++" \
315327
install_dir="$PREFIX" \
316328
llvm_projects='clang;lld' \
317-
targets_to_build="X86" \
329+
targets_to_build="$LLVM_MACHINE" \
318330
additional_linker_flags="" \
319331
additional_compiler_flags="-s" \
320332
additional_cmake="" \
@@ -333,7 +345,7 @@ cc_compiler="clang" \
333345
cxx_compiler="clang++" \
334346
install_dir="$PREFIX" \
335347
llvm_projects='libcxx;libcxxabi;libunwind' \
336-
targets_to_build='X86;BPF' \
348+
targets_to_build="$LLVM_MACHINE;BPF" \
337349
additional_linker_flags="" \
338350
additional_cmake="" \
339351
build_compiler_libs
@@ -343,7 +355,7 @@ cc_compiler="clang" \
343355
cxx_compiler="clang++" \
344356
install_dir="$TOOLCHAIN_DIR/final/$TUPLE/$TUPLE/sysroot/usr" \
345357
llvm_projects='libcxx;libcxxabi;libunwind' \
346-
targets_to_build='X86;BPF' \
358+
targets_to_build="$LLVM_MACHINE;BPF" \
347359
additional_linker_flags="" \
348360
additional_cmake="" \
349361
build_compiler_libs
@@ -371,7 +383,7 @@ cc_compiler="clang" \
371383
cxx_compiler="clang++" \
372384
install_dir="$PREFIX" \
373385
llvm_projects='clang;compiler-rt;lld' \
374-
targets_to_build="X86;BPF" \
386+
targets_to_build="$LLVM_MACHINE;BPF" \
375387
additional_compiler_flags="" \
376388
additional_linker_flags="-rtlib=compiler-rt -l:libc++abi.a -ldl -lpthread" \
377389
additional_cmake="${llvm_additional_cmake}" \
@@ -451,7 +463,7 @@ if [ $KEEP_INTERMEDIATE_STAGES -eq 0 ]; then
451463
mv "$SYSROOT" "$CURRENT_DIR"
452464
rm -r "$CURRENT_DIR/$TUPLE"
453465
rm -r "$TOOLCHAIN_DIR/stage1"
454-
rm -r "$LLVM_SRC"
466+
rm -rf "$LLVM_SRC" # Force needed for .git
455467
else
456468
ln -s "$SYSROOT" "$CURRENT_DIR"
457469
fi

config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# For GCC configurations please look at crosstool-ng-config
33

44
# The vendor part has to be changed also in the crosstool-ng-config file
5-
TUPLE=x86_64-osquery-linux-gnu
5+
TUPLE=$MACHINE-osquery-linux-gnu
66

77
ZLIB_VER="1.2.11"
88
ZLIB_URL="https://zlib.net/zlib-${ZLIB_VER}.tar.gz"

0 commit comments

Comments
 (0)