5 BASE
=$
(readlink
-f ${PWD})
7 TOOLCHAIN_INSTALL
=$
(readlink
-f "$TOOLCHAIN_INSTALL")
8 ROOTFS
=$
(readlink
-f "$ROOTFS")
10 TOOLCHAIN_BIN
=${TOOLCHAIN_INSTALL}/bin
11 HEX_SYSROOT
=${TOOLCHAIN_INSTALL}/hexagon-unknown-linux-musl
12 HEX_TOOLS_TARGET_BASE
=${HEX_SYSROOT}/usr
23 TEMP
="$(readlink -f "$PWD/tmp.
tar.gz
")"
24 wget
--quiet "$URL" -O "$TEMP"
26 tar xaf
"$TEMP" --strip-components=1
32 fetch
"$BASE/llvm-project" "$LLVM_URL"
33 cdp
"$BASE/build-llvm"
36 -DCMAKE_BUILD_TYPE=Release \
37 -DCMAKE_INSTALL_PREFIX=${TOOLCHAIN_INSTALL} \
38 -DLLVM_ENABLE_LLD=ON \
39 -DLLVM_TARGETS_TO_BUILD="Hexagon" \
40 -DLLVM_ENABLE_PROJECTS="clang;lld" \
41 "$BASE/llvm-project/llvm"
44 ln -sf clang hexagon-unknown-linux-musl-clang
45 ln -sf clang
++ hexagon-unknown-linux-musl-clang
++
46 ln -sf llvm-ar hexagon-unknown-linux-musl-ar
47 ln -sf llvm-objdump hexagon-unknown-linux-musl-objdump
48 ln -sf llvm-objcopy hexagon-unknown-linux-musl-objcopy
49 ln -sf llvm-readelf hexagon-unknown-linux-musl-readelf
50 ln -sf llvm-ranlib hexagon-unknown-linux-musl-ranlib
53 cat <<EOF > hexagon-unknown-linux-musl.cfg
54 -G0 --sysroot=${HEX_SYSROOT}
59 cdp
"$BASE/build-clang_rt"
61 -DCMAKE_BUILD_TYPE=Release \
62 -DLLVM_CONFIG_PATH="$BASE/build-llvm/bin/llvm-config" \
63 -DCMAKE_ASM_FLAGS="-G0 -mlong-calls -fno-pic --target=hexagon-unknown-linux-musl " \
64 -DCMAKE_SYSTEM_NAME=Linux \
65 -DCMAKE_C_COMPILER="${TOOLCHAIN_BIN}/hexagon-unknown-linux-musl-clang" \
66 -DCMAKE_ASM_COMPILER="${TOOLCHAIN_BIN}/hexagon-unknown-linux-musl-clang" \
67 -DCMAKE_INSTALL_PREFIX=${HEX_TOOLS_TARGET_BASE} \
68 -DCMAKE_CROSSCOMPILING=ON \
69 -DCMAKE_C_COMPILER_FORCED=ON \
70 -DCMAKE_CXX_COMPILER_FORCED=ON \
71 -DCOMPILER_RT_BUILD_BUILTINS=ON \
72 -DCOMPILER_RT_BUILTINS_ENABLE_PIC=OFF \
73 -DCMAKE_SIZEOF_VOID_P=4 \
74 -DCOMPILER_RT_OS_DIR= \
75 -DCAN_TARGET_hexagon=1 \
76 -DCAN_TARGET_x86_64=0 \
77 -DCOMPILER_RT_SUPPORTED_ARCH=hexagon \
78 -DLLVM_ENABLE_PROJECTS="compiler-rt" \
79 "$BASE/llvm-project/compiler-rt"
80 ninja install-compiler-rt
83 build_musl_headers
() {
84 fetch
"$BASE/musl" "$MUSL_URL"
87 CC
=${TOOLCHAIN_BIN}/hexagon-unknown-linux-musl-clang \
88 CROSS_COMPILE
=hexagon-unknown-linux-musl \
89 LIBCC
=${HEX_TOOLS_TARGET_BASE}/lib
/libclang_rt.builtins-hexagon.a \
90 CROSS_CFLAGS
="-G0 -O0 -mv65 -fno-builtin -fno-rounding-math --target=hexagon-unknown-linux-musl" \
91 .
/configure
--target=hexagon
--prefix=${HEX_TOOLS_TARGET_BASE}
92 PATH
=${TOOLCHAIN_BIN}:$PATH make CROSS_COMPILE
= install-headers
95 ln -sf hexagon-unknown-linux-musl hexagon
98 build_kernel_headers
() {
99 fetch
"$BASE/linux" "$LINUX_URL"
100 mkdir
-p "$BASE/build-linux"
102 make O
=..
/build-linux ARCH
=hexagon \
103 KBUILD_CFLAGS_KERNEL
="-mlong-calls" \
104 CC
=${TOOLCHAIN_BIN}/hexagon-unknown-linux-musl-clang \
105 LD
=${TOOLCHAIN_BIN}/ld.lld \
106 KBUILD_VERBOSE
=1 comet_defconfig
109 cd "$BASE/build-linux"
112 CC
=${TOOLCHAIN_BIN}/clang \
113 INSTALL_HDR_PATH
=${HEX_TOOLS_TARGET_BASE} \
121 CROSS_COMPILE
=hexagon-unknown-linux-musl- \
126 LIBCC
=${HEX_TOOLS_TARGET_BASE}/lib
/libclang_rt.builtins-hexagon.a \
127 CFLAGS
="-G0 -O0 -mv65 -fno-builtin -fno-rounding-math --target=hexagon-unknown-linux-musl" \
128 .
/configure
--target=hexagon
--prefix=${HEX_TOOLS_TARGET_BASE}
129 PATH
=${TOOLCHAIN_BIN}/:$PATH make CROSS_COMPILE
= install
130 cd ${HEX_TOOLS_TARGET_BASE}/lib
131 ln -sf libc.so ld-musl-hexagon.so
132 ln -sf ld-musl-hexagon.so ld-musl-hexagon.so
.1
133 cdp
${HEX_TOOLS_TARGET_BASE}/..
/lib
134 ln -sf ..
/usr
/lib
/ld-musl-hexagon.so
.1