-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Support non-embedded targets #463
Comments
This certainly sounds like a desirable feature and feasible if someone likes to contribute or fund it. |
Is it possible to make defmt works on standard x86 linux? It fails to link with the custom linker script. If I don't use the custom linker script |
No OS is supported at the moment; that's what this issue is about. What you are describing are the symptoms of several unimplemented things.
sounds about right. wouldn't know the exact reason off the top of my head but may be related to Linux binaries being relocatable. Firmware images use absolute addresses for everything (relocation=static in linker/compiler lingo). This ("format string 'interning'" is probably the hardest thing to fix / design / implement. More so on platforms that don't use the ELF format: macOS and Windows.
(interesting that they "survive" (are not discarded by the linker) the linking process)
without the custom linker script the log strings won't end in the right place so the .defmt linker section is not created hence the error message The other thing that's missing is a transport crate for Linux and other OSes. That crate defines how the encoded/compressed defmt data is output (e.g. framing) and to where (e.g. stdout, a file, a named pipe, a socket, etc.). You would then pass this defmt data to |
Is there any hope of making it work by setting the right compiler flags so that the log strings are "at the right place"? I don't know much about linking so maybe I am missing the point |
maybe? I'm familiar with the details of static linking but not the details of dynamic / relocatable linking so I can't answer that |
With the following parameters linking succeed but the program segfault immediately.
For what I understand, the INFO section should not interfere with the loaded program and only be present in the ELF file. If I remove only the last link argument, my program starts, if I put it back it crashes before |
I had assume that the default linker script was always passed as a parameter. Looks like is it not. After adding it to [target.x86_64-unknown-linux-musl]
rustflags = [
"-C", "target-feature=+crt-static",
"-C", "relocation-model=static",
"-C", "link-arg=-T/usr/x86_64-linux-musl/usr/lib/ldscripts/elf_x86_64.x",
"-C", "link-arg=-Tdefmt.x"
] It seems to works fine without |
@DBLouis, very cool that you made it work! 🎉 What is your usecase that makes you want to use |
Use case can be that there is a It seems one way to do it is just to add different feature flags to the lib itself: https://github.com/embassy-rs/embassy/blob/master/embassy/src/fmt.rs |
That would work, but I think the goal is to have binary logging on hosted targets, for things like embedded linux where there are storage limitations with normal logging. |
Came across this while working on a defmt-serial target: https://github.com/gauteh/defmt-serial. Wrote an example for the host environment, works with: #463 (comment):
|
That is great to see @gauteh! Is there anything we can do to support non-embedded targets better? |
@Urhengulas , I guess the biggest problem is the rustflags that are currently needed. Couldn't get it to work on -gnu target. The rest is solvable:
|
If anyone is working on this, you might find the linker scripts and tooling in the google/pigweed/pw_tokeniser directory useful. It's all written in c++ but works for host/embedded-arm but uses similar mechanisms to what defmt uses. i.e. pw_tokeniser and defmt offer very similar functionality. |
Hello, Right now #463 (comment) seems to be working for linux
|
Currently defmt only works in ELF targets, and requires a custom linker script. Is supporting non-embedded targets in the radar?
I think the most portable way would be to not rely en ELF/linker tricks and have the proc macros hit flat files (or a sqlite DB?) to assign indexes to format strings.
This would be a big change, so if you don't want to do this because the only goal is supporting embedded devices, I understand :) I thought I'd open this issue to confirm.
The text was updated successfully, but these errors were encountered: