Skip to content

Commit 40362c4

Browse files
chiichenfslongjin
andauthored
修复了未正确定义Target引起的错误 (#36)
* 修复了未正确定义Target引起的错误 * 修复了环境变量的错误定义 * 修改Makefile以适配不同架构 * 解决未设置rustflags导致pagefault的问题 --------- Co-authored-by: longjin <longjin@DragonOS.org>
1 parent df4e489 commit 40362c4

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

.cargo/config.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ path = "systemctl/src/main.rs"
1515

1616
[dependencies]
1717
hashbrown = "0.11"
18-
cfg-if = { version = "1.0"}
18+
cfg-if = { version = "1.0" }
1919
lazy_static = { version = "1.4.0" }
2020
libc = "0.2"
2121

Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,38 @@
33
TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu"
44
RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
55

6+
ifdef DADK_CURRENT_BUILD_DIR
67
# 如果是在dadk中编译,那么安装到dadk的安装目录中
7-
INSTALL_DIR?=$(DADK_CURRENT_BUILD_DIR)
8+
INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
9+
else
810
# 如果是在本地编译,那么安装到当前目录下的install目录中
9-
INSTALL_DIR?=./install
11+
INSTALL_DIR = ./install
12+
endif
1013

1114

15+
ifeq ($(ARCH), x86_64)
16+
export RUST_TARGET=x86_64-unknown-linux-musl
17+
else ifeq ($(ARCH), riscv64)
18+
export RUST_TARGET=riscv64gc-unknown-linux-gnu
19+
else
20+
# 默认为x86_86,用于本地编译
21+
export RUST_TARGET=x86_64-unknown-linux-musl
22+
endif
23+
1224
build:
13-
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build
25+
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
1426

1527
run-dragonreach:
16-
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --bin DragonReach
28+
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --bin DragonReach
1729

1830
clean:
1931
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean
2032

2133
build-release:
22-
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --release
34+
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
2335

2436
clean-release:
25-
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --release
37+
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
2638

2739
fmt:
2840
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
@@ -35,4 +47,4 @@ install:
3547
mkdir -p $(INSTALL_DIR)/etc/reach/system
3648
mkdir -p $(INSTALL_DIR)/etc/reach/ipc
3749
cp ./parse_test/shell.service $(INSTALL_DIR)/etc/reach/system/shell.service
38-
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --path . --no-track --root $(INSTALL_DIR) --force
50+
RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force

0 commit comments

Comments
 (0)