Skip to content

Commit

Permalink
rust: "ARCH" detection for toolchain independantly from location
Browse files Browse the repository at this point in the history
When called from cross or spk usage of $(ARCH)
When called from toolchain:
   - Usage of $(TC_ARCH) when $(TC_NAME) does not exist
   - Usage of $(TC_NAME) for generic archs
  • Loading branch information
th0ma7 committed Jan 27, 2024
1 parent acb36a3 commit cffe774
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 13 additions & 11 deletions mk/spksrc.cross-rust-env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,43 @@ ifeq ($(RUSTUP_DEFAULT_TOOLCHAIN),)
RUSTUP_DEFAULT_TOOLCHAIN = stable
endif

# When calling directly from toolchain/syno-<arch>-<version>
# ARCH variable is still unset thus using $(TC_ARCH) although
# in generic archs we must rely on $(TC_NANE)
RUST_ARCH = $(or $(ARCH),$(lastword $(subst -, ,$(TC_NAME))),$(TC_ARCH))

# 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

# When calling directly from toolchain/syno-<arch>-<version>
# ARCH variable is still unset thus using $(or $(ARCH),$(TC_ARCH))

# map archs to rust targets
ifeq ($(findstring $(or $(ARCH),$(TC_ARCH)), $(ARMv5_ARCHS)),$(or $(ARCH),$(TC_ARCH)))
ifeq ($(findstring $(RUST_ARCH), $(ARMv5_ARCHS)),$(RUST_ARCH))
RUST_TARGET = armv5te-unknown-linux-gnueabi
endif
ifeq ($(findstring $(or $(ARCH),$(TC_ARCH)), $(ARMv7_ARCHS)),$(or $(ARCH),$(TC_ARCH)))
ifeq ($(findstring $(RUST_ARCH), $(ARMv7_ARCHS)),$(RUST_ARCH))
RUST_TARGET = armv7-unknown-linux-gnueabihf
endif
ifeq ($(findstring $(or $(ARCH),$(TC_ARCH)), $(ARMv7L_ARCHS)),$(or $(ARCH),$(TC_ARCH)))
ifeq ($(findstring $(RUST_ARCH), $(ARMv7L_ARCHS)),$(RUST_ARCH))
RUST_TARGET = armv7-unknown-linux-gnueabi
endif
ifeq ($(findstring $(or $(ARCH),$(TC_ARCH)), $(ARMv8_ARCHS)),$(or $(ARCH),$(TC_ARCH)))
ifeq ($(findstring $(RUST_ARCH), $(ARMv8_ARCHS)),$(RUST_ARCH))
RUST_TARGET = aarch64-unknown-linux-gnu
endif
ifeq ($(findstring $(or $(ARCH),$(TC_ARCH)), $(PPC_ARCHS)),$(or $(ARCH),$(TC_ARCH)))
ifeq ($(findstring $(RUST_ARCH), $(PPC_ARCHS)),$(RUST_ARCH))
RUST_BUILD_TOOLCHAIN = 0
RUST_TARGET = powerpc-unknown-linux-gnuspe
TC_RUSTUP_TOOLCHAIN = stage$(RUSTUP_DEFAULT_TOOLCHAIN_STAGE)-$(RUST_TARGET)
endif
ifeq ($(findstring $(or $(ARCH),$(TC_ARCH)), $(x64_ARCHS)),$(or $(ARCH),$(TC_ARCH)))
ifeq ($(findstring $(RUST_ARCH), $(x64_ARCHS)),$(RUST_ARCH))
RUST_TARGET = x86_64-unknown-linux-gnu
endif
ifeq ($(findstring $(or $(ARCH),$(TC_ARCH)), $(i686_ARCHS)),$(or $(ARCH),$(TC_ARCH)))
ifeq ($(findstring $(RUST_ARCH), $(i686_ARCHS)),$(RUST_ARCH))
RUST_TARGET = i686-unknown-linux-gnu
endif

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

# By default use the default toolchain if unset
Expand Down
4 changes: 4 additions & 0 deletions mk/spksrc.tc-rust.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

# Define rustc configuration toml file location
# when rebuilding for unsupported archs (i.e. Tier 3)
ifeq ($(strip $(TC_NAME)),)
TC_LOCAL_VARS_RUST = $(WORK_DIR)/$(TC_ARCH).toml
else
TC_LOCAL_VARS_RUST = $(WORK_DIR)/$(lastword $(subst -, ,$(TC_NAME))).toml
endif

# Configure file descriptor lock timeout
ifeq ($(strip $(FLOCK_TIMEOUT)),)
Expand Down

0 comments on commit cffe774

Please sign in to comment.