Proposal: Allow setting the stack size on build time#184
Conversation
- using templating to create layout file on build time
4ae8928 to
288b245
Compare
|
This doesn't really get us anything does it? The default stack size is too large for the HiFive1 so now an entire board won't work without users specifying an environment variable. |
As you said: a user of the library can set the stack size of the board. I could put the smaller stack size into the Makefiles making it more obvious. |
|
I would propose to define an overrideable default stack size per board. The stack should be big enough s.t. the largest possible number of examples runs without problems. This is very important for new The opposite approach based on defining a stack size per app is conceptually wrong in my opinion as the stack consumption does not only depend on the app code but on the target architecture and other compiler settings as well. |
|
The stack usage is mostly app dependent. It is also compiler and architecture dependent, but I don't think there is much difference between the architectures for stack usage. |
|
@alistair23: would it make sense to merge this PR in your eyes? As a next step we could move the examples which work with the Hifive board into separate crates (although I won't promise that this will be a trivial task as we have never tested using |
|
I'm not sure what the advantage is here, now it seems like users have to figure out stack sizes and change them manually. |
That point is that
I suppose this is what you wanted to achieve with #180 ? |
|
This seems like a step in the wrong direction though.
|
|
I personally don't need this change I rather looked for a straightforward way to implement the changes aimed in #180 which I refused to accept.
Requirements for heap/stack are different for apps which use
You can. You can even hard-code this is in the Makefile. I am okay with closing this PR alongside with #180 |
|
Closing because I believe #244 made this obsolete. |
Contents
In this PR I propose a way to set the stack size on build time. I use a very simple replacement routine on build time to create the layout files of the app which sets the stack size obtained from the environment variable
APP_STACK_SIZE.Advantages
I think there will be more use cases which need to change the layout file on compile time as for example multiple app support.
Disadvantages
Changing the stack size is not possible per app, at least not trivially. If this is absolutely required one could read the required stack sizes from configuration files next to the examples. However, the main use case for the build system should be supporting to build one app in one crate depending on
libtock-rs.Also reading from environmental variables might not be the preferred way to configure a build system. But any change to this should come alongside with a change to the usage of the variables
PLATFORM,APP_HEAPandKERNEL_HEAP.Extensions
As
build.rsis growing some of the functionality should be moved to a separate "build tools" crate.Moreover, I feel that some sections of
layout_generic.ldand the layout files themselves could be generated from primitive values like the beginning of the ram, the size of the kernel from the platform etc. so the linker files get easier to maintain.