Skip to content

Commit

Permalink
Add a CMakeLists.txt to initialize and drive the first build.
Browse files Browse the repository at this point in the history
This keeps all the environment variables sane and allows for
out-of-this-tree builds.

Usage:
    cmake -B ../build -DINSTALL_ROOT=/local/mnt/new-toolchain_for_hexagon/install

cd to ../build and issue a, "make tools" command to build everything.

Signed-off-by: Sid Manning <sidneym@quicinc.com>
  • Loading branch information
SidManning committed Feb 27, 2025
1 parent 74fe78e commit e662cf4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
59 changes: 59 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
cmake_minimum_required(VERSION 3.22)
project(
"Hexagon open source toolchain"
DESCRIPTION "It is a sample toolchain to support Hexagon"
HOMEPAGE_URL "https://github.com/quic/toolchain_for_hexagon"
LANGUAGES NONE)


# Set variables with CACHE option to allow command line override
set(HOST_CLANG_VER 20 CACHE STRING "Host Clang version")
set(ARTIFACT_TAG 20.0.0 CACHE STRING "Artifact tag")
set(INSTALL_ROOT /tmp/$ENV{USER}/hexagon-qemu CACHE STRING "Install root")
set(TOOLCHAIN_INSTALL ${INSTALL_ROOT}/clang+llvm-${ARTIFACT_TAG}-cross-hexagon-unknown-linux-musl)
set(ROOT_INSTALL ${INSTALL_ROOT}/install_rootfs)
set(ARTIFACT_BASE ${INSTALL_ROOT}/artifacts)

set(TOOLCHAIN_INSTALL_REL ${TOOLCHAIN_INSTALL})
set(TOOLCHAIN_BIN ${TOOLCHAIN_INSTALL}/x86_64-linux-gnu/bin)
set(TOOLCHAIN_LIB ${TOOLCHAIN_INSTALL}/x86_64-linux-gnu/lib)
set(HEX_SYSROOT ${TOOLCHAIN_INSTALL}/x86_64-linux-gnu/target/hexagon-unknown-linux-musl)
set(HEX_TOOLS_TARGET_BASE ${HEX_SYSROOT}/usr)
set(ROOT_INSTALL_REL ${ROOT_INSTALL})
set(ROOTFS ${ROOT_INSTALL})
set(RESULTS_DIR ${ARTIFACT_BASE}/${ARTIFACT_TAG})

# Custom commands
add_custom_target(setup
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARTIFACT_BASE}
COMMAND ${CMAKE_COMMAND} -E make_directory ${RESULTS_DIR}
COMMAND ${CMAKE_COMMAND} -E echo_append ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E echo_append ${TOOLCHAIN_INSTALL_REL}
)

add_custom_target(clone
DEPENDS setup
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get-src-repos.sh ${CMAKE_CURRENT_SOURCE_DIR} ${TOOLCHAIN_INSTALL_REL}
)

add_custom_target(eld
DEPENDS clone
COMMAND ${CMAKE_COMMAND} -E chdir llvm-project git clone git@github.qualcomm.com:cgit/eld.git
)

#
# NOTE:
# DEPENDS eld
# Remove this when incrementally building
# the scripts are very picky about running more than once.
#
add_custom_target(tools
DEPENDS eld
COMMAND
env TOOLCHAIN_INSTALL=${TOOLCHAIN_INSTALL}
env ROOT_INSTALL=${ROOT_INSTALL}
env ARTIFACT_BASE=${ARTIFACT_BASE}
env ARTIFACT_TAG=${ARTIFACT_TAG}
${CMAKE_CURRENT_SOURCE_DIR}/build-toolchain.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
6 changes: 3 additions & 3 deletions build-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ build_clang_rt_builtins() {

config_kernel() {
cd ${BASE}
mkdir obj_linux
mkdir -p obj_linux
cd linux
make O=../obj_linux ARCH=hexagon \
CROSS_COMPILE=hexagon-unknown-linux-musl- \
Expand Down Expand Up @@ -253,7 +253,7 @@ build_qemu() {
--enable-slirp \
--enable-plugins \
--disable-containers \
--python=$(which python3.8) \
--python=$(which python) \
--target-list=hexagon-softmmu,hexagon-linux-user --prefix=${TOOLCHAIN_INSTALL}/x86_64-linux-gnu \

# --cc=clang \
Expand Down Expand Up @@ -322,7 +322,7 @@ which clang
clang --version
ninja --version
cmake --version
python3.8 --version
python --version

build_llvm_clang

Expand Down
4 changes: 3 additions & 1 deletion get-src-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ git clone -q --branch=hexagon https://github.com/quic/musl &
git clone -q https://github.com/quic/hexagonMVM &
git clone -q https://github.com/qemu/qemu &

gitdirs="qemu llvm-test-suite musl linux busybox hexagonMVM llvm-project libc-test buildroot cpython"

wait

dump_checkout_info() {
out=${1}
mkdir -p ${out}
for d in ./*
for d in ${gitdirs}
do
if [[ -d ${d} ]]; then
proj=$(basename ${d})
Expand Down

0 comments on commit e662cf4

Please sign in to comment.