<div dir="ltr"><div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">InstrProfData.inc is shared between LLVM and compiler-rt:<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><a href="https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ProfileData/InstrProfData.inc">https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ProfileData/InstrProfData.inc</a><br><a href="https://github.com/llvm/llvm-project/blob/main/compiler-rt/include/profile/InstrProfData.inc">https://github.com/llvm/llvm-project/blob/main/compiler-rt/include/profile/InstrProfData.inc</a><br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">There's no special mechanism to keep those in sync, we manage them manually.</blockquote><div><br></div><div>Thanks Petr. That's about the same amount of code that ORC will need to share I think. Glad there's a precedent to follow.</div><div><br></div><div>-- Lang. </div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 24, 2021 at 4:29 PM Petr Hosek <<a href="mailto:phosek@google.com">phosek@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>InstrProfData.inc is shared between LLVM and compiler-rt:</div><div><br></div><div><a href="https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ProfileData/InstrProfData.inc" target="_blank">https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ProfileData/InstrProfData.inc</a><br></div><div><a href="https://github.com/llvm/llvm-project/blob/main/compiler-rt/include/profile/InstrProfData.inc" target="_blank">https://github.com/llvm/llvm-project/blob/main/compiler-rt/include/profile/InstrProfData.inc</a><br></div><div><br></div><div>There's no special mechanism to keep those in sync, we manage them manually.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 24, 2021 at 3:56 PM David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Yeah, for buildability (for instance, Google's build system doesn't<br>
have any special dispensations for header only libraries - doesn't<br>
allow arbitrary includes without dependencies - and I think this is<br>
generally a good thing) it's probably best/necessary to duplicate.<br>
<br>
Though now that I think about it, I think there is /something/ shared<br>
between compiler-rt and LLVM - for xray and instrumented profiling, I<br>
think there are some common constants or data structures or something.<br>
Might be worth checking how those work?<br>
<br>
On Sat, Apr 24, 2021 at 2:10 PM Lang Hames via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hi Chris,<br>
><br>
>> Ok, so you’re saying you want it to be part of the llvm/llvm-project/tree/main/compiler-rt tree, but not part of the compiler_rt library itself, got it.<br>
>> Does compiler-rt currently depend on LLVM libraries?  Does this change the dependence graph of the llvm and compiler-rt subproject?<br>
><br>
><br>
> As far as I know no compiler-rt libraries depend on LLVM. The ORC runtime definitely doesn't, so there would be no change to the dependence graph.<br>
><br>
> In my prototype branch I have used some header-only includes from LLVM for shared data structures and serialization utilities. I'm not sure what the policy is on that, but if we want to prohibit any LLVM includes then those files could just be duplicated -- they're quite small and self contained.<br>
><br>
> -- Lang.<br>
><br>
> On Thu, Apr 22, 2021 at 4:20 PM Chris Lattner <<a href="mailto:clattner@nondot.org" target="_blank">clattner@nondot.org</a>> wrote:<br>
>><br>
>> Ok, so you’re saying you want it to be part of the llvm/llvm-project/tree/main/compiler-rt tree, but not part of the compiler_rt library itself, got it.<br>
>><br>
>> Does compiler-rt currently depend on LLVM libraries?  Does this change the dependence graph of the llvm and compiler-rt subproject?<br>
>><br>
>> -Chris<br>
>><br>
>> On Apr 19, 2021, at 10:31 AM, Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:<br>
>><br>
>>> Arguments in favor are that the build requirements are very similar, and there are some conceptual parallels (the ORC runtime is providing implementations for entry points generated by the compiler and linker, among other things). On the other hand the implementations are all JIT specific, which is definitely different from everything else in compiler-rt.<br>
>><br>
>><br>
>> After a night to think about it I think I'd rephrase this: The ORC runtime is a JIT-specific compiler runtime library. From a JIT developer's point of view it is an excellent fit for compiler-rt, and from a static compiler developer's point of view it's a non-entity, so just dead weight.<br>
>><br>
>> If compiler-rt were broken up then it would make sense to have the ORC runtime be a separate subproject and client of the common complier-rt build infrastructure. That would be the ideal solution. Until then I think compiler-rt seems like the best home for it -- making the ORC runtime its own subproject now would duplicate compiler-rt's build system only for us to have to reconcile it later (or worse, maintain the duplication indefinitely).<br>
>><br>
>> Petr, Eric -- Do you have a sense of how difficult it would be to lift compiler-rt's common build infrastructure out? Being new to compiler-rt I'm wary of tackling that, but if you think it'd be easy I'm happy to work with you to try to get it done.<br>
>><br>
>> -- Lang.<br>
>><br>
>><br>
>> On Sun, Apr 18, 2021 at 9:50 PM Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:<br>
>>><br>
>>> Hi Chris,<br>
>>><br>
>>> My understanding is that compiler-rt is an umbrella project that builds a number of libraries (builtins, asan, tsan, fuzzer, etc.), and my thought was that the ORC runtime could fit in as an addition to that set. Arguments in favor are that the build requirements are very similar, and there are some conceptual parallels (the ORC runtime is providing implementations for entry points generated by the compiler and linker, among other things). On the other hand the implementations are all JIT specific, which is definitely different from everything else in compiler-rt.<br>
>>><br>
>>> If not compiler-rt, is there anywhere else that you think this project would fit? Would it make sense to introduce it as a new top-level project?<br>
>>><br>
>>> -- Lang.<br>
>>><br>
>>> On Sun, Apr 18, 2021 at 9:08 PM Chris Lattner <<a href="mailto:clattner@nondot.org" target="_blank">clattner@nondot.org</a>> wrote:<br>
>>>><br>
>>>> Hey Lang,<br>
>>>><br>
>>>> Is your goal here to make this part fo compiler_rt the generated library, or part of the subproject?  This seems conceptually very different than compiler_rt (which was supposed to be entry points implicitly generated by the compiler).  Should this be its “own thing”?<br>
>>>><br>
>>>> -Chris<br>
>>>><br>
>>>> On Apr 17, 2021, at 1:51 PM, Lang Hames via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>>><br>
>>>> Hi All,<br>
>>>><br>
>>>> I've broken the compiler-rt cmake changes and new directories out of the ORC runtime prototype and posted them for review in <a href="https://reviews.llvm.org/D100711" rel="noreferrer" target="_blank">https://reviews.llvm.org/D100711</a>.<br>
>>>><br>
>>>> Most of this was adapted from xray's cmake files and project layout. I'm not a CMake expert, so I expect there's room for improvement here, but otherwise I'm hoping it's a pretty canonical "new compiler-rt library".<br>
>>>><br>
>>>> Kind Regards,<br>
>>>> Lang.<br>
>>>><br>
>>>> On Wed, Apr 14, 2021 at 10:34 AM Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:<br>
>>>>><br>
>>>>> Hi All,<br>
>>>>><br>
>>>>> Petr -- since the ORC runtime's dependencies are similar to libFuzzer's, is there any reason not to land the ORC runtime in compiler-rt now and then break it out again later? If the compiler-rt refactor is likely to happen soon then it's worth waiting, otherwise I think landing it in compiler-rt sooner rather than later is the best option, so that any kinks in the integration can be worked out before any future compiler-rt refactor.<br>
>>>>><br>
>>>>> -- Lang.<br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> On Mon, Apr 12, 2021 at 4:38 PM Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:<br>
>>>>>>><br>
>>>>>>> From this it sounds like "convenient reusing of the build system" rather than "should be included in compiler-rt as a library"? If that's the case maybe making it clear or lifting the common build system support out might be maintainable without the "this is a runtime library for the system" sort of thing?<br>
>>>>>><br>
>>>>>><br>
>>>>>> Yeah. It sounds like in an ideal world we'd lift out the common build system support, then have a new set of sub-projects that re-use that generic build system.<br>
>>>>>><br>
>>>>>> Do you have any sense of how difficult it would be to lift out that common build system code? If that's relatively easy then maybe the right approach is to do that first, then land the ORC runtime. Otherwise the ORC runtime could go in to compiler-rt for now, then be split out with the rest of compiler-rt when it's broken up -- it doesn't require any meaningful changes to existing compiler-rt code, so it should be very easy to break back out again later.<br>
>>>>>><br>
>>>>>> -- Lang.<br>
>>>>>><br>
>>>>>><br>
>>>>>> On Mon, Apr 12, 2021 at 3:51 PM Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>> wrote:<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> On Mon, Apr 12, 2021 at 6:36 PM Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:<br>
>>>>>>>><br>
>>>>>>>> Hi Petr,<br>
>>>>>>>><br>
>>>>>>>>> I'd like to better understand the structure of the ORC runtime and its dependencies (both build and runtime). Does it use the C or C++ standard library? Does it depend on other parts of LLVM? Do you plan on reusing some of the existing compiler-rt libraries like sanitizer_common?<br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>> The ORC runtime currently uses the C++ standard library.<br>
>>>>>>>> Since the ORC runtime needs to communicate with the LLVM ORC library it also currently uses some header-only includes from LLVM. It does not depend on any LLVM libraries. We could duplicate this code, but I'd prefer to share it if possible.<br>
>>>>>>>> I have not used sanitizer_common, but some parts of it look like they may be useful.<br>
>>>>>>>><br>
>>>>>>>> I gravitated towards implementing the ORC runtime in compiler-rt because I need to be able to write parts of it in platform-specific assembly (which compiler-rt supports), and because the runtime should be build for all targets, not just the host (which seems to be the standard way that compiler-rt is configured).<br>
>>>>>>>><br>
>>>>>>><br>
>>>>>>> From this it sounds like "convenient reusing of the build system" rather than "should be included in compiler-rt as a library"? If that's the case maybe making it clear or lifting the common build system support out might be maintainable without the "this is a runtime library for the system" sort of thing?<br>
>>>>>>><br>
>>>>>>> -eric<br>
>>>>>>><br>
>>>>>>>>><br>
>>>>>>>>> To give a bit more background on why I'm interested, compiler-rt has grown fairly organically this has been making the maintenance more and more difficult, at least from the build perspective. There are some runtimes that only use C, some that use C++, some that use C++ standard library. When building compiler-rt together with other runtimes like libc or libc++, it's difficult to pick up the right order which is why we have several entry points into compiler-rt's build system to build different subsets and that's been a maintenance headache.<br>
>>>>>>>>><br>
>>>>>>>>><br>
>>>>>>>>> I've been thinking about this quite a bit recently and I repeatedly came to the conclusion that compiler-rt would ideally be broken up into several subprojects, but that should probably be discussed as a separate topic. However, understanding the build and runtimes dependencies of the ORC runtime could help us decide whether it should be a part of compiler-rt or be a separate subproject.<br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>> That makes sense to me. I think of the ORC runtime as a compiler-rt-style runtime with a libc++ dependency. In that sense I think it's similar to libFuzzer, and whatever solution we come up with for libFuzzer would probably also be applicable to the ORC runtime too.<br>
>>>>>>>><br>
>>>>>>>> -- Lang.<br>
>>>>>>>><br>
>>>>>>>> On Mon, Apr 12, 2021 at 2:36 PM Petr Hosek <<a href="mailto:phosek@google.com" target="_blank">phosek@google.com</a>> wrote:<br>
>>>>>>>>><br>
>>>>>>>>> I'd like to better understand the structure of the ORC runtime and its dependencies (both build and runtime). Does it use the C or C++ standard library? Does it depend on other parts of LLVM? Do you plan on reusing some of the existing compiler-rt libraries like sanitizer_common?<br>
>>>>>>>>><br>
>>>>>>>>> To give a bit more background on why I'm interested, compiler-rt has grown fairly organically this has been making the maintenance more and more difficult, at least from the build perspective. There are some runtimes that only use C, some that use C++, some that use C++ standard library. When building compiler-rt together with other runtimes like libc or libc++, it's difficult to pick up the right order which is why we have several entry points into compiler-rt's build system to build different subsets and that's been a maintenance headache.<br>
>>>>>>>>><br>
>>>>>>>>> I've been thinking about this quite a bit recently and I repeatedly came to the conclusion that compiler-rt would ideally be broken up into several subprojects, but that should probably be discussed as a separate topic. However, understanding the build and runtimes dependencies of the ORC runtime could help us decide whether it should be a part of compiler-rt or be a separate subproject.<br>
>>>>>>>>><br>
>>>>>>>>> On Mon, Apr 12, 2021 at 12:26 PM Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:<br>
>>>>>>>>>><br>
>>>>>>>>>> Hi All,<br>
>>>>>>>>>><br>
>>>>>>>>>> I'd like to add the ORC runtime library (preview available at <a href="https://github.com/lhames/llvm-project/tree/orc-runtime-preview" rel="noreferrer" target="_blank">https://github.com/lhames/llvm-project/tree/orc-runtime-preview</a>) to compiler-rt.<br>
>>>>>>>>>><br>
>>>>>>>>>> Background:<br>
>>>>>>>>>><br>
>>>>>>>>>> ORC, like MCJIT, can link JIT'd code either into the current process ("in-process" mode) or into a remote executor process ("cross-process" mode). Some JIT features require support code in the executor process, but the existing ORC libraries are only linked into the JIT process. This has made cross-process mode support for those features (which include static initializers, thread local variables, exception handling, and others) awkward or impractical to implement. The ORC runtime library aims to provide the necessary support code in a form that is loadable by the JIT itself, which should allow these features to work uniformly in both modes.<br>
>>>>>>>>>><br>
>>>>>>>>>> My prototype branch of the ORC runtime (available at <a href="https://github.com/lhames/llvm-project/tree/orc-runtime-preview" rel="noreferrer" target="_blank">https://github.com/lhames/llvm-project/tree/orc-runtime-preview</a>) has advanced to the point where it can provide uniform support for static initializers, destructors, exceptions, thread locals, and language registration for Objective C and Swift code. This support is all MachO/Darwin only so far, but should be easily adaptable for ELF/Linux/BSD support.<br>
>>>>>>>>>><br>
>>>>>>>>>> Proposal:<br>
>>>>>>>>>><br>
>>>>>>>>>> The proof of concept implementation has been very successful, so I would like to move future development to the LLVM main branch so that others can benefit from this.<br>
>>>>>>>>>><br>
>>>>>>>>>> Before I start posting patches, though:<br>
>>>>>>>>>><br>
>>>>>>>>>> Does anyone see any problems with including this in compiler-rt?<br>
>>>>>>>>>><br>
>>>>>>>>>> Does anyone think that there is a more reasonable home for the ORC runtime within the llvm-project? I considered LLVM itself, or a new top-level project, but neither seemed as natural a fit as compiler-rt.<br>
>>>>>>>>>><br>
>>>>>>>>>> Finally, if everyone is happy for it to be included in principle, are there any volunteers to review ORC runtime patches?<br>
>>>>>>>>>><br>
>>>>>>>>>> Regards,<br>
>>>>>>>>>> Lang.<br>
>>>><br>
>>>> _______________________________________________<br>
>>>> LLVM Developers mailing list<br>
>>>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>>>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>>>><br>
>>>><br>
>><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
</blockquote></div>