<div dir="ltr">r257499<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 10, 2016 at 1:23 PM, Jakob Bornecrantz <span dir="ltr"><<a href="mailto:wallbraker@gmail.com" target="_blank">wallbraker@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Dec 24, 2015 at 1:28 AM, Jakob Bornecrantz <<a href="mailto:wallbraker@gmail.com">wallbraker@gmail.com</a>> wrote:<br>
> On Wed, Dec 23, 2015 at 9:38 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br>
>> On Wed, Dec 23, 2015 at 3:28 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>
>>> On Wed, Dec 23, 2015 at 11:25 AM, Aaron Ballman via llvm-dev<br>
>>> <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>>><br>
>>>> On Wed, Dec 23, 2015 at 1:55 PM, Jakob Bornecrantz <<a href="mailto:wallbraker@gmail.com">wallbraker@gmail.com</a>><br>
>>>> wrote:<br>
>>>> > On Wed, Dec 23, 2015 at 5:49 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
>>>> > wrote:<br>
>>>> >> On Wed, Dec 23, 2015 at 11:29 AM, Jakob Bornecrantz via llvm-dev<br>
>>>> >> <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>>> >>> I'm building on Windows x64 using cmake, Ninja and VS 2013 express on<br>
>>>> >>> Windows 7.<br>
>>>> >>><br>
>>>> >>> So I have been using the LLVMSharp method on getting a usable loadable<br>
>>>> >>> LLVM.dll[1][2].<br>
>>><br>
>>><br>
>>> One day, I would like to make it easier to make LLVM.dll...<br>
><br>
> We (not I) have rewritten the powershell script into a python<br>
> script[1] and where hoping that we could commit that to LLVM and have<br>
> it make a DLL during regular MSVC builds. And if possible shipping<br>
> that DLL with the Windows package (and Windows snapshot builds[2]).<br>
><br>
>>><br>
>>>><br>
>>>> > Further investigation show that for the MinGW build OLE32 is added to<br>
>>>> > the dependencies for LLVMSupport.lib in the CMakeLists.txt file, there<br>
>>>> > are a couple of other libraries added as well. This lead me to find<br>
>>>> > that those where added for the MSVC build with a pragma(lib, xx), so I<br>
>>>> > added such a pragma for OLE32 and that fixes my script that is<br>
>>>> > generating LLVM.dll, will also fix other peoples problems with OLE32<br>
>>>> > missing as well.<br>
>>>><br>
>>>> Generally speaking, static libraries like LLVMSupport are just an<br>
>>>> archive of a bunch of compiled object files, and whatever ultimately<br>
>>>> consumes that library is responsible for providing external<br>
>>>> definitions. So, for instance, clang.exe consumes LLVMSupport.lib and<br>
>>>> so it also links in OLE32. I believe that we usually only use<br>
>>>> #pragma(lib) to signal that non-standard libraries need to be linked<br>
>>>> in, otherwise every source file in an archive would wind up with an<br>
>>>> unwieldy number of pragmas for all its imports, or you would have to<br>
>>>> manually maintain that list in some common header file. I don't think<br>
>>>> that the pragma(lib) for advapi32.lib should be there either, FWIW,<br>
>>>> but I don't know that we've ever had a hard-and-fast rule for this<br>
>>>> sort of thing.<br>
>>><br>
>>><br>
>>> Sure, but the fact that static libraries can't encode their dependencies has<br>
>>> always been an annoying missing feature, not something that we want to<br>
>>> follow if we can avoid it.<br>
>><br>
>> Agreed.<br>
>><br>
>>>><br>
>>>> I'm not opposed to this patch, per se, but it feels like a slippery<br>
>>>> slope as to what makes the cut and what does not. I would rather see<br>
>>>> *less* non-standard pragma usage instead of more.<br>
>>><br>
>>><br>
>>> For these kinds of DLLs that are available on all modern versions of<br>
>>> Windows, I think it's perfectly reasonable to use the 'pragma comment lib'<br>
>>> auto linking mechanism. Realistically, no consumer of LLVMSupport.lib is<br>
>>> going to be surprised if it needs ole32.dll.<br>
>><br>
>> I think we're making the same point -- no consumer of LLVMSupport.lib<br>
>> should expect to work if it doesn't use the stock set of library<br>
>> dependencies. So use #pragma(lib) for everything that's not in that<br>
>> set, but expect consumers to at least be using the stock set. Unless<br>
>> you're suggesting we stick a #pragma(lib, user32) (et al) somewhere as<br>
>> well?<br>
><br>
> So ole32 and friends are added by default by cmake[3] which is why you<br>
> are seeing them on the executables.<br>
><br>
> Looking through the source I find advapi32.lib, psapi.lib, shell32.lib<br>
> and dbghelp.lib are added via pragmas. Of these psapi.lib and<br>
> dghelp.lib are not added to the default libs by cmake[3]. So just<br>
> removing the pragmas would break the build without adding them back<br>
> into the linking libs in cmake. Tho it would break all non-cmake based<br>
> builds (that are using LLVM components) out there that don't happen to<br>
> also link those libs. That is for versions < 3.8 non-cmake builds<br>
> worked magically thanks to the pragmas.<br>
><br>
> I have no real say in what path you should take here. Pragmas for me<br>
> would be the easiest for me, since they just magically works, tho I<br>
> appreciate the technical ugliness they present. That said if you<br>
> remove the pragmas the list of libraries needed should be documented<br>
> somewhere and probably also be returned by llvm-config.exe.<br>
><br>
> If we keep the pragmas I guess we could have does link.exe add the<br>
> libs by default as a basis for which pragmas we should add in. I can't<br>
> experiment right now but user32, kernel32 and friends seems be<br>
> included by default by link.exe or they are pragmas in the MSVC<br>
> headers that the LLVM build picks.<br>
><br>
> Thanks again for your time.<br>
<br>
</div></div>Ping?<br>
<div class="HOEnZb"><div class="h5"><br>
Cheers, Jakob.<br>
<br>
><br>
> [1] <a href="https://github.com/VoltLang/GenLLVMDLLPy/blob/master/GenLLVMDLL.py" rel="noreferrer" target="_blank">https://github.com/VoltLang/GenLLVMDLLPy/blob/master/GenLLVMDLL.py</a><br>
> [2] <a href="http://llvm.org/builds/" rel="noreferrer" target="_blank">http://llvm.org/builds/</a><br>
> [3] <a href="https://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Platform/Windows-MSVC.cmake" rel="noreferrer" target="_blank">https://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Platform/Windows-MSVC.cmake</a><br>
</div></div></blockquote></div><br></div>