-
-
Notifications
You must be signed in to change notification settings - Fork 11
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 using different toolchain versions in one Nerves project #146
Comments
IMO this problem is already solved by mix targets Toolchain major versions currently follow GCC major versions. I don't see how having new hex package for every major version changes anything here.
Is there anything different in practice? |
@Damirados Could you try doing this in a project? Maybe that will make it more apparent when you get the dependency resolution failure due to one project requiring |
I have setup example repo
Currently Mix does not consider target when doing dependency resolution. |
Following advice from elixir-lang/elixir#14040 I have made changes to mix.exs Damirados/nerves_mix_target_bug@cc5deb9 It works well for this scenario. |
This is great! Thank you for working through this. I would definitely like to get this documented publicly somewhere. It will certainly help people. On the other hand, I have first hand experience with supporting multiple lockfile issues, so I don't want this to be a common Nerves setup. Practically speaking that means that I wouldn't put it in the Nerves new project generator, and that's one place I'd need it to support a mixed GCC 13/14 set of systems. The alternative of creating a toolchain package with the gcc version number in it is looking really interesting to me. I know it's ugly, but it's conceptually simple and would work with zero effort from Nerves users. The total lack of end user support that we'd need to do is what's most appealing. The decoupling of release timing between systems maintainers is also appealing and will allow Nerves to scale to more platforms as it will be easier to include deps for less-frequently maintained hardware. I'm assuming a |
Currently each toolchain is specified as a hex dependency in the Nerves system. It's important that the toolchain that compiled the Nerves system is compatible with the one being used to compile NIFs and ports in a Nerves project. For example, it would be bad if a Nerves user got a toolchain update that updated the C runtime libraries without the corresponding Nerves system update. That could result in a new function being called that wasn't in the shared libraries included with the system and would cause code to break at runtime.
The way this is currently solved is by using mix dependencies to ensure toolchain versions match and works well most of the time.
The problem comes when you have a multi-target Nerves project. All Nerves systems in that project need to be updated in unison when the toolchain changes. This is because mix only allows one version of the dependency in a project at a time. In theory, the Nerves project should be fine since the Mix target specs for the dependencies ensure this constraint. However Elixir doesn't have a means for supporting this and it may, in fact, cause more confusion if it were added since dependency resolution already is a hard problem.
One solution is to create a new hex package for every major version of GCC. That way a Nerves system that would work better with GCC 14 doesn't need to wait for a GCC 13 bug fix for a different Nerves system. See #145 for an example that is causing this to happen. This also would help improve the situation where if you have a project that pulls Nerves systems from multiple maintainers, you don't have to wait for all of the maintainers to publish an update before upgrading yourself. This situation also requires improvements to the Nerves system, but decoupling toolchains is needed for it too.
The downside of making a hex package per GCC version is that it really adds a lot of hex packages. This looks like an inelegant solution when you first see it, but it's unclear what would be significantly better. It also looks hard to maintain unless this project gets updated to generating mix toolchain projects via scripts.
The text was updated successfully, but these errors were encountered: