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

[workspace issue] Error: invalid register after refactor under workspace #10314

Closed
PeterWrighten opened this issue Jan 21, 2022 · 4 comments
Closed
Labels
C-bug Category: bug

Comments

@PeterWrighten
Copy link

PeterWrighten commented Jan 21, 2022

Problem

The same issue as rust #93151.

When I want to refactor an OS project with Cargo workshop, which its original rust code is not encapsulated under cargo workspace but could promise successful run , compiler reported 'invalid register' issue as follow:

(My code is here, refactored by Cargo workspace)

% cargo build
   Compiling user_lib v0.1.0 (/Users/apple/GitHub/OperatingSystem/peter_batch_os/user)
error: invalid register `x10`: unknown register
 --> user/src/syscall.rs:9:13
  |
9 |             inlateout("x10") args[0] => ret,
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: invalid register `x11`: unknown register
  --> user/src/syscall.rs:10:13
   |
10 |             in("x11") args[1],
   |             ^^^^^^^^^^^^^^^^^

error: invalid register `x12`: unknown register
  --> user/src/syscall.rs:11:13
   |
11 |             in("x12") args[2],
   |             ^^^^^^^^^^^^^^^^^

error: invalid register `x17`: unknown register
  --> user/src/syscall.rs:12:13
   |
12 |             in("x17") id
   |             ^^^^^^^^^^^^

error: could not compile `user_lib` due to 4 previous errors

My source code here has added unsafe statement and asm mod, target triple is also modified to "riscv64gc-unknown-none-elf", but it seems that stil could't work under cargo workspace :(

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.60.0-nightly (2022-01-18)

@PeterWrighten PeterWrighten added the C-bug Category: bug label Jan 21, 2022
@PeterWrighten
Copy link
Author

PeterWrighten commented Jan 21, 2022

Now it works well by changing rustflags, but still cound not guarantee its performance when .cargo config file is not under root directory. I want to know how could I do to work it out just depended by .cargo file under members' crate.

@bjorn3
Copy link
Member

bjorn3 commented Jan 21, 2022

.cargo/config.toml is read for the current directory and all of it's parent directories. It isn't necessarily read for the specific workspace member you are trying to build if you are not in it's directory.

@PeterWrighten
Copy link
Author

.cargo/config.toml is read for the current directory and all of it's parent directories. It isn't necessarily read for the specific workspace member you are trying to build if you are not in it's directory.

But actually, in my case, if .cargo/config.toml is just in members' crate (In my code, it is ./user/.cargo/config.toml) but not in peter_batch_os directory, it couldn't be built at all...

@PeterWrighten PeterWrighten reopened this Jan 22, 2022
@ehuss
Copy link
Contributor

ehuss commented Feb 27, 2022

I'm going to close as this sounds like an issue with config file search order. Those issues are tracked in #9769. There are a few other workarounds, some of them unstable (such as per-package-target and profile rustflags).

@ehuss ehuss closed this as completed Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants