cd "${isim}c-$surum-src"
_date=2019-05-23
_rustc=1.35.0
_cargo=0.36.0
mkdir -p build/cache/$_date
cp $KAYNAKLAR_DEPO/rustc-${_rustc}-x86_64-unknown-linux-gnu.tar.gz build/cache/$_date/
cp $KAYNAKLAR_DEPO/rust-std-${_rustc}-x86_64-unknown-linux-gnu.tar.gz build/cache/$_date/
cp $KAYNAKLAR_DEPO/cargo-${_cargo}-x86_64-unknown-linux-gnu.tar.gz build/cache/$_date/

#export RUSTC_WRAPPER=/usr/bin/ccache # ccache i eklemek gerekebilir-hızlı derleme için

cat <<- EOF > $SRC/config.toml
	[llvm]
	link-shared = true

	[install]
	prefix = "/usr"

	[rust]
	channel = "stable"
	rpath = false
	codegen-tests = false
	debuginfo = true
    debuginfo-lines = true

	[build]
	docs = false
	extended = true
	python = "python3"
EOF
	# part of [build] options
        if [ -e '/usr/bin/rustc' ]; then
		if [ -z "$(/usr/bin/ldd /usr/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so | egrep '.*libLLVM-.*.so => not found')" ]; then
cat <<- EOF >> $SRC/config.toml
	cargo = "/usr/bin/cargo"
	rustc = "/usr/bin/rustc"
EOF
		else
			echo 'llvm broken symlink detected, not using system rust to bootstrap'
		fi
        fi

cat <<- EOF >> $SRC/config.toml
	[target.x86_64-unknown-linux-gnu]
	llvm-config = "/usr/bin/llvm-config"
EOF

cat $SRC/config.toml

mkdir "$KAYNAKLAR_DEPO/rust" || true
export CARGO_HOME="$KAYNAKLAR_DEPO/rust"
rm -rf $CARGO_HOME

export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"
/usr/bin/python3 ./x.py dist --config="${SRC}"/config.toml -j"$(nproc)"
