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

Use environment to override stack/heap sizes #155

Merged
merged 1 commit into from Apr 5, 2024

Conversation

therealbstern
Copy link

This allows setting an environment variable at build time to change the stack and/or heap sizes without having to fork teensy4-rs and/or patching build.rs. The variables in question are TEENSY4_HEAP_SIZE and TEENSY4_STACK_SIZE and they default to the current values in build.rs if they're not present or won't parse::<usize>().

It is recommended to set the variables in the [env] section of Cargo.toml but not required.

Note that changing the environment variables doesn't trigger a rebuild without a cargo clean. I'm open to suggestions on how to make rebuilds happen.

build.rs Outdated Show resolved Hide resolved
build.rs Outdated Show resolved Hide resolved
@therealbstern
Copy link
Author

@mciantyre I'm going to make the changes suggested above; I'll ping you when this is complete.

Unless you have no interest in this PR, in which case you can close it.

@therealbstern
Copy link
Author

@mciantyre I think this is ready for you if you are interested in it.

@mciantyre
Copy link
Owner

I'm interested in the feature, and I'd prefer to maintain it outside of the BSP if possible. I think the main change here could look something like

diff --git a/build.rs b/build.rs
index 201ff96..861d6be 100644
--- a/build.rs
+++ b/build.rs
@@ -10,8 +10,10 @@ fn main() {
         })
         .heap(Memory::Ocram)
         .heap_size(16 * 1024)
+        .heap_size_env_override("TEENSY4_HEAP_SIZE")
         .stack(Memory::Dtcm)
         .stack_size(16 * 1024)
+        .stack_size_env_override("TEENSY4_STACK_SIZE")
         .vectors(Memory::Dtcm)
         .text(Memory::Itcm)
         .data(Memory::Dtcm)

with the behavior described in the PR summary. We move this support into the runtime. imxrt-rs/imxrt-rt#13 proposes the feature.


Note that changing the environment variables doesn't trigger a rebuild without a cargo clean.

Take a look at cargo:rerun-if-env-changed in the build scripts documentation.

@therealbstern
Copy link
Author

therealbstern commented Mar 1, 2024

We move this support into the runtime. imxrt-rs/imxrt-rt#13 proposes the feature.

Great, I'm perfectly happy with you putting it wherever makes the most sense to you.

Take a look at cargo:rerun-if-env-changed in the build scripts documentation.

Thank you, that's ideal.

If you want to close this because it's superseded, that's fine with me.

@mciantyre mciantyre merged commit 2f2cd1f into mciantyre:master Apr 5, 2024
7 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.

None yet

3 participants