Skip to content

Commit

Permalink
env-setup.sh: Remove GNU tools in the Docker image before building
Browse files Browse the repository at this point in the history
This will help ensure that the GNU tools aren't hard coded anywhere as
the goal of the LLVM tools is to be as compatible as possible.

Closes: ClangBuiltLinux#122
Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed Apr 22, 2019
1 parent 5df0988 commit 4871f8b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions env-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,32 @@ ccache --set-config=cache_dir=/travis/.ccache

# Clear out the stats so we actually know the cache stats
ccache -z

# Ensure that GNU tools are not available when using LLVM tools
function remove() {
mapfile -t files < <(type -ap "${@}")
for file in "${files[@]}"; do rm -vf "${file}"; done
}

case ${ARCH:=arm64} in
arm32*) CROSS_COMPILE=arm-linux-gnueabi- ;;
arm64) CROSS_COMPILE=aarch64-linux-gnu- ;;
ppc32) CROSS_COMPILE=powerpc-linux-gnu- ;;
ppc64le) CROSS_COMPILE=powerpc64le-linux-gnu- ;;
esac

# Remove the target's tools
remove "${CROSS_COMPILE:-}"ar
remove "${CROSS_COMPILE:-}"gcc
[[ ${LD:-} =~ ld.lld ]] && remove ${CROSS_COMPILE:-}{ld,ld.bfd,ld.gold}

# Remove the host tools if we are cross compiling
if [[ -n ${CROSS_COMPILE:-} ]]; then
remove ar
remove gcc
[[ ${LD:-} =~ ld.lld ]] && remove {ld,ld.bfd,ld.gold}
fi

# Ensure that we always exit cleanly because a bash script's
# exit code is always the code of the last command
exit 0

0 comments on commit 4871f8b

Please sign in to comment.