broken more

This commit is contained in:
Cody P Schafer
2014-11-13 17:12:15 -05:00
parent d1c3e49ac2
commit e2d129ca8c
4 changed files with 149 additions and 78 deletions
+12 -17
View File
@@ -1,7 +1,5 @@
RUSTC = "rustc" RUSTC = "rustc"
RUSTC_ARCHFLAGS += "--target=target" RUSTC_ARCHFLAGS += "--target=${TARGET_SYS} -C rpath"
# BUILD_LDFLAGS # BUILD_LDFLAGS
# ${STAGING_LIBDIR_NATIVE} # ${STAGING_LIBDIR_NATIVE}
@@ -19,7 +17,10 @@ RUSTC_ARCHFLAGS += "--target=target"
RUST_PATH_NATIVE="${STAGING_LIBDIR_NATIVE}:${STAGING_BASE_LIBDIR_NATIVE}" RUST_PATH_NATIVE="${STAGING_LIBDIR_NATIVE}:${STAGING_BASE_LIBDIR_NATIVE}"
# FIXME: set based on whether we are native vs cross vs buildsdk, etc # FIXME: set based on whether we are native vs cross vs buildsdk, etc
RUST_PATH = "${RUST_PATH_NATIVE}" export RUST_PATH ??= "${RUST_PATH_NATIVE}"
# FIXME: set this to something (sysroot?) for each of target,native,cross
export RUST_TARGET_PATH = "${datadir}/rust/target"
CARGO = "cargo" CARGO = "cargo"
@@ -38,25 +39,20 @@ oe_cargo_config () {
# NOTE: we cannot pass more flags via this interface, the 'linker' is # NOTE: we cannot pass more flags via this interface, the 'linker' is
# assumed to be a path to a binary. If flags are needed, a wrapper must # assumed to be a path to a binary. If flags are needed, a wrapper must
# be used. # be used.
cat >.cargo/config <<EOF echo "paths = [" >.cargo/config
paths = [
EOF
for p in ${OECARGO_PATH}; do for p in ${OECARGO_PATH}; do
printf "\"%s\" " "$p" printf "\"%s\" " "$p"
done | sed -e 's/[ \n]+/,/g' -e 's/,$//' >>.cargo/config done | sed -e 's/[ \n]+/,/g' -e 's/,$//' >>.cargo/config
cat >>.cargo/config <<EOF echo "]" >>.cargo/config
]
[target.${RUST_TARGET_SYS}]
ar = "${TARGET_PREFIX}ar"
linker = "${TARGET_PREFIX}gcc"
EOF
} }
oe_cargo_patch () { oe_cargo_patch () {
cat >>Cargo.toml <<EOF cat >>Cargo.toml <<EOF
[profile.dev] [profile.dev]
rpath = true rpath = true
[profile.release]
rpath = true
EOF EOF
} }
@@ -64,8 +60,7 @@ oe_runcargo_build () {
# FIXME: if there is already an entry for this target, in an existing # FIXME: if there is already an entry for this target, in an existing
# cargo/config, this won't work. # cargo/config, this won't work.
which cargo which cargo
bbnote ${CARGO} build --target ${RUST_TARGET_SYS} "$@" bbnote ${CARGO} build --target ${TARGET_SYS} "$@"
oe_cargo_config oe_cargo_config
export RUST_PATH="${RUST_PATH}" "${CARGO}" build -v --target "${TARGET_SYS}" --release "$@"
"${CARGO}" build -v --target "${RUST_TARGET_SYS}" --release "$@"
} }
@@ -0,0 +1,26 @@
{
"data-layout": "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32",
"llvm-target": "mipsallegrexel-unknown-psp-elf",
"target-endian": "little",
"target-word-size": "32",
"arch": "mips",
"os": "psp",
"cpu": "mips32",
"features": "+eabi,-mips32,-o32",
"morestack": false,
"no-compiler-rt": true,
"executables": true,
"linker": "psp-gcc",
"position_independant_executables": true,
"function-sections": false,
"relocation-model": "static",
"linker_is_gnu": true,
"pre-link-args": [
"-fPIC",
"-L/scratch/laden/local/pspsdk/psp/sdk/lib",
"-specs=/scratch/laden/local/pspsdk/psp/sdk/lib/prxspecs",
"-Wl,-q,-T/scratch/laden/local/pspsdk/psp/sdk/lib/linkfile.prx",
"/scratch/laden/local/pspsdk/psp/sdk/lib/prxexports.o",
"module.s"
]
}
+106 -58
View File
@@ -22,91 +22,137 @@ def rust_triple(arch, vendor, os, d):
os = "linux-gnu" os = "linux-gnu"
return arch + vendor + '-' + os return arch + vendor + '-' + os
RUST_TARGET_SYS = "${@rust_triple('${TARGET_ARCH}','${TARGET_VENDOR}','${TARGET_OS}', d)}"
RUST_BUILD_SYS = "${@rust_triple('${BUILD_ARCH}','${BUILD_VENDOR}','${BUILD_OS}', d)}"
RUST_HOST_SYS = "${@rust_triple('${HOST_ARCH}','${HOST_VENDOR}','${HOST_OS}', d)}"
deref() { ## Required elements of the target spec
eval echo "\$$1" export DATA_LAYOUT_ARM = ""
} export LLVM_TARGET_ARM = ""
export TARGET_ENDIAN_ARM = ""
export TARGET_WORD_SIZE_ARM = ""
export ARCH_ARM = ""
# OS = linux
## "Optional" elements of the target spec
strip_flags () {
# from cmake.bbclass
sed 's/^\([^ ]*\).*/\1/'
}
# Generates a config file suitable for use as a compiler-and-runtime-build-time # Generates a config file suitable for use as a compiler-and-runtime-build-time
# target specification (distinct from those target specifications used by # target specification (distinct from those target specifications used by
# `rustc --target`) # `rustc --target`)
# #
# Designed to operate where $1={host,target,build}, and creates targets named # Designed to operate where $1={host,target,build}, and creates targets with
# 'host', 'target', and 'build' that correspond to these. # the <vendor> portion subsituted with 'host', 'build', or 'target'
rust_gen_mk_cfg () { rust_gen_mk_cfg () {
deref() {
eval echo "\$$1"
}
ARCH="$(deref $u_ARCH)"
local u=`echo $1 | tr '[:lower:]' '[:upper:]'` local u=`echo $1 | tr '[:lower:]' '[:upper:]'`
local sys=$(deref $u_SYS) local sys=$(deref ${u}_SYS)
local rust_sys=$(deref RUST_$u_SYS) local rust_base_sys=$(deref RUST_BASE_${u}_SYS)
local p="${S}/mk/cfg/" local p="${S}/mk/cfg/"
if [ -z "$sys" ]; then if [ -z "$sys" ]; then
bbnote "Rust: no SYS for $u" bbnote "Rust: no SYS for $u"
return return
fi fi
if [ -z "$rust_base_sys" ]; then
if [ -z "$rust_sys" ]; then bbfatal "Rust: no RUST_BUILD_SYS for $u (sys=$sys)"
bbfatal "Rust: no RUST_SYS for $u (sys=$sys)"
fi fi
if ! [ -e "$p/$rust_sys" ]; then if ! [ -e "$p$rust_base_sys" ]; then
bbfatal "Could not find RUST_$u_SYS = $rust_sys in file '$p/$rust_sys'" bberror "Could not find RUST_BASE_${u}_SYS = ${rust_base_sys}"
fi bbfatal "file '$p/$rust_base_sys'"
if [ -e "$p/$1" ]; then
bbfatal "Rust config spec already exists: '$p/$1'"
fi fi
# Use one of the existing configs as our base # Use one of the existing configs as our base
cp "$p/$rust_sys" "$p/$1" cp -f "$p$rust_base_sys" "$p$sys"
# FIXME: right now we assume our targets lack regex special characters # FIXME: right now we assume our targets lack regex special characters
# and assumes flags lack regex special chars and ';'
# Fixup the target name for all variables # 1. Fixup the target name for all variables
# Edit in our: # 2. Blank CROSS_PREFIX (XXX: should we set it to "${CCACHE}${$u_PREFIX}"
# - CROSS_PREFIX (blank it) # and adjust other vars as needed?)
# - CC # 3. Edit in our:
local cc="`echo $(deref $u_CC) | strip_flags`" local bare_cc="$(deref ${u}_PREFIX)gcc"
# - CXX (from cmake.bbclass) local cc="${CCACHE}${bare_cc} $(deref ${u}_CC_ARCH)"
local cxx="`echo $(deref $u_CXX) | strip_flags`" local cxx="${CCACHE}$(deref ${u}_PREFIX)g++ $(deref ${u}_CC_ARCH)"
# - CPP local cpp="$(deref ${u}_PREFIX)gcc $(deref ${u}_CC_ARCH) -E"
local cpp="$cc -E" local ar="$(deref ${u}_PREFIX)ar"
# - AR
local ar="$(deref $u_AR)" # 4. Append our:
# Append our: # FIXME: TOOLCHAIN_OPTIONS are only for TARGET (which is sometimes HOST)
# - CFLAGS local c_flags="$(deref ${u}_CC_ARCH)${TOOLCHAIN_OPTIONS} $(deref ${u}_CFLAGS)"
local c_flags="$(deref $u_CC_ARCH)${TOOLCHAIN_OPTIONS} $(deref $u_CFLAGS)" local cxx_flags="$(deref ${u}_CC_ARCH)${TOOLCHAIN_OPTIONS} $(deref ${u}_CXXFLAGS)"
# - CXXFLAGS local link_flags="${TOOLCHAIN_OPTIONS} $(deref ${u}_LD_ARCH)"
local cxx_flags="$(deref $u_CC_ARCH)${TOOLCHAIN_OPTIONS} $(deref $u_CXXFLAGS)"
# - LINK_FLAGS
local link_flags="${TOOLCHAIN_OPTIONS} ${HOST_LD_ARCH}"
sed -i \ sed -i \
-e "s/$rust_sys/$1/" \ -e "s/${rust_base_sys}/$sys/g" \
\ \
-e "s/^CROSS_PREFIX_$1.*\$//gc" \ -e "s/^CROSS_PREFIX_${sys}.*\$//" \
-e "s/^CC_$1=.*\$/CC_$1 := ${cc}/" \ -e "s/^CC_$sys=.\*\$/CC_$sys := ${cc}/" \
-e "s/^CXX_$1=.*\$/CXX_$1 := ${cxx}/" \ -e "s/^CXX_$sys=.\*\$/CXX_$sys := ${cxx}/" \
-e "s/^CPP_$1=.*\$/CPP_$1 := ${cpp}/" \ -e "s/^CPP_$sys=.\*\$/CPP_$sys := ${cpp}/" \
-e "s/^AR_$1=.*\$/AR_$1 := ${ar}/" \ -e "s/^AR_$sys=.\*\$/AR_$sys := ${ar}/" \
\ \
-e "/^CFG_GCCISH_CFLAGS/ s/$/ ${c_flags}/" \ -e "/^CFG_GCCISH_CFLAGS/ s;\$; ${c_flags};" \
-e "/^CFG_GCCISH_CXXFLAGS/ s/$/ ${cxx_flags}/" \ -e "/^CFG_GCCISH_CXXFLAGS/ s;\$; ${cxx_flags};" \
-e "/^CFG_GCCISH_LINK_FLAGS/ s/$/ ${link_flags}/" \ -e "/^CFG_GCCISH_LINK_FLAGS/ s;\$; ${link_flags};" \
\ \
"$p/$1" "$p/$sys"
local t="${WORKDIR}/targets/"
mkdir -p "$t"
local link_flags_vec='[ "-fPIC" ]'
cat >"$t$sys" <<-EOF
{
"data-layout": "$(deref DATA_LAYOUT__$ARCH)",
"llvm_target": "${sys}",
"target_endian": "little",
"target-word-size": "$(deref TARGET_WORD_SIZE__$ARCH)",
"arch": "$ARCH",
"os": "linux",
"linker": "${bare_cc}",
"pre_link_args": ${link_flags_vec},
# post_link_args
# cpu
"features": "$(deref FEATURES__$ARCH)",
"dynamic_linking": true,
"executables": true,
"morestack": true,
# relocation_model
# ...
# is_like_windows
"linker_is_gnu": true,
"has_rpath": true,
# no_compiler_rt
"position_independent_executables": true,
}
EOF
} }
do_rust_arch_fixup () { do_rust_arch_fixup () {
RUST_HOST_SYS="${RUST_HOST_SYS}" RUST_BASE_TARGET_SYS="${@rust_triple('${TARGET_ARCH}','${TARGET_VENDOR}','${TARGET_OS}', d)}"
RUST_BUILD_SYS="${RUST_BUILD_SYS}" RUST_BASE_BUILD_SYS="${@rust_triple('${BUILD_ARCH}','${BUILD_VENDOR}','${BUILD_OS}', d)}"
RUST_TARGET_SYS="${RUST_TARGET_SYS}" RUST_BASE_HOST_SYS="${@rust_triple('${HOST_ARCH}','${HOST_VENDOR}','${HOST_OS}', d)}"
# XXX: these are all hacks around having the variables be shell vars
# instead of bitbake vars. It probably makes sense to convert this
# entire mess into python so we don't have to do this.
HOST_SYS="${HOST_SYS}"
BUILD_SYS="${BUILD_SYS}"
TARGET_SYS="${TARGET_SYS}"
HOST_ARCH="${HOST_ARCH}"
BUILD_ARCH="${BUILD_ARCH}"
TARGET_ARCH="${TARGET_ARCH}"
rust_gen_mk_cfg host rust_gen_mk_cfg host
rust_gen_mk_cfg build rust_gen_mk_cfg build
rust_gen_mk_cfg target rust_gen_mk_cfg target
@@ -127,13 +173,14 @@ do_configure () {
unset CPPFLAGS unset CPPFLAGS
# rpath is required otherwise rustc fails to resolve symbols # rpath is required otherwise rustc fails to resolve symbols
#"--build=${BUILD_SYS}"
${S}/configure \ ${S}/configure \
"--enable-rpath" \ "--enable-rpath" \
"--disable-verify-install" \ "--disable-verify-install" \
"--prefix=${prefix}" \ "--prefix=${prefix}" \
"--target=target" \ "--target=${TARGET_SYS}" \
"--host=host" \ "--host=${HOST_SYS}" \
"--build=build" \
"--localstatedir=${localstatedir}" \ "--localstatedir=${localstatedir}" \
"--sysconfdir=${sysconfdir}" \ "--sysconfdir=${sysconfdir}" \
"--datadir=${datadir}" \ "--datadir=${datadir}" \
@@ -153,6 +200,7 @@ rust_runmake () {
unset LDFLAGS unset LDFLAGS
unset CXXFLAGS unset CXXFLAGS
unset CPPFLAGS unset CPPFLAGS
oe_runmake "$@" oe_runmake "$@"
} }
+2
View File
@@ -0,0 +1,2 @@
SRCREV = "15ba87f0314fda5e81603f37ae5f40e2022bcfc1"
require rust-git.inc