-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
scripts: check_init_priorities: use the zephyr executable file [WAS: scripts: add dump_init_order.py] #62459
scripts: check_init_priorities: use the zephyr executable file [WAS: scripts: add dump_init_order.py] #62459
Conversation
ca9df0a
to
e3cc466
Compare
3362259
to
ddc5701
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it :)
Very cool! Should this be added as a west target for convenience/ better discoverability? |
Thanks for the feedback folks, I thought more about this and realized that the information here works for So I'm taking a 180 on this one, going to rip the file scanning code off @kartben yes will look into adding a target |
0d03b81
0d03b81
to
b2f81d2
Compare
703e7b5
to
c78a7e7
Compare
9367106
to
fdbea03
Compare
Ok small update now that I managed to get my hands on an armclang file, there's two problems: 1 - the init data is spread into multiple sections, looks something like:
2 - the symbols for the init section boundaries are not there, looks like the linker resolved and ate them up So [1] is easy to fix and I've actually decided to integrate the change regardless: I've just changed [2] is a more of a problem though, if the armclang linker cannot be configured to omit those symbols (some debug option?) I think I'll have to either guess the symbols from those Waiting for further feedback from @tejlmand. |
Wonder how the linker ended up with those now that I looked into it, from the content these seems to be 103: Was trying to correlate those in the code but maybe it's better to just shut this off for armclang for the moment. Waiting to hear if it works for ARCMWDT at least. |
Rework check_init_priorities to use the main executable file instead of the individual object files for discovering the devices. This should make the script more robust in case of stale files in the build directory, and also makes it work with LTO object files. Additionally, keep track of the detected init calls, and add a handy "-i" option to produce a human readable print of the initcalls in the call sequence, which can be useful for debugging initialization problems due to odd SYS_INIT and DEVICE interactions. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a new "initlevels" target that can be used to print a human readable version of the init sequence by running: west build -t initlevels. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
fdbea03
to
39c1961
Compare
Added a conditional to skip this for armclang binaries, no point blocking on that, it can be fixed down the road by someone that have access to that compiler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with MWDT toolchain - seems to be working fine.
@evgeniy-paltsev thanks for testing this @tejlmand can we go ahead with this one excluded on armclang for now? Then you folks with access to that compiler can look into this whenever you have time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, just a couple of minor nits to get cleaned out before final +1.
7952abf
39c1961
to
7952abf
Compare
The script does not play well with armclang binariest at the moment. Disable the automatic invocation when running with armclang, at least until this is investigated and fixed. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
7952abf
to
4706d0e
Compare
Reworked the "no armclang support" patch, it now works by:
|
${fail_on_warning} | ||
) | ||
endif() | ||
|
||
if(NOT CMAKE_C_COMPILER_ID STREQUAL "ARMClang") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not fond, of it, but I see your reasoning here.
#62459 (comment)
and users could want to run the target even with the kconfig to n
.
I don't think this specific feature is strong enough to have something along TOOLCHAIN_CREATES_GOOD_ELF
or similar.
So accepted for now, and let's see if we can find a way with armclang to support the check init feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm sure it can be fixed, those stripping options in cmake/bintools/armclang/elfconvert_command.cmake
looks suspicious to me. It'd be cool to figure a way of having a CI run with these compilers so we don't depend on individuals to test stuff though.
I'll file an issue about it, it's worth discussing.
Hi, this is a rework of device discovery code of
check_init_priorities
. Instead of finding all the individual object files and find the level+piority from the section name, parse back theinitlevel
section from the output elf file. This means that the script is not impacted by stale files in the build directory, but more importantly it makes it work with LTO builds, where somehow the intermediate object fiels sections are completely mangled up.While doing this, add a feature to print a human readable format of the initialization sections. This is pretty much just a friendlier version of
arm-zephyr-eabi-objdump -j initlevel -j device_area -d build/zephyr/zephyr.elf
. I'm using it to troubleshoot SYS_INIT order breakages, though I'm thinking one may use it in CI to compare the known sequence order of a build and catch unintended changes.Looks something like this:
Very much inspired by a comment from @bjarki-trackunit on the original proposal, should be fairly easy to adapt to #61986.
Also pushed on https://github.com/zephyrproject-rtos/zephyr-testing/tree/vfabio-testing-branch
Since this now needs to work on a linked library I had to tweak the CMakeFiles a bit, and also it turns out this does not quite work with the elf file when using
NATIVE_LIBRARY
, although it does on the final exe. I could hack around it but I'd rather turn it off in that case right now and look for a proper solution down the road.