Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chp 2 & rust] 是否可以将其在cargo工作空间重构? #52

Closed
PeterWrighten opened this issue Jan 26, 2022 · 6 comments
Closed

Comments

@PeterWrighten
Copy link

PeterWrighten commented Jan 26, 2022

在做chp2的实验时,我尝试将user和os都置于cargo工作空间下,试图重构(非linux,macOS环境下)。但是遇到了如下问题:

.cargo/config.toml文件如果分别置于members目录(此处为/osuser)的话,无法编译通过。但如果将.cargo/config.toml置于根目录的话user可以编译通过。

我的代码在这里,刚入门rust和学习操作系统,望指教。

@PeterWrighten
Copy link
Author

PeterWrighten commented Jan 26, 2022

【追加】:
关于宏使用的问题目前已解决。

但batch.rs中的用户栈与内核栈依旧有如下问题:

static KERNEL_STACK: KernelStack = KernelStack {    
    data: [0; KERNEL_STACK_SIZE] 
};

以上代码rust-analyzer会报错,说无法发现值,不知是rust-analyzer的问题还是代码的问题。

@wyfcyx
Copy link
Collaborator

wyfcyx commented Jan 26, 2022

rust-analyzer的问题是因为data行末需要加一个,;至于config.toml我觉得不算什么大问题,只要能跑起来就行。或者可以考虑不用config.toml,直接在os/Makefile里面的cargo命令里面加上对应的设置,不过这样会比较麻烦。

@PeterWrighten
Copy link
Author

rust-analyzer的问题是因为data行末需要加一个,;至于config.toml我觉得不算什么大问题,只要能跑起来就行。或者可以考虑不用config.toml,直接在os/Makefile里面的cargo命令里面加上对应的设置,不过这样会比较麻烦。

感谢回复。加了,还是会报错orz
Makefile的话,是不是不可以用cargo工作空间那样运行了呢

@PeterWrighten
Copy link
Author

rust-analyzer的问题是因为data行末需要加一个,;至于config.toml我觉得不算什么大问题,只要能跑起来就行。或者可以考虑不用config.toml,直接在os/Makefile里面的cargo命令里面加上对应的设置,不过这样会比较麻烦。

目前上述问题均已解决,但是无论是在Linux还是macOS下都出现了无法将应用bin链接到内核的问题。报错如下:

error: Could not find incbin file '/../target/riscv64gc-unknown-none-elf/release/03priv_inst.bin'
   |
note: instantiated into assembly here
  --> <inline asm>:39:13

这只是其中之一,实际上五个应用链接时都会报错反馈错误。

@wyfcyx
Copy link
Collaborator

wyfcyx commented Jan 28, 2022

我对cargo工作空间不太了解,你如果想基于它的话可能需要多尝试一下。比如在build.rs里面打印一下当前工作路径,看看链接的时候到底是在哪个路径下。

@PeterWrighten
Copy link
Author

我对cargo工作空间不太了解,你如果想基于它的话可能需要多尝试一下。比如在build.rs里面打印一下当前工作路径,看看链接的时候到底是在哪个路径下。

好的,我再尝试一下。主要是想熟悉一下Cargo的特性,也因为电脑性能有限不太想跑虚拟机orz
感谢耐心回复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants