2024-04-25
Participants
-
Parth
-
Alexey Karyakin
-
Ana Pazos
-
Anmol Paralkar
-
Anton R.
-
Daniel Thornburgh
-
Garrett Van Mourik
-
Garvit Gupta
-
Jonathon Penix
-
Paul Kirth
-
Peter Smith
-
Petr Hosek
-
Prabhu
-
Ram Nalamothu
-
Scott
-
Stan Kvasov
-
Vince Del Vecchio
-
Wyatt
-
Todd Snider
-
Volodymyr Turanskyy
Agenda
-
Follow up on [RFC] Improve map-files for effective analysis and debugging - #16 by partaror_07 1 discussion.
-
Follow up on [RFC] A user-guided ROM patching mechanism for embedded applications discussion.
-
(Petr) Feedback on RFC: Support for Memory Regions in ELF
-
(Petr) Feedback on [RFC] LLD --enable-non-contiguous-regions
-
(Todd) Assistance for debugging embedded applications built with LTO?
-
Not discussed, FYI-only: Interesting discussions in the community:
- Llvm-objcopy --compress-sections 1
- Using KASan for bare-metal Google Online Security Blog: Address Sanitizer for Bare-metal Firmware 1
- Bare-metal prof lib update to latest format Main proflib10 by smithp35 · Pull Request #423 · ARM-software/LLVM-embedded-toolchain-for-Arm · GitHub
Discussion
LLD map-files improvements RFC (Parth)
-
Refresh from last time.
-
Petr:
-
There is an old Phabricator review ⚙ D63190 Add -gnu-map option to emit a map file in the GNU-tsyle format. for an GNU LD compatible map file implementation. There are a lot of projects that consume LLD map files, so we should preserve the current format for compatibility.
-
Having a JSON format we would be able to process it easier as well as transform it into different specific formats.
-
Proposal is to use JSON + a transform to existing LLD format for compatibility. Make the default output as GNU LD.
-
JSON support is how other tools approach the issue, it would be good for consistency of LLVM binutils user experience.
-
-
A possible con against JSON: JSON grows very quickly because of a lot of duplication of information, so for big projects it can easily become unmanageable. A workaround could be to make the output a compressed stream.
-
Peter: Configurable level of detail of the resulting map file - we have the same in armlink as --info command line option, works nicely.
-
Peter: What to include in the output? What is provided in the GNU LD file sounds good already.
-
Possible additional information to provide:
-
Expressions for debugging
-
(Petr) now there is no good way to extract something like AST from LLD, there is an effort to re-do the LLD parser to create a proper AST, then build IR and have a pass manager with clear passes. This would enable expression debugging additional info. Equally, we can use print-before/print-after for a pass like in clang, for debugging, which might be better than dumping it into the map file. This will be worked on over the summer as a project.
-
(Peter) There may be an opportunity to progressively print out values as expressions are evaluated, but this is likely to be not very user friendly.
-
(Daniel) Current lambda function based LLD implementation of parsing and processing linker script files may not be optimal either, so will benefit from the rework into AST/IR.
-
-
Tool version and the actual command line:
- Agreed. Analog of “-grecord-gcc-switches” command line option would be very useful.
-
-
ROM patching
-
Peter is reviewing and will comment, hopefully, next week.
-
The main concern is, if the added complexity justifies the use case.
Memory Regions in ELF
-
Peter commented.
-
The key issue is that attribute(section) now can be merged by the compiler.
-
Proposal to create a mapping to memory regions and allow selection specific ones.
Enable non contiguous regions in LLD (Daniel)
-
There is the RFC and a patch for automatic placement to distribute across regions.
-
Peter: Is it possible to get “cycles” that never converge? → no, there is a mechanism to ensure progress or link failure.
-
Scott: RFC: Support for Memory Regions in ELF This is something I have worked on in the past to address section placement overflow particularly when working with non-contiguous memory regions e.g. ARM’s SRAM_L and SRAM_U - Prior Art Database - IP.com.
Debugging LTO (Todd)
-
(Peter) there may be multiple dimensions to the problem:
-
Debug info?
-
Difference in behaviour?
-
Code removed?
-
-
Peter: General recommendation may be to “bisec” split LTO non-LTO pieces of build and gradually move into the LTO scope.
-
Other experience:
-
Scott
-
Debug info usually is OK
-
There is the memory region problem - cannot palace where needed.
-
-
Paul
-
Usually the code has a lot of bad assumptions about inlining, changes across TUs.
-
How to debug: save-temps/IR between passes - similar to debugging a compiler. GCC is a bit easier to use because of the different LTO model.
-
Optimisation marks can also be used, e.g. for tracking of inlining.
-
-
-
Todd: Can we provide before/after views to simplify debugging to show the user what happened?