This is an archive of the discontinued LLVM Phabricator instance.

[polly] Dynamic libraries are not supported on Cygwin
ClosedPublic

Authored by carlo-bramini on Jul 20 2023, 12:57 AM.

Details

Summary

Cygwin shares the same limitations as traditional Windows executables for dynamic library loading, so disable building the dynamic library on Cygwin targets.

Diff Detail

Event Timeline

carlo-bramini created this revision.Jul 20 2023, 12:57 AM
Herald added a project: Restricted Project. · View Herald Transcript
carlo-bramini requested review of this revision.Jul 20 2023, 12:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 12:57 AM
efriedma added a subscriber: efriedma.

I don't see how PIC is related to anything; can you fix the commit message to explain this is a Windows (PE/COFF) issue?

I don't see how PIC is related to anything; can you fix the commit message to explain this is a Windows (PE/COFF) issue?

Well, I configured the sources with:

cmake ../llvm-project/llvm -G Ninja -DCMAKE_BUILD_TYPE=Release -Wno-dev -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_PROJECTS="polly"

When linking the last file, which is lib/LLVMPolly.dll, the build process stops with thousands of error messages saying "undefined reference to xxx".
I found two solutions for this problem:

(1) I did the same change it has been done for WIN32 into those CMakeLists.txt files.
It won't emit errors, but lib/LLVMPolly.dll is not built anymore.
That's why it works.
I don't know why it has been done for WIN32, but perhaps this is the expected behaviour.

(2) first, I executed:

ninja -j1 -v

and I grabbed the command line that it is used for linking lib/LLVMPolly.dll.
It is interesting to notice that there are not additional libraries as dependecy on this command line, just object files.
Then, I copied and pasted that command line and I added these libraries at the bottom:

lib/libLLVMCore.dll.a lib/libLLVMSupport.dll.a lib/libLLVMAnalysis.dll.a lib/libLLVMTransformUtils.dll.a lib/libLLVMPasses.dll.a lib/libLLVMScalarOpts.dll.a lib/libLLVMPasses.dll.a lib/libLLVMInstCombine.dll.a lib/libLLVMipo.dll.a lib/libLLVMTarget.dll.a lib/libLLVMTargetParser.dll.a

By doing so, lib/LLVMPolly.dll is linked successfully.

Actually, I have choosen the fastest solution to be used as a patch, because, as it is written, this is done also on WIN32, although the second one would be prefered.
Perhaps, the choice to avoid the final linking had some reasons, but I don't know what they are or if there is a bug hidden somewhere into the cmake scripts or elsewhere, sorry.

efriedma accepted this revision.Sep 1 2023, 1:05 PM
efriedma retitled this revision from [polly] CYGWIN: fix build error about PIC code. to [polly] Dynamic libraries are not supported on Cygwin.
efriedma edited the summary of this revision. (Show Details)

I attempted to fix the commit message for you; let me know if it makes sense to you.

Otherwise LGTM; how do you want to be credited in the git "author" line?

This revision is now accepted and ready to land.Sep 1 2023, 1:06 PM

The title looks good to me.

Otherwise LGTM; how do you want to be credited in the git "author" line?

real name: Carlo Bramini
email address: carlo_bramini@users.sourceforge.net

This revision was automatically updated to reflect the committed changes.