Skip to content

Commit

Permalink
rust: First working version for powerpc-*-gnuspe for qoriq arch
Browse files Browse the repository at this point in the history
NOTE: requires clean-up and review of every extra variable set
  • Loading branch information
th0ma7 committed Jan 24, 2024
1 parent 274c67b commit 086889c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
8 changes: 6 additions & 2 deletions mk/spksrc.cross-rust-env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ CMAKE_PATH = $(abspath $(WORK_DIR)/../../../native/cmake/work-native/install/usr
export CARGO_HOME=$(BASE_DISTRIB_DIR)/cargo
export RUSTUP_HOME=$(BASE_DISTRIB_DIR)/rustup
export PATH:=$(abspath $(BASE_DISTRIB_DIR)/cargo/bin):$(CMAKE_PATH):$(PATH)
export CFLAGS_$(subst -,_,$(RUST_TARGET))="$(TC_EXTRA_CFLAGS)"
export CXXFLAGS_$(subst -,_,$(RUST_TARGET))="$(TC_EXTRA_CFLAGS)"
export LDFLAGS_$(subst -,_,$(RUST_TARGET))="--sysroot=$(WORK_DIR)/$(TC_TARGET)/$(TC_SYSROOT)"
endif

ifeq ($(RUSTUP_DEFAULT_TOOLCHAIN),)
RUSTUP_DEFAULT_TOOLCHAIN = stable
endif

# When building toolchain Tier-3 arch support
# While stage-2 is the truly current compiler, stage-1 suffice our needs
# https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html#stage-2-the-truly-current-compiler
RUSTUP_DEFAULT_TOOLCHAIN_STAGE = 2
RUSTUP_DEFAULT_TOOLCHAIN_STAGE = 1

ifeq ($(TC_RUSTUP_TOOLCHAIN),)
TC_RUSTUP_TOOLCHAIN = $(RUSTUP_DEFAULT_TOOLCHAIN)
Expand Down Expand Up @@ -45,7 +49,7 @@ RUST_TARGET = aarch64-unknown-linux-gnu
endif
ifeq ($(findstring $(ARCH), $(PPC_ARCHS)),$(ARCH))
RUST_TARGET = powerpc-unknown-linux-gnuspe
TC_RUSTUP_TOOLCHAIN = $(RUST_TARGET)
TC_RUSTUP_TOOLCHAIN = stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE)-$(RUST_TARGET)
endif
ifeq ($(RUST_TARGET),)
$(error Arch $(ARCH) not supported)
Expand Down
7 changes: 4 additions & 3 deletions mk/spksrc.cross-rust.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ endif
# overriding definition using +stable or +$(RUSTUP_TOOLCHAIN)
# https://rust-lang.github.io/rustup/environment-variables.html
rust_install_target:
@echo " ==> Cargo install rust package $(PKG_NAME) (rustc +$(RUSTUP_TOOLCHAIN) -vV)"
@$(RUN) rustc +$(RUSTUP_TOOLCHAIN) -vV
@$(RUN) cargo install $(CARGO_INSTALL_ARGS)
@echo " ==> Cargo install rust package $(PKG_NAME) (rustc +$(TC_RUSTUP_TOOLCHAIN) -vV)"
@$(RUN) rustc +$(TC_RUSTUP_TOOLCHAIN) -vV
@$(RUN) echo cargo +$(TC_RUSTUP_TOOLCHAIN) install $(CARGO_INSTALL_ARGS) --target $(RUST_TARGET)
@$(RUN) cargo +$(TC_RUSTUP_TOOLCHAIN) install $(CARGO_INSTALL_ARGS) --target $(RUST_TARGET)

#####

Expand Down
31 changes: 23 additions & 8 deletions mk/spksrc.tc-rust.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,26 @@ rust_toml:
@echo 'profile = "compiler"' ; \
echo
@echo "[build]" ; \
echo 'target = ["$(RUST_TARGET)"]' ; \
echo 'target = ["x86_64-unknown-linux-gnu", "$(RUST_TARGET)"]' ; \
echo "build-stage = $(RUSTUP_DEFAULT_TOOLCHAIN_STAGE)" ; \
echo "doc-stage = 2" ; \
echo "docs = false" ; \
echo "docs-minification = false" ; \
echo "compiler-docs = false" ; \
echo
@echo "[rust]" ; \
echo 'channel = "stable"' ; \
echo 'lto = "off"' ; \
echo
@echo "[llvm]" ; \
echo 'download-ci-llvm = "if-unchanged"' ; \
echo
@echo "[install]" ; \
echo
@echo "[dist]" ; \
echo
@echo "[target.x86_64-unknown-linux-gnu]" ; \
echo
@echo "[target.$(RUST_TARGET)]" ; \
echo 'cc = "$(WORK_DIR)/$(TC_TARGET)/bin/$(TC_PREFIX)gcc"' ; \
echo 'cxx = "$(WORK_DIR)/$(TC_TARGET)/bin/$(TC_PREFIX)g++"' ; \
Expand Down Expand Up @@ -96,13 +110,14 @@ else
@$(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 && ./x setup compiler)
@(cd $(WORK_DIR)/rust && \
CFLAGS_$(subst -,_,$(RUST_TARGET))="$(TC_EXTRA_CFLAGS)" \
CXXFLAGS_$(subst -,_,$(RUST_TARGET))="$(TC_EXTRA_CFLAGS)" \
LDFLAGS_$(subst -,_,$(RUST_TARGET))="--sysroot=$(WORK_DIR)/$(TC_TARGET)/$(TC_SYSROOT)" \
RUST_BACKTRACE=full \
./x build --config $(TC_LOCAL_VARS_RUST))
@rustup toolchain link $(TC_RUSTUP_TOOLCHAIN) $(WORK_DIR)/rust/build/host/stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE)
(cd $(WORK_DIR)/rust && \
CFLAGS_$(subst -,_,$(RUST_TARGET))="$(TC_EXTRA_CFLAGS)" \
CPPFLAGS_$(subst -,_,$(RUST_TARGET))="$(TC_EXTRA_CFLAGS)" \
CXXFLAGS_$(subst -,_,$(RUST_TARGET))="$(TC_EXTRA_CFLAGS)" \
CARGO_TARGET_$(shell echo $(RUST_TARGET) | tr - _ | tr a-z A-Z)_RUSTFLAGS="-Ctarget-cpu=e500" \
RUST_BACKTRACE=full \
./x build --config $(TC_LOCAL_VARS_RUST))
rustup toolchain link $(TC_RUSTUP_TOOLCHAIN) $(WORK_DIR)/rust/build/host/stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE)
@for i in 0 1 2 ; do \
[ $${i} -lt $(RUSTUP_DEFAULT_TOOLCHAIN_STAGE) ] && (cd $(WORK_DIR)/rust && ./x clean --stage $${i}) || true ; \
done
Expand Down
3 changes: 1 addition & 2 deletions mk/spksrc.tc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ tc_vars: flag
echo TC_ENV += CARGO_BUILD_TARGET=\"$(RUST_TARGET)\" ; \
echo TC_ENV += CARGO_TARGET_$(shell echo $(RUST_TARGET) | tr - _ | tr a-z A-Z)_AR=\"$(WORK_DIR)/$(TC_TARGET)/bin/$(TC_PREFIX)ar\" ; \
echo TC_ENV += CARGO_TARGET_$(shell echo $(RUST_TARGET) | tr - _ | tr a-z A-Z)_LINKER=\"$(WORK_DIR)/$(TC_TARGET)/bin/$(TC_PREFIX)gcc\" ; \
echo TC_ENV += CARGO_TARGET_$(shell echo $(RUST_TARGET) | tr - _ | tr a-z A-Z)_RUSTFLAGS=\"-C link-arg=--sysroot=$(abspath $(WORK_DIR)/$(TC_TARGET)/$(TC_SYSROOT)) $(TC_RUSTFLAGS) $$\(ADDITIONAL_RUSTFLAGS\)\" ; \
echo TC_ENV += RUSTUP_TOOLCHAIN=\"$(TC_RUSTUP_TOOLCHAIN)\" ; \
echo TC_ENV += CARGO_TARGET_$(shell echo $(RUST_TARGET) | tr - _ | tr a-z A-Z)_RUSTFLAGS=\"$(TC_RUSTFLAGS) $$\(ADDITIONAL_RUSTFLAGS\)\" ; \
echo TC_CONFIGURE_ARGS := --host=$(TC_TARGET) --build=i686-pc-linux ; \
echo TC_TYPE := $(TC_TYPE) ; \
echo TC_SYSROOT := $(WORK_DIR)/$(TC_TARGET)/$(TC_SYSROOT) ; \
Expand Down

0 comments on commit 086889c

Please sign in to comment.