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

Error: Cannot locate the path to the asm file #82

Closed
sporksmith opened this issue Nov 3, 2022 · 12 comments · Fixed by #83
Closed

Error: Cannot locate the path to the asm file #82

sporksmith opened this issue Nov 3, 2022 · 12 comments · Fixed by #83

Comments

@sporksmith
Copy link

sporksmith commented Nov 3, 2022

In shadow (an admittedly complex hybrid C/Rust project that uses build scripts, bindgen, and cbindgen...) I'm getting the following error:

# Use shadow's helper to initialize a cmake build dir
$ ./setup build debug
...
# Try using cargo asm:
$ (cd src && cargo asm -p shadow-rs --lib "shadow_rs::main::host::Host::default_ip")
...
Error: Cannot locate the path to the asm file

I tried on both Rust 1.63.0 and 1.65.0

@pacak
Copy link
Owner

pacak commented Nov 3, 2022

Can you run it with -vvv to see if it is looking anywhere near where it should be looking?

@sporksmith
Copy link
Author

Sure:

$ cargo asm --manifest-path=src/Cargo.toml -p shadow-rs --lib --target-dir build/src/target -vvv "shadow_rs::main::host::Host::default_ip"
Artifact files: ["  /home/jnewsome/projects/shadow/dev/build/src/target/release/deps/libbytes-b6d5f55491c0e232.rlib " , Finished"/home/jnewsome/projects/shadow/dev/build/src/target/release/deps/libbytes-b6d5f55491c0e232.rmeta "release [optimized] target(s) in 0.07s]

Error: Cannot locate the path to the asm file

Both of the referenced files exist, though I wonder if the leading and trailing whitespace inside the quoted strings is an issue.

$ ls /home/jnewsome/projects/shadow/dev/build/src/target/release/deps/libbytes-b6d5f55491c0e232.rlib
/home/jnewsome/projects/shadow/dev/build/src/target/release/deps/libbytes-b6d5f55491c0e232.rlib
$ ls /home/jnewsome/projects/shadow/dev/build/src/target/release/deps/libbytes-b6d5f55491c0e232.rmeta
/home/jnewsome/projects/shadow/dev/build/src/target/release/deps/libbytes-b6d5f55491c0e232.rmeta

@sporksmith
Copy link
Author

Or maybe I'm just seeing two log lines get interwoven. "Artifact files..." and "Finished..."

@pacak
Copy link
Owner

pacak commented Nov 3, 2022

Managed to reproduce it locally, will take a look.

@sporksmith
Copy link
Author

#82 - looks like there's something strange going on with rlib, I'm trying to go though artifacts as they are parsed and I don't see anything related to shadow-rs even though .s files are created. I wonder if you have any ideas, if not - I'll hack something to dig through the files directly in case of rlib...

Was this comment meant to be on this issue?

One thing that's a little odd about this crate is that it supports both rlib and staticlib output: https://github.com/shadow/shadow/blob/6fc290de3f88f79f5072661df0d728d65c9307d9/src/main/Cargo.toml#L10

I think normally both are created when compiling with --lib, but maybe this is confusing things somehow?

@pacak
Copy link
Owner

pacak commented Nov 3, 2022

Was this comment meant to be on this issue?

Yes. Code that is having a problem was introduced in that MR and I was trying to reach the author.

I think normally both are created when compiling with --lib, but maybe this is confusing things somehow?

Probably. Either way it's a good test case and I'll make sure it works. Planning to look closer into the problem tomorrow.

@sporksmith
Copy link
Author

Probably. Either way it's a good test case and I'll make sure it works.

I tried removing staticlib from the crate-type list, but got the same result

Planning to look closer into the problem tomorrow.

Thanks! This isn't in any way urgent for me, but it'd be nice if we could use this tool :)

@pacak
Copy link
Owner

pacak commented Nov 4, 2022

Can you check if rlib branch solves the problem for you?

@sporksmith
Copy link
Author

Yup, that branch seems to work! I also had the symbol name slightly wrong; after fixing it:

$ ~/src/cargo-show-asm/target/debug/cargo-asm --manifest-path=src/Cargo.toml -p shadow-rs --lib --target-dir build/src/target "shadow_rs::host::host::Host::default_ip"
    Finished release [optimized] target(s) in 0.07s
.section .text.shadow_rs::host::host::Host::default_ip,"ax",@progbits
	.globl	shadow_rs::host::host::Host::default_ip
	.p2align	4, 0x90
	.type	shadow_rs::host::host::Host::default_ip,@function
shadow_rs::host::host::Host::default_ip:

	.cfi_startproc
	mov rdi, qword ptr [rdi]

	jmp qword ptr [rip + hostc_getDefaultIP@GOTPCREL]

.Lfunc_end2554:
	.size	shadow_rs::host::host::Host::default_ip, .Lfunc_end2554-shadow_rs::host::host::Host::default_ip

Thanks!

@pacak
Copy link
Owner

pacak commented Nov 4, 2022

Okay, I'll fix the tests and release a new version. Thank you for reporting a problem.

@pacak pacak mentioned this issue Nov 5, 2022
@pacak pacak closed this as completed in #83 Nov 5, 2022
@pacak
Copy link
Owner

pacak commented Nov 5, 2022

Released 0.2.3

@sporksmith
Copy link
Author

Confirmed works for me at the latest release. Thank you for the quick turnaround!

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

Successfully merging a pull request may close this issue.

2 participants