Skip to content

Commit e8e727d

Browse files
rokupsddobrev
authored andcommitted
Fix linking to LLVM libs on linux, when system has llvm/clang installed. (#1020)
This change prevents premake from inserting /usr/lib64 search path on linux. GCC does not need this path specified compiler automatically knows where to look for system libs. Insertion of this path causes issues system has clang/llvm libs installed. Build would link to system libraries instead of custom required by CppSharp. Also this patch revealed that linking to `pthread`, `z` and `tinfo` libraries on linux is not necessary and disabling them in LLVM build config works. Linking to these libs was removed. As you probably have guessed in the past CppSharp would throw `DllNotFoundException` due to missing symbols because it linked to system LLVM libs, not custom in-tree LLVM build.
1 parent 0805ab1 commit e8e727d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

build/LLVM.lua

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,13 @@ function SetupLLVMLibs()
100100
defines { "__STDC_CONSTANT_MACROS", "__STDC_LIMIT_MACROS" }
101101

102102
filter { "system:macosx" }
103-
links { "c++", "curses" }
104-
105-
filter { "system:macosx or system:linux" }
106-
links { "pthread", "z" }
103+
links { "c++", "curses", "pthread", "z" }
107104

108105
filter { "action:vs*" }
109106
links { "version" }
110107

111108
filter {}
112109

113-
if os.ishost("linux") and os.isfile("/usr/lib/libtinfo.so") then
114-
links { "tinfo" }
115-
end
116-
117110
if LLVMDirPerConfiguration then
118111
filter { "configurations:Debug" }
119112
libdirs { path.join(LLVMRootDirDebug, "build/lib") }

build/scripts/LLVM.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ require "../Helpers"
44

55
local llvm = path.getabsolute(basedir .. "/../deps/llvm")
66

7+
-- Prevent premake from inserting /usr/lib64 search path on linux. GCC does not need this path specified
8+
-- as compiler automatically knows where to look for system libs. Insertion of this path causes issues
9+
-- when system has clang/llvm libs installed. Build would link to system libraries instead of custom
10+
-- build required by CppSharp.
11+
if os.istarget("linux") then
12+
premake.tools.gcc.libraryDirectories['architecture']['x86_64'] = function(cfg) return {} end
13+
end
14+
715
-- If we are inside vagrant then clone and build LLVM outside the shared folder,
816
-- otherwise file I/O performance will be terrible.
917
if is_vagrant() then

0 commit comments

Comments
 (0)