[cfe-dev] cindex.py & cmake builds of clang

Arnaud ALLARD DE GRANDMAISON arnaud.allarddegrandmaison at parrot.com
Tue May 8 07:13:40 PDT 2012


This is not per-se a build system problem : the build system is tweaked to avoid a collision occuring on windows (only) on some msvc intermediate files.

In my opinion, the best fix would be to change the libclang dll name only on windows. cindex.py is already 'decorating' the library name depending on the platform (platform specific suffix, ...), and we can handle here the windows specific 'decoration'. This would have the advantage that on a given platform, the 'libclang' would always have the same name, irrespective of the build system used.

The attached patch implements this, or at least is a step in the right direction.

I have attempted  to make the Windows/cygwin & Windows/msvc cmake builds give the same library name, to simplify the library finding on the windows platform. I have unfortunately no way to check it myself on Windows.

Cheers,
--
Arnaud
________________________________________
From: Manuel Klimek [klimek at google.com]
Sent: Tuesday, May 08, 2012 12:11 PM
To: David Röthlisberger
Cc: Arnaud ALLARD DE GRANDMAISON; cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] cindex.py & cmake builds of clang

On Mon, May 7, 2012 at 3:06 PM, David Röthlisberger <david at rothlis.net> wrote:
> On 7 May 2012, at 12:30, Arnaud de Grandmaison wrote:
>> When building clang using cmake, libclang is actually named
>> 'liblibclang' to avoid a file collision on Windows.
>>
>> It seems to me the cindex.py should be able to cope with both flavours,
>> as it can not know for sure how the libclang library was generated.
>> The attached patch teach cindex.py to attempt to load 'liblibclang' in
>> case the loading of 'libclang' failed.
>
> I have run into this problem as well: One cannot build libclang on Unix using cmake if one wants to use the libclang python bindings.
>
> I raised bug 12620 where I documented the history of this liblibclang nonsense:
> http://llvm.org/bugs/show_bug.cgi?id=12620
>
> A quick summary: For the sake of Windows Visual Studio users, where a library (clang.dll) cannot share the same base name as an executable (clang.exe), the cmake build system was changed to build libclang.dll, which in turn caused the Unix builds to produce liblibclang.so instead of libclang.so.
>
> In response to "Why can't we produce libclang.dll on Windows and libclang..so on Unix?", Óscar Fuentes replied "This is not a technical problem. We know how to implement any of the choices under consideration."
> http://clang-developers.42468.n3.nabble.com/Cannot-run-clang-regression-tests-with-cmake-td2961911.html#d1305831334000-246
>
> So it seems that somebody already knows how to fix this, but no further work was done.
>
> I really want the python bindings to work, so I prefer Arnaud's patch over no solution at all; but it feels so filthy to add code to work around defects in the build system, instead of fixing the build system.

The question is whether we consider that a problem with the build system:
When you refer to libclang, you usually put the "lib" into the name.
If you consider the "lib" to be part of the name, and want the
standard unix pattern -l<name> to work, it liblibclang is actually the
correct file name for the library, and the proposed patch is the
correct solution (and the configure build should probably be fixed,
too ;)

If we don't consider the name of the library to be libclang, and you
want to write -lclang, then we can easily fix the cmake file - the
right fix in that case would in my opinion be to either change the
library prefix in general, or just the name of the dll on windows,
depending on what windows devs find more reasonable.

Cheers,
/Manuel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cindex_cmake.patch
Type: text/x-patch
Size: 1535 bytes
Desc: cindex_cmake.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120508/1a8c2fbb/attachment.bin>


More information about the cfe-dev mailing list