-
Notifications
You must be signed in to change notification settings - Fork 214
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
Remove implicit 'mem' feature for '-none' targets. #379
Remove implicit 'mem' feature for '-none' targets. #379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, the -Zbuild-std-features=compiler-builtins-mem
seems to work for https://github.com/cloud-hypervisor/rust-hypervisor-firmware on the latest nightly.
I'm a little worried that this can break folks, isn't it conventional that "-none" targets don't have any external code? If external code is present could the target be named something else? |
By external code, do you mean something like libc? In my situation, I'm not linking against libc, or any other external code; I would argue my target is still a "-none" one. For the Xtensa LX6 chip I am developing for, some segments of memory can only be accessed in a word aligned manner. It's normal memory, but internally the bus used to access it has these restrictions. The compiler is free to insert these mem functions wherever it see's fit, hence the mem functions for this target have to work anywhere. In terms of breakage, the decision to implicitly enable the"mem" feature is quite recent, in fact the PR describes itself as a bit of cludge to cover as many bases as possible. I understand not wanting to break peoples builds, but in my experience, opting in to cargo features is easy, opting out is hard. Perhaps an alternative is to add my custom mem functions in this crate, behind a cfg target gate? Although, my target is still in the process of llvm upstreaming, and a long way away being an experimental target in Rust, so I am not sure this is the best idea. |
I think as @MabezDev mentioned using string comparison against the target name to determine "is an external implementation of Due to how the target features work, if |
This will be transparent to users of say |
So this should only matter for
I'm assuming so, given that the change that enabled this only did so recently. So it looks like the prebuilt |
I'm a little concerned that I think this will essentially break everyone using Regardless, I guess this should be OK, but it will likely cause some disruption. |
I think it should be fine to declare these symbols as weak by default. I don't think that would break anyone and I think it would fix the issue of users wanting to bring their own? (or libc is linked in for one reason or another) |
Apologies, this dropped of my radar!
I think this would work for me, and in fact is probably a better solution overall. I am happy to open a new PR with the changes and close this one? One thing I struggled with before, is how to test these compiler-builtins changes? I tried using patch in the |
I understand these changes are not to be made lightly, and will require some thought. Perhaps in the meantime would you be open to accepting a PR that adds the custom mem routines for the xtensa arch behind a cfg? Much like the current |
I recently run into this problem with the esp32 |
As per #379 (comment), we should change the |
Now that rust-lang/rust#77284 is merged, anyone who needs the
mem
feature can opt-in with-Zbuild-std-features=compiler-builtins-mem
. This change stops targets with '-none' in there triple from implicitly having themem
feature enabled.Fixes #369