@@ -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
105105function 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
225225set -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+
227239source ./config
228240
229241TOOLCHAIN_DIR=$1
@@ -314,7 +326,7 @@ cc_compiler="gcc" \
314326cxx_compiler=" g++" \
315327install_dir=" $PREFIX " \
316328llvm_projects=' clang;lld' \
317- targets_to_build=" X86 " \
329+ targets_to_build=" $LLVM_MACHINE " \
318330additional_linker_flags=" " \
319331additional_compiler_flags=" -s" \
320332additional_cmake=" " \
@@ -333,7 +345,7 @@ cc_compiler="clang" \
333345cxx_compiler=" clang++" \
334346install_dir=" $PREFIX " \
335347llvm_projects=' libcxx;libcxxabi;libunwind' \
336- targets_to_build=' X86 ;BPF' \
348+ targets_to_build=" $LLVM_MACHINE ;BPF" \
337349additional_linker_flags=" " \
338350additional_cmake=" " \
339351build_compiler_libs
@@ -343,7 +355,7 @@ cc_compiler="clang" \
343355cxx_compiler=" clang++" \
344356install_dir=" $TOOLCHAIN_DIR /final/$TUPLE /$TUPLE /sysroot/usr" \
345357llvm_projects=' libcxx;libcxxabi;libunwind' \
346- targets_to_build=' X86 ;BPF' \
358+ targets_to_build=" $LLVM_MACHINE ;BPF" \
347359additional_linker_flags=" " \
348360additional_cmake=" " \
349361build_compiler_libs
@@ -371,7 +383,7 @@ cc_compiler="clang" \
371383cxx_compiler=" clang++" \
372384install_dir=" $PREFIX " \
373385llvm_projects=' clang;compiler-rt;lld' \
374- targets_to_build=" X86 ;BPF" \
386+ targets_to_build=" $LLVM_MACHINE ;BPF" \
375387additional_compiler_flags=" " \
376388additional_linker_flags=" -rtlib=compiler-rt -l:libc++abi.a -ldl -lpthread" \
377389additional_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
455467else
456468 ln -s " $SYSROOT " " $CURRENT_DIR "
457469fi
0 commit comments