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 <natechancellor@gmail.com>
  • Loading branch information
nathanchance committed May 14, 2019
1 parent 4cd9785 commit 0e2a26e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions env-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,42 @@ 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 "${CROSS_COMPILE:-}"objcopy
remove "${CROSS_COMPILE:-}"objdump
remove "${CROSS_COMPILE:-}"nm
remove "${CROSS_COMPILE:-}"readelf
remove "${CROSS_COMPILE:-}"strip

# 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}
remove objcopy
remove objdump
remove nm
remove readelf
remove strip
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 0e2a26e

Please sign in to comment.