Details
- Reviewers
ABataev
Diff Detail
Event Timeline
To pass wrapper bitcode directly to the linker when LTO is enabled. LTO plugin does not accept bc if there is no data layout.
In this case clang driver would need to get it from somewhere in order to pass it to the wrapper tool. I do not know where it can get it from.
Ok, it is possible to do it like you suggested, but I think that teaching wrapper tool to set data layout without external help is more preferable. There is a certain difference between opt and wrapper tool – opt works on the existing .bc that is provided in command line and data-layout option just gives user an optional way to override input’s data layout while wrapper tool creates output .bc from scratch. With your proposal, data-layout would become sort of mandatory option for the wrapper tool which is not very convenient. I believe wrapper tool should be able to set it without external help, and we can always add an option to override data layout (similar to opt) if there would be a need for that.
Why it is not convenient? Plus, when you're trying to build the data layout yourself, you end up with the default one for the given target rather than rely on the one specified by the user when the driver was invoked. So, I think, it would be better to get the data layout from the driver rather than use the default one.
I would agree with you if data layout was indeed available in the driver, but unfortunately driver does not have access to any existing TargetInfo instance (or maybe I just have not found it). So, I have to create TargetInfo and build data layout even for the case when driver passes it to the wrapper tool. I guess that would also be a default data layout, so it would not differ much from what I have already done in this patch. BTW, I will probably upload an alternative patch where I have implemented your suggestion, just to compare))
Of course, this is not a good solution. I was hoping that TargetInfo is available in driver. Otherwise, it would be good somehow to read the target data from the .bc file.
Wrapper tool is invoked at link phase, therefore there just could be no .bc files available to read data layout from. Ok, looks like there is no good solution for the data layout problem, so I will drop the idea of passing wrapper .bc directly to the linker when LTO is enabled (at least for now:). I will abandon this patch.