Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: Enable usage of native/rust-qoriq
Browse files Browse the repository at this point in the history
th0ma7 committed Jan 27, 2024
1 parent b2ccc55 commit 39fa120
Showing 2 changed files with 27 additions and 11 deletions.
28 changes: 18 additions & 10 deletions mk/spksrc.cross-rust-env.mk
Original file line number Diff line number Diff line change
@@ -19,20 +19,15 @@ endif
# https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html#stage-2-the-truly-current-compiler
RUSTUP_DEFAULT_TOOLCHAIN_STAGE = 2

ifeq ($(TC_RUSTUP_TOOLCHAIN),)
TC_RUSTUP_TOOLCHAIN = $(RUSTUP_DEFAULT_TOOLCHAIN)
# When calling directly from
# toolchain/syno-<arch>-<vertion>
# ARCH variable is still unset
ifeq ($(ARCH),)
ARCH=$(TC_ARCH)
endif

RUST_TARGET =
# map archs to rust targets
ifeq ($(findstring $(ARCH), $(x64_ARCHS)),$(ARCH))
RUST_TARGET = x86_64-unknown-linux-gnu
endif
ifeq ($(findstring $(ARCH), $(i686_ARCHS)),$(ARCH))
RUST_TARGET = i686-unknown-linux-gnu
endif
ifeq ($(findstring $(ARCH), $(ARMv5_ARCHS)),$(ARCH))
# may be not supported for cargo
RUST_TARGET = armv5te-unknown-linux-gnueabi
endif
ifeq ($(findstring $(ARCH), $(ARMv7_ARCHS)),$(ARCH))
@@ -45,9 +40,22 @@ ifeq ($(findstring $(ARCH), $(ARMv8_ARCHS)),$(ARCH))
RUST_TARGET = aarch64-unknown-linux-gnu
endif
ifeq ($(findstring $(ARCH), $(PPC_ARCHS)),$(ARCH))
RUST_FORCE_TOOLCHAIN = 0
RUST_TARGET = powerpc-unknown-linux-gnuspe
TC_RUSTUP_TOOLCHAIN = stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE)-$(RUST_TARGET)
endif
ifeq ($(findstring $(ARCH), $(x64_ARCHS)),$(ARCH))
RUST_TARGET = x86_64-unknown-linux-gnu
endif
ifeq ($(findstring $(ARCH), $(i686_ARCHS)),$(ARCH))
RUST_TARGET = i686-unknown-linux-gnu
endif

ifeq ($(RUST_TARGET),)
$(error Arch $(ARCH) not supported)
endif

# By default use the default toolchain if unset
ifeq ($(TC_RUSTUP_TOOLCHAIN),)
TC_RUSTUP_TOOLCHAIN = $(RUSTUP_DEFAULT_TOOLCHAIN)
endif
10 changes: 9 additions & 1 deletion mk/spksrc.tc-rust.mk
Original file line number Diff line number Diff line change
@@ -103,10 +103,17 @@ ifeq ($(TC_RUSTUP_TOOLCHAIN),$(RUSTUP_DEFAULT_TOOLCHAIN))
@$(MSG) "rustup target add $(RUST_TARGET)"
rustup override set stable
rustup target add $(RUST_TARGET)
rustup show
else
@$(MSG) "Target $(RUST_TARGET) unavailable..."
ifeq ($(RUST_BUILD_TOOLCHAIN),0)
@$(MSG) "Install rust target $(RUST_TARGET) from native"
@$(MAKE) -C ../../native/rust-qoriq
else
@$(MSG) "Build rust target $(RUST_TARGET) from sources"
@$(MSG) "Enforce usage of CMake 3.20.0 or higher"
@$(MAKE) -C ../../native/cmake
exit 2
@$(MSG) "Building Tier-3 rust target: $(RUST_TARGET)"
@(cd $(WORK_DIR) && [ ! -d rust ] && git clone --depth 1 https://github.com/rust-lang/rust.git || true)
@(cd $(WORK_DIR)/rust && rm -f config.toml && ./x setup compiler)
@@ -120,8 +127,9 @@ else
[ $${i} -lt $(RUSTUP_DEFAULT_TOOLCHAIN_STAGE) ] && (cd $(WORK_DIR)/rust && ./x clean --stage $${i}) || true ; \
done
@$(MSG) "Building Tier 3 rust target: $(RUST_TARGET) - stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE) complete"
endif
rustup show
endif
endif

post_rustc_target: $(RUSTC_TARGET)

0 comments on commit 39fa120

Please sign in to comment.