-
Notifications
You must be signed in to change notification settings - Fork 264
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
Explore how private dependencies with links =
affect esp-hal
#2589
Comments
Not sure I understand the concern correctly. At least for the Another thing is having multiple versions of a PAC (or different PACs) in the dependency tree: For different versions:
For different PACs (well - who would do that?)
I also tried to check which of our external dependencies (of esp-hal) includes Our own crates:
|
I'm also not sure I understand the concern here. The HAL depends on these packages, not user code. We are in control of these dependencies, as long as we follow semver with our releases I don't think there should be any issues? |
Okay, so in the interest of trying to get this resolved...
I don't believe points 1-3 should be too controversial, however please let me know if anybody disagrees. Points 4 and 5 will require some further discussion I guess, so please let me know your opinions on this. Once the above points are resolved, we can carry out the required changes and consider this complete. |
Why is this? |
it's because of the |
Ah I see, could that be moved to the hal? I can easily picture an application having multiple versions of the PAC in their project from 3rd party drivers. Given the PAC isn't getting stabilised anytime soon it'd be really inconvenient for |
I can only imagine to copy+paste all the |
Thanks for taking the time to look at this!
I think I might have the opposite opinion, consider:
Agree
I think I agree, but I'm also wondering what's the benefit, only one esp-hal version in the dep tree will call
I think we can ignore this one for now, but good to know it has a links field because I forgot 😆.
I think we should really try and avoid a Here is my controversial take, we should remove all the interrupt stuff out of the PACs and into the HAL, which may require making some changes (or using a fork) of svd2rust. Without that stuff, we are free to upgrade the PACs over time without worry. To me it's always felt a bit odd for the register access library to hold the static of the all the interrupt handlers, moving to the HAL also gives use the option to store the handlers in FLASH (for riscv) with a config option too, though that is a minor benefit. With above said, I think we can punt this down the line. I don't think we need a Thoughts? |
But why would someone depend on the rt crate in their binary? 🤔 And I guess (need to test that) when there are two versions of an rt-crate, people will run into linker issues (duplicate global symbols) which look a lot scarier than what they get with the links-key (while the error they see in that case is still not great in this situation)
The __EXTERNAL_INTERRUPTS will be there multiple times and cause linker issues (b.c. they are |
Somehow I completely missed the |
There can't be two versions of esp-hal in a project because we have a no-mangle |
Having multiple versions of the HAL in their project will result in duplicated symbols, will it not? e.g. as Daniel pointed out there will now be two different versions of
Why does it matter if the runtime crates change between HAL releases? If they are dependencies of the HAL, and users are not intended to include them in their own projects directly, then they will always be using exactly the version specified by the HAL. If we do not add
What is the concern with upgrading the PACs as their currently stand? Again, they are a direct dependency of the HAL and in most use cases the user should not need to include them as direct dependencies. In the case they do, why would they not want to use the latest published version of the PAC? Why is making this a requirement an issue? I'm not really understanding this line of reasoning, maybe I'm missing something. I'm also not sure what we gain by creating this extra work for ourselves, this interrupt-related code is all automatically generated for us, where as if we move it to the HAL any changes in the SVDs will require us to either copy-paste the changes in, or make the changes manually in the HAL, which will be an error-prone process and easy to forget to do. |
Third party library authors can choose to depend on a specific PAC version. As you yourself are aware, a breaking PAC change can be rather annoying to apply. If we can allow a driver author to decouple their implementation from the PAC used by esp-hal (by taking the peripheral singleton, then essentially throwing it away and using the PAC internally), I think we can reduce a lot of friction for them. Since the hardware doesn't change, I doubt there is much value in forcing (working) driver implementations to be updated just to keep it compiling. |
I did some experimenting with this, you can find my full results, which have a break down of the test and the output in each test folder (inside README.md). I'll summarize what I found here, but I do encourage you to play around with it a bit yourself. https://github.com/MabezDev/semver-playground PACsI don't believe PACs should have a Actionable items:
HALI don't think we need Expanding on above, I decided to see if we can utilize semver trick to make 1.x and 2.x interoperable, to avoid ecosystem upgrade churn if we ever need to release 2.0.0. The Actionable items:
rt cratesI think these should have a
I don't think these are use cases we want to support. In general whilst multiple versions of the hal can coexist, only one hal version can be the entry point for the program. Actionable items:
Those are my current thoughts, I've listen some action items but I won't convert those to issues until this has had a bit of time to sit and we're sure this is the correct path forward. Just a reminder that the above comments are a brief summary of the actual results, so please read those before replying here, just in case I've already answered your question. |
It would be possible to reference esp-hal twice, but what would be the point? The peripheral singletons are different types between the HAL versions, so if users initialize esp-hal 2.0, they won't be able to use esp-hal 1.0 drivers with 2.0 peripherals. I guess the option remains to unsafely grab old peripherals to use the old drivers, but that's pretty difficult to do when someone uses DMA or interrupts. I can understand libraries working with multiple major HAL versions, but those libraries can have exclusive hal-version features, too. |
but they can, with semver trick, provided we don't need to fundamentally change anything to do with the peripheral struct itself or the driver constructors in v2.0.0. We can release another minor version of 1.x which uses 2.x peripherals (it depends on a future version of itself) meaning both 1.x and 2.x peripherals/drivers are interoperable. Take a look at the multiple-hal-semver trick test and in particular the 1.3.0 release of
Yeah if semver trick isn't appropriate for the reasons I mentioned above, then yes this is the route to go down. |
Okay, I've read through your material this time :) I think the As these arrays need to be on a set memory location, any change that allows multiple crates with "rt" enabled to exist is wrong. If anything, we should add |
Thanks for double checking my work! You're right, I completely forgot about the RT feature of the PACs, I'll update the test cases shortly, but I agree that actually we should have the |
I'm slightly concerned that when we release 1.0 some of our deps may in inadvertently break esp-hal builds by accident. I'm not sure what happens when:
Another similar scenario:
I'm bringing this up now as although the rt crates are private, they might have the power to break builds if we're not careful, so we need to be sure.
The text was updated successfully, but these errors were encountered: