-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add CMake functions for time_critical section placement of target sources #2677
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
base: develop
Are you sure you want to change the base?
Add CMake functions for time_critical section placement of target sources #2677
Conversation
…rces part of raspberrypi#2653 This change introduces two new CMake functions: ``` pico_sections_time_critical(TARGET [SOURCES]) ``` Prefixes the target's object file sections with ".time_critical" ``` pico_sections_not_in_flash(TARGET [SOURCES]) ``` Prefixes the target's object file sections with ".time_critical_ram"
Testing this with the
My CMake version is 3.25.1, and it looks like most of the |
Bummer, but thanks for testing and figuring this out! I'm new to CMake and had no idea I was using such recent features. My CMake version is 3.28.1, and the 3.27 release notes from July 18, 2023 support your observation about the I also assume it's an unreasonable ask to have the pico-sdk's minimum version bumped to 3.27, is that correct? Is it an important goal for the pico-sdk to support older versions of CMake down to version 3.13 from November 20, 2018 or version 3.17 from March 20, 2020? What determines the pico-sdk's minimum version? In Java projects that I've worked on using Gradle based builds it's common practice to follow the latest releases of the Gradle toolchain and even to specify a particular Gradle version to be used within a project for stability and build reproducibility reasons. Is that strategy also common in the CMake world? Is that strategy just not applicable here to the pico-sdk since an sdk needs to support a wide range of CMake versions being specified in the projects that consume it? This seems like a deal breaker for merging my CMake functions in their current form, is that correct? If so, do you have any ideas for an alternate but similarly straight forward and portable implementation that calls objcopy with a selected list of object file names? |
We want to support the CMake versions installed by major Linux operating systems (including Raspberry Pi OS), which are generally a bit behind the latest version (eg Ubuntu 22.04 uses 3.22, Debian Bullseye uses 3.18 and Bookworm uses 3.25), so 3.27 would be too recent for that. You could probably do it with regular Also, rather than echoing Also, as these functions would probably share common functionality (just different section names), it would be better to have a common function they both call, rather than duplicating the internals |
9bf202b
to
8bafd78
Compare
That makes a lot of sense.
Would it be acceptable for merge if we just don't make these utility functions available to projects that use CMake versions < 3.27, while leaving them available for use in projects that do use CMake versions >= 3.27? I've updated the PR to use this approach.
I settled on the current implementation with the external file because of two limitations that I ran into:
Maybe your CMake-foo is stronger than mine. Do you see a path around those limitations?
I've consolidated their common implementation into a new |
That would probably lead to a lot of user-confusion (and possibly bug-reports against pico-sdk 🐛 ) if somebody (with a newer version of CMake installed) created an "example project" that made use of one of these new functions; and then somebody else (with an older version of CMake) downloaded and tried to build that project? 🤔
|
Yes, I agree with @lurch that we wouldn’t want to merge this so it requires CMake 3.27, especially given it can probably be implemented in a way that still supports earlier CMake
Ah yes, I hadn’t twigged that you were generating multiple commands for But if you use regular |
I've broken out from my original PR for #2653 as @will-v-pi suggested.
This change introduces two new CMake functions:
Which will prefix the target's object file sections with ".time_critical" based on matching them to source files.
Which will prefix the target's object file sections with ".time_critical_ram" based on matching them to source files.
These function's names mirror those of their code macro counterparts in the sections.h file. They are intended to be compatible with the "using XIP cache as SRAM" changes being introduced in #2660 but don't require those changes to be used with the existing binary type builds.