Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toolchain: abort if environment is not valid #168

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions toolchain/build-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@ declare -A TOOLCHAN_TO_PHOENIX_TARGETS=(
[sparc-phoenix]="sparcv8leon3-gr716 sparcv8leon3-gr712rc"
)

if [ -z "$1" ] || [ -z "${TOOLCHAN_TO_PHOENIX_TARGETS[$1]}" ]; then
TARGET="$1"
BUILD_ROOT="$2"

if [ -z "$TARGET" ] || [ -z "${TOOLCHAN_TO_PHOENIX_TARGETS[$TARGET]}" ]; then
echo "Missing or invalid target provided! Abort."
echo "officially supported targets:"
printf "%s\n" "${!TOOLCHAN_TO_PHOENIX_TARGETS[@]}"
exit 1
fi

PHOENIX_TARGETS="${TOOLCHAN_TO_PHOENIX_TARGETS[$1]}"
PHOENIX_TARGETS="${TOOLCHAN_TO_PHOENIX_TARGETS[$TARGET]}"

if [ -z "$2" ]; then
if [ -z "$BUILD_ROOT" ]; then
echo "No toolchain install path provided! Abort."
exit 1
fi

if [ "${2:0:1}" != "/" ]; then
if [ "${BUILD_ROOT:0:1}" != "/" ]; then
echo "Path must not be relative."
exit 1
fi
Expand All @@ -42,15 +45,28 @@ if [ ! -f "$SCRIPT_DIR/../../phoenix-rtos-kernel/Makefile" ] || [ ! -f "$SCRIPT_
exit 1
fi

# Those env variables override command line options passed to configure scripts
# This check was added due to libstdc++ configure using host compiler instead of cross compiler
# TODO: check if all stages are affected. If not then consider using unset in those stages
if [[ -v CC || -v CFLAGS || -v LIBS || -v CPPFLAGS || -v CXX || -v CXXFLAGS || -v CPP || -v CXXCPP || -v CXXFILT ]]; then
echo "Environment contains variables that should not be set. Abort."
echo "Make sure to unset CC CFLAGS LIBS CPPFLAGS CXX CXXFLAGS CPP CXXCPP CXXFILT"
exit 1
fi

if command -v "${TARGET}-gcc" > /dev/null; then
echo "Command \"${TARGET}-gcc\" found in PATH. Abort."
echo "Make sure to to remove existing toolchain from PATH"
exit 1
fi

# old legacy versions of the compiler:
#BINUTILS=binutils-2.28
#GCC=gcc-7.1.0

BINUTILS=binutils-2.34
GCC=gcc-9.5.0

TARGET="$1"
BUILD_ROOT="$2"
TOOLCHAIN_PREFIX="${BUILD_ROOT}/${TARGET}"
SYSROOT="${TOOLCHAIN_PREFIX}/${TARGET}"
MAKEFLAGS="-j9 -s"
Expand Down
Loading