This tool will be used to generate C wrappers for the C++ LLVM libc
implementations. This change does not hook this tool up to anything yet.
However, it can be useful for cases where one does not want to run the
objcopy step (to insert the C symbol in the object file) but can make use
of LTO to eliminate the cost of the additional wrapper call. This can be
relevant for certain downstream platforms. If this tool can benefit other
libc platforms in general, then it can be integrated into the build system
with options to use or not use the wrappers. An example of such a
platform is CUDA.
Details
- Reviewers
abrachet - Commits
- rGa32af8252fde: [libc] Add a tool called WrapperGen.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This looks good. I wonder though how we will deal with global variables. Those can't be easily wrapped like functions can.
libc/utils/tools/WrapperGen/Main.cpp | ||
---|---|---|
19–21 | How do you imagine we will invoke this tool? Our list of function names is in TableGen so it wouldn't be easy to run this over every function name. Will this be called from add_entrypoint_object then? | |
58 | I think this should be fine because all we care about it ABI compatibility, and we're only including the src/ headers not the include/ ones so the compiler wont complain there. |
Yes, global variables question is open if we have to support them in some manner. The one we have currently, errno which not really global but like one, is accessed by the extension function __errno_location. So, we are good in this case. If there are other global variables we need to support (nothing comes to my mind), we can take that up at that time.
libc/utils/tools/WrapperGen/Main.cpp | ||
---|---|---|
19–21 | Yes, the build rules will be the right place to hook this up. The downstream use case I am working with does exactly that. | |
58 | Right. In the existing code, there are no examples which break. But, added this TODO just in case. Does not add value you think? |
There are the stupid globals related to getopt :). Indeed solvable later.
libc/utils/tools/WrapperGen/Main.cpp | ||
---|---|---|
58 | No preference either way. |
How do you imagine we will invoke this tool? Our list of function names is in TableGen so it wouldn't be easy to run this over every function name. Will this be called from add_entrypoint_object then?