From cfc0eef43ade6389c7ae78ce99d71f1c561a7349 Mon Sep 17 00:00:00 2001 From: Vladimir Timofeev Date: Mon, 5 May 2014 11:28:55 +0400 Subject: [PATCH 1/3] Add libLLVMProfileData.a to list of libs for linking. This fix compilation for me with fresh checkout of llvm and clang. --- src/CppParser/premake4.lua | 1 + src/Parser/Parser.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/src/CppParser/premake4.lua b/src/CppParser/premake4.lua index ab42bdf8..76f56199 100644 --- a/src/CppParser/premake4.lua +++ b/src/CppParser/premake4.lua @@ -62,6 +62,7 @@ project "CppSharp.CppParser" "LLVMObjCARCOpts", "LLVMObject", "LLVMOption", + "LLVMProfileData", "LLVMScalarOpts", "LLVMSupport", "LLVMTarget", diff --git a/src/Parser/Parser.lua b/src/Parser/Parser.lua index b2008414..bd34cd42 100644 --- a/src/Parser/Parser.lua +++ b/src/Parser/Parser.lua @@ -67,6 +67,7 @@ project "CppSharp.Parser" "LLVMObjCARCOpts", "LLVMObject", "LLVMOption", + "LLVMProfileData", "LLVMScalarOpts", "LLVMSupport", "LLVMTarget", From 8d9f581a33b41249c7240550b322322f5772e2c1 Mon Sep 17 00:00:00 2001 From: Vladimir Timofeev Date: Tue, 6 May 2014 01:35:52 +0400 Subject: [PATCH 2/3] Consolidate LLVM linking --- build/LLVM.lua | 46 +++++++++++++++++++++++++++++++++++++- src/CppParser/premake4.lua | 45 +------------------------------------ src/Parser/Parser.lua | 42 ---------------------------------- 3 files changed, 46 insertions(+), 87 deletions(-) diff --git a/build/LLVM.lua b/build/LLVM.lua index 59fae3fd..eb107400 100644 --- a/build/LLVM.lua +++ b/build/LLVM.lua @@ -32,5 +32,49 @@ function SetupLLVMLibs() configuration "macosx" links { "c++", "curses", "pthread", "z" } + configuration "*" + links + { + "LLVMAnalysis", + "LLVMAsmParser", + "LLVMBitReader", + "LLVMBitWriter", + "LLVMCodeGen", + "LLVMCore", + "LLVMipa", + "LLVMipo", + "LLVMInstCombine", + "LLVMInstrumentation", + "LLVMIRReader", + "LLVMLinker", + "LLVMMC", + "LLVMMCParser", + "LLVMObjCARCOpts", + "LLVMObject", + "LLVMOption", + "LLVMProfileData", + "LLVMScalarOpts", + "LLVMSupport", + "LLVMTarget", + "LLVMTransformUtils", + "LLVMVectorize", + "LLVMX86AsmParser", + "LLVMX86AsmPrinter", + "LLVMX86Desc", + "LLVMX86Info", + "LLVMX86Utils", + "clangAnalysis", + "clangAST", + "clangBasic", + "clangCodeGen", + "clangDriver", + "clangEdit", + "clangFrontend", + "clangLex", + "clangParse", + "clangSema", + "clangSerialization", + } + configuration(c) -end \ No newline at end of file +end diff --git a/src/CppParser/premake4.lua b/src/CppParser/premake4.lua index 76f56199..df9b87dd 100644 --- a/src/CppParser/premake4.lua +++ b/src/CppParser/premake4.lua @@ -31,50 +31,7 @@ project "CppSharp.CppParser" SetupLLVMLibs() configuration "*" - - links - { - "clangAnalysis", - "clangAST", - "clangBasic", - "clangCodeGen", - "clangDriver", - "clangEdit", - "clangFrontend", - "clangLex", - "clangParse", - "clangSema", - "clangSerialization", - "LLVMAnalysis", - "LLVMAsmParser", - "LLVMBitReader", - "LLVMBitWriter", - "LLVMCodeGen", - "LLVMCore", - "LLVMipa", - "LLVMipo", - "LLVMInstCombine", - "LLVMInstrumentation", - "LLVMIRReader", - "LLVMLinker", - "LLVMMC", - "LLVMMCParser", - "LLVMObjCARCOpts", - "LLVMObject", - "LLVMOption", - "LLVMProfileData", - "LLVMScalarOpts", - "LLVMSupport", - "LLVMTarget", - "LLVMTransformUtils", - "LLVMVectorize", - "LLVMX86AsmParser", - "LLVMX86AsmPrinter", - "LLVMX86Desc", - "LLVMX86Info", - "LLVMX86Utils", - } end -include ("Bindings") \ No newline at end of file +include ("Bindings") diff --git a/src/Parser/Parser.lua b/src/Parser/Parser.lua index bd34cd42..dd6e9f08 100644 --- a/src/Parser/Parser.lua +++ b/src/Parser/Parser.lua @@ -48,45 +48,3 @@ project "CppSharp.Parser" configuration "*" - links - { - "LLVMAnalysis", - "LLVMAsmParser", - "LLVMBitReader", - "LLVMBitWriter", - "LLVMCodeGen", - "LLVMCore", - "LLVMipa", - "LLVMipo", - "LLVMInstCombine", - "LLVMInstrumentation", - "LLVMIRReader", - "LLVMLinker", - "LLVMMC", - "LLVMMCParser", - "LLVMObjCARCOpts", - "LLVMObject", - "LLVMOption", - "LLVMProfileData", - "LLVMScalarOpts", - "LLVMSupport", - "LLVMTarget", - "LLVMTransformUtils", - "LLVMVectorize", - "LLVMX86AsmParser", - "LLVMX86AsmPrinter", - "LLVMX86Desc", - "LLVMX86Info", - "LLVMX86Utils", - "clangAnalysis", - "clangAST", - "clangBasic", - "clangDriver", - "clangEdit", - "clangFrontend", - "clangLex", - "clangParse", - "clangSema", - "clangSerialization", - "clangCodeGen", - } \ No newline at end of file From cac09f703d9a9e566a3ea01e6f35ae140e46c7e4 Mon Sep 17 00:00:00 2001 From: Vladimir Timofeev Date: Tue, 6 May 2014 04:45:43 +0400 Subject: [PATCH 3/3] Link with LLVMProfileData only if it exists in libdirs. This library exists only in recent llvm, so adding it to link, breaks windows builds... Premake do not allow this, so implement StaticLinksOpt in Helpers.lua --- build/Helpers.lua | 25 +++++++++++++++++++++++++ build/LLVM.lua | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/build/Helpers.lua b/build/Helpers.lua index bf9db600..099e427d 100644 --- a/build/Helpers.lua +++ b/build/Helpers.lua @@ -94,3 +94,28 @@ function IncludeDir(dir) end end end + +function StaticLinksOpt(libnames) + local cc = configuration() + local path = table.concat(cc.configset.libdirs, ";") + + local formats + if os.is("windows") then + formats = { "%s.lib" } + else + formats = { "lib%s.a" } + end + table.insert(formats, "%s"); + + local existing_libnames = {} + for _, libname in ipairs(libnames) do + for _, fmt in ipairs(formats) do + local name = string.format(fmt, libname) + if os.pathsearch(name, path) then + table.insert(existing_libnames, libname) + end + end + end + + links(existing_libnames) +end diff --git a/build/LLVM.lua b/build/LLVM.lua index eb107400..fbdb3397 100644 --- a/build/LLVM.lua +++ b/build/LLVM.lua @@ -52,7 +52,6 @@ function SetupLLVMLibs() "LLVMObjCARCOpts", "LLVMObject", "LLVMOption", - "LLVMProfileData", "LLVMScalarOpts", "LLVMSupport", "LLVMTarget", @@ -75,6 +74,7 @@ function SetupLLVMLibs() "clangSema", "clangSerialization", } + StaticLinksOpt { "LLVMProfileData" } configuration(c) end