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

Exclude interrupt vector table from host build (e.g. in a build script) #44

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

summivox
Copy link
Contributor

Background

I was trying to use imxrt-hal in the build script of my firmware crate. This creates a difficulty: I am using the "rt" feature in the firmware crate. When I include imxrt-hal in the build deps, because features are additive, the build script is also linked with the vector table, which now complains about the lack of IRQ handlers.

Solution

I need a way to exclude the vector table from being linked into the build script.
Was going to try target_arch = "arm" and realized that it's possible for the host arch to be "arm" too.

Since the firmware is built with target_os = "none" and the build script is built on a non-bare-metal system, I went with this as the extra filter. It seems to be working.

I need a way to exclude the vector table from being linked into the
build script.  Was going to try target_arch = "arm" and realized that
it's possible for the host arch to be "arm" too.

Since the firmware is built with target_os = "none" and the build script
is built on a non-bare-metal system, I went with this as the extra
filter. It seems to be working.
Copy link
Member

@mciantyre mciantyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I don't see this hurting anyone, so I plan to release in the 0.5 series.

Did you have any luck using feature resolver version 2 to work around this issue? From my understanding, the resolver handles the case when build dependencies and normal dependencies need different builds and features enabled. The dependency / feature declarations might look like this.

[dependencies]
imxrt-ral = { version = "0.5", features = ["${MY_CHIP}"] }

[target.'cfg(all(target_os = "none", target_arch = "arm"))'.dependencies]
imxrt-ral = { version = "0.5", features = ["rt"] }

[build-dependencies]
imxrt-ral = "0.5"

@summivox
Copy link
Contributor Author

I tried resolver v2; unfortunately it did not work. It's strange because I just read the cargo book section from your link, and according to my impression your setup should work, but nope. Maybe it currently only stops build deps features from added to normal deps, but normal deps features regardless of condition are still added to build deps? /shrug

@mciantyre
Copy link
Member

Sorry, I'm not sure either, but thanks for giving it a try and following up.

I released this commit in imxrt-ral 0.5.3.

@mciantyre mciantyre merged commit 584f3a9 into imxrt-rs:master Aug 21, 2023
20 checks passed
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 this pull request may close these issues.

2 participants