Bug 427651

Summary: Static linking of LLVM libs breaks krita
Product: [Frameworks and Libraries] SeExpr Reporter: Antonio Rojas <arojas>
Component: GeneralAssignee: amyspark <amy>
Status: RESOLVED FIXED    
Severity: normal CC: halla
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Antonio Rojas 2020-10-13 18:35:53 UTC
SUMMARY
Krita's SeExpr links to the static LLVM libs (Interpreter, MCJIT, etc) instead of the shared libLLVM.so in [1]. This in turn makes krita itself link statically to the same libs again, which break krita at runtime due to double linking:

CommandLine Error: Option 'interpreter-print-volatile' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options 

Linking against the shared libLLVM library, like upstream seexpr does [2] fixes the problem.

[1] https://invent.kde.org/graphics/seexpr/-/blob/master/CMakeLists.txt#L192
[2] https://github.com/wdas/SeExpr/blob/main/CMakeLists.txt#L150
Comment 1 Halla Rempt 2020-10-14 07:41:24 UTC
Afaik, seexpr for Krita should be built with the following flags: -DENABLE_LLVM_BACKEND=OFF -DENABLE_SSE4=OFF -DBUILD_DOC=OFF -DBUILD_TESTS=OFF -DBUILD_UTILS=OFF -DUSE_PYTHON=OFF

so, that disables llvm and python.

Amyspark, is that correct?
Comment 2 amyspark 2020-10-14 18:04:46 UTC
This is correct. The SeExpr fork we use in Krita does not involve LLVM at all.

In the next point release, I will make it build without LLVM support by default.

In any case, I will have a look at this and make sure it works correctly.
Comment 3 amyspark 2020-10-15 01:25:53 UTC
FTR, linking against shared LLVM makes it impossible to use in systems that provide only static LLVM (like the Academy Software Foundation's Docker images, which I use for testing my changes in CI). 
I'm checking if the CMake modules provides any tooling to dynamically detect and use the shared lib if available (otherwise, I'll have to use llvm-config...)