# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by scripts/Create-CopyPatch.
# 
# T2 SDE: package/.../clang/parse-config-5
# Copyright (C) 2010 - 2020 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---

if ! atstage toolchain; then
  for x in CC CXX KCC; do
	if eval '[ "$SDECFG_DEFAULT_'$x'" = "clang" ]'; then
		case "$x" in
			CC)
				#[[ "$SDECFG_OPT" = size* ]] && var_append GCC_WRAPPER_APPEND ' ' "-Oz"
				[ "$SDECFG_LTO" != 0 ] && ! hasflag NO-LTO &&
					var_append GCC_WRAPPER_APPEND " " "-fuse-ld=lld -c?:-O2"
				z="${archprefix}clang" ;;
			CXX)	z="${archprefix}clang++" ;;
			KCC)	z="${archprefix}clang"
				if [ "$SDECFG_OPT" = "size" ]; then
				    var_insert KCC_WRAPPER_REMOVE " " "-O -O[0-9]"
				    var_insert KCC_WRAPPER_INSERT " " "-Os"
				fi
				;;
			*)	z="clang_$X_NOT_YET_IMPLEMENTED" ;;
		esac
		for y in $z; do
			[ "`type -p $y`" ] && export $x=$y
		done
	fi
  done
fi
