[llvm][update][5.0.0] llvm 5.0.0

This commit is contained in:
Vasily Levchenko
2017-12-01 09:29:38 +03:00
committed by Vasily Levchenko
parent e2d2ed5237
commit 3a6cb76dc1
15 changed files with 127 additions and 63 deletions
+4 -2
View File
@@ -22,6 +22,7 @@ apply plugin: 'kotlin'
apply plugin: org.jetbrains.kotlin.NativeInteropPlugin apply plugin: org.jetbrains.kotlin.NativeInteropPlugin
apply plugin: 'c' apply plugin: 'c'
apply plugin: 'cpp'
final Project libclangextProject = project(":libclangext") final Project libclangextProject = project(":libclangext")
final String libclangextTask = libclangextProject.path + ":build" final String libclangextTask = libclangextProject.path + ":build"
@@ -44,7 +45,7 @@ List<String> ldflags = ["$llvmDir/$libclang", "-L$libclangextDir.absolutePath",
if (libclangextIsEnabled) { if (libclangextIsEnabled) {
assert(isMac()) assert(isMac())
ldflags.addAll(['-Wl,--no-demangle', '-Wl,-search_paths_first', '-Wl,-headerpad_max_install_names']) ldflags.addAll(['-Wl,--no-demangle', '-Wl,-search_paths_first', '-Wl,-headerpad_max_install_names', '-Wl,-U,_futimens'])
List<String> llvmLibs = [ List<String> llvmLibs = [
"clangAST", "clangASTMatchers", "clangAnalysis", "clangBasic", "clangDriver", "clangEdit", "clangAST", "clangASTMatchers", "clangAnalysis", "clangBasic", "clangDriver", "clangEdit",
@@ -54,7 +55,7 @@ if (libclangextIsEnabled) {
"clangToolingCore", "clangToolingCore",
"clangTooling", "clangFormat", "LLVMTarget", "LLVMMC", "LLVMLinker", "LLVMTransformUtils", "clangTooling", "clangFormat", "LLVMTarget", "LLVMMC", "LLVMLinker", "LLVMTransformUtils",
"LLVMBitWriter", "LLVMBitReader", "LLVMAnalysis", "LLVMProfileData", "LLVMCore", "LLVMBitWriter", "LLVMBitReader", "LLVMAnalysis", "LLVMProfileData", "LLVMCore",
"LLVMSupport" "LLVMSupport", "LLVMBinaryFormat", "LLVMDemangle"
].collect { "$llvmDir/lib/lib${it}.a".toString() } ].collect { "$llvmDir/lib/lib${it}.a".toString() }
ldflags.addAll(llvmLibs) ldflags.addAll(llvmLibs)
@@ -67,6 +68,7 @@ model {
clangstubs(NativeLibrarySpec) { clangstubs(NativeLibrarySpec) {
sources { sources {
c.source.srcDir 'prebuilt/nativeInteropStubs/c' c.source.srcDir 'prebuilt/nativeInteropStubs/c'
cpp.source.srcDir 'prebuilt/nativeInteropStubs/cpp'
} }
binaries.all { binaries.all {
@@ -0,0 +1,9 @@
#ifdef __linux__
namespace llvm {
/**
* http://lists.llvm.org/pipermail/llvm-dev/2017-January/109621.html
* We can't rebuild llvm, but we can define symbol missed in llvm build.
*/
int DisableABIBreakingChecks = 1;
}
#endif
+7 -3
View File
@@ -99,13 +99,17 @@ kotlinNativeInterop {
llvm { llvm {
dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary" dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary"
defFile 'llvm.def' defFile 'llvm.def'
compilerOpts "-fPIC", "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include" if (!project.parent.convention.plugins.platformInfo.isWindows())
compilerOpts "-fPIC"
compilerOpts "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include"
linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static" linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static"
} }
hash { // TODO: copy-pasted from ':common:compileHash' hash { // TODO: copy-pasted from ':common:compileHash'
compilerOpts '-fPIC' if (!project.parent.convention.plugins.platformInfo.isWindows()) {
linkerOpts '-fPIC' compilerOpts '-fPIC'
linkerOpts '-fPIC'
}
linker 'clang++' linker 'clang++'
linkOutputs ":common:${hostName}Hash" linkOutputs ":common:${hostName}Hash"
@@ -290,8 +290,8 @@ internal class FunctionGenerationContext(val function: LLVMValueRef,
private fun callRaw(llvmFunction: LLVMValueRef, args: List<LLVMValueRef>, private fun callRaw(llvmFunction: LLVMValueRef, args: List<LLVMValueRef>,
lazyLandingpad: () -> LLVMBasicBlockRef?): LLVMValueRef { lazyLandingpad: () -> LLVMBasicBlockRef?): LLVMValueRef {
val rargs = args.toCValues() val rargs = args.toCValues()
if (LLVMIsAFunction(llvmFunction) != null /* the function declaration */ && if (LLVMIsAFunction(llvmFunction) != null /* the function declaration */ &&
(LLVMGetFunctionAttr(llvmFunction) and LLVMNoUnwindAttribute) != 0) { isFunctionNoUnwind(llvmFunction)) {
return LLVMBuildCall(builder, llvmFunction, rargs, args.size, "")!! return LLVMBuildCall(builder, llvmFunction, rargs, args.size, "")!!
} else { } else {
@@ -280,11 +280,25 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
val functionType = getFunctionType(externalFunction) val functionType = getFunctionType(externalFunction)
val function = LLVMAddFunction(llvmModule, name, functionType)!! val function = LLVMAddFunction(llvmModule, name, functionType)!!
val attributes = LLVMGetFunctionAttr(externalFunction)
LLVMAddFunctionAttr(function, attributes) copyFunctionAttributes(externalFunction, function)
return function return function
} }
private fun copyFunctionAttributes(source: LLVMValueRef, destination: LLVMValueRef) {
// TODO: consider parameter attributes
val attributeIndex = LLVMAttributeFunctionIndex
val count = LLVMGetAttributeCountAtIndex(source, attributeIndex)
memScoped {
val attributes = allocArray<LLVMAttributeRefVar>(count)
LLVMGetAttributesAtIndex(source, attributeIndex, attributes)
(0 until count).forEach {
LLVMAddAttributeAtIndex(destination, attributeIndex, attributes[it])
}
}
}
private fun importMemset() : LLVMValueRef { private fun importMemset() : LLVMValueRef {
val parameterTypes = cValuesOf(int8TypePtr, int8Type, int32Type, int32Type, int1Type) val parameterTypes = cValuesOf(int8TypePtr, int8Type, int32Type, int32Type, int1Type)
val functionType = LLVMFunctionType(LLVMVoidType(), parameterTypes, 5, 0) val functionType = LLVMFunctionType(LLVMVoidType(), parameterTypes, 5, 0)
@@ -306,7 +320,7 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
private fun externalNounwindFunction(name: String, type: LLVMTypeRef, origin: LlvmSymbolOrigin): LLVMValueRef { private fun externalNounwindFunction(name: String, type: LLVMTypeRef, origin: LlvmSymbolOrigin): LLVMValueRef {
val function = externalFunction(name, type, origin) val function = externalFunction(name, type, origin)
LLVMAddFunctionAttr(function, LLVMNoUnwindAttribute) setFunctionNoUnwind(function)
return function return function
} }
@@ -281,6 +281,28 @@ fun parseBitcodeFile(path: String): LLVMModuleRef = memScoped {
} }
} }
private val nounwindAttrKindId: Int
get() = getAttributeKindId("nounwind")
fun isFunctionNoUnwind(function: LLVMValueRef): Boolean {
val attribute = LLVMGetEnumAttributeAtIndex(function, LLVMAttributeFunctionIndex, nounwindAttrKindId)
return attribute != null
}
private fun getAttributeKindId(attributeName: String): Int {
val nounwindAttrKindId = LLVMGetEnumAttributeKindForName(attributeName, attributeName.length.signExtend())
if (nounwindAttrKindId == 0) {
throw Error("Unable to find '$attributeName' attribute kind id")
}
return nounwindAttrKindId
}
fun setFunctionNoUnwind(function: LLVMValueRef) {
val attribute = LLVMCreateEnumAttribute(LLVMGetTypeContext(function.type), nounwindAttrKindId, 0)!!
LLVMAddAttributeAtIndex(function, LLVMAttributeFunctionIndex, attribute)
}
internal fun String.mdString() = LLVMMDString(this, this.length)!! internal fun String.mdString() = LLVMMDString(this, this.length)!!
internal fun node(vararg it:LLVMValueRef) = LLVMMDNode(it.toList().toCValues(), it.size) internal fun node(vararg it:LLVMValueRef) = LLVMMDNode(it.toList().toCValues(), it.size)
+29 -30
View File
@@ -28,9 +28,9 @@ homeDependencyCache = .konan/cache
llvmDebugOptFlags = -O0 llvmDebugOptFlags = -O0
# Mac OS X. # Mac OS X.
llvmVersion.osx = 3.9.0 llvmVersion.osx = 5.0.0
llvmHome.osx = clang-llvm-3.9.0-darwin-macos llvmHome.osx = clang-llvm-5.0.0-darwin-macos
targetToolchain.osx = clang-llvm-3.9.0-darwin-macos targetToolchain.osx = clang-llvm-5.0.0-darwin-macos
arch.osx = x86_64 arch.osx = x86_64
targetSysRoot.osx = target-sysroot-1-darwin-macos targetSysRoot.osx = target-sysroot-1-darwin-macos
@@ -49,13 +49,13 @@ osVersionMin.osx = 10.11
entrySelector.osx = -alias _Konan_main _main entrySelector.osx = -alias _Konan_main _main
dependencies.osx = target-sysroot-1-darwin-macos \ dependencies.osx = target-sysroot-1-darwin-macos \
libffi-3.2.1-2-darwin-macos \ libffi-3.2.1-2-darwin-macos \
clang-llvm-3.9.0-darwin-macos clang-llvm-5.0.0-darwin-macos
# Apple iOS. # Apple iOS.
targetToolchain.osx-ios = clang-llvm-3.9.0-darwin-macos targetToolchain.osx-ios = clang-llvm-5.0.0-darwin-macos
dependencies.osx-ios = target-sysroot-1-darwin-macos \ dependencies.osx-ios = target-sysroot-1-darwin-macos \
libffi-3.2.1-2-darwin-ios \ libffi-3.2.1-2-darwin-ios \
clang-llvm-3.9.0-darwin-macos \ clang-llvm-5.0.0-darwin-macos \
target-sysroot-2-darwin-ios target-sysroot-2-darwin-ios
arch.ios = arm64 arch.ios = arm64
@@ -73,10 +73,10 @@ osVersionMinFlagClang.ios = -miphoneos-version-min
osVersionMin.ios = 8.0 osVersionMin.ios = 8.0
# Apple iOS simulator. # Apple iOS simulator.
targetToolchain.osx-ios_sim = clang-llvm-3.9.0-darwin-macos targetToolchain.osx-ios_sim = clang-llvm-5.0.0-darwin-macos
dependencies.osx-ios_sim = target-sysroot-1-darwin-macos \ dependencies.osx-ios_sim = target-sysroot-1-darwin-macos \
libffi-3.2.1-2-darwin-ios_sim \ libffi-3.2.1-2-darwin-ios_sim \
clang-llvm-3.9.0-darwin-macos \ clang-llvm-5.0.0-darwin-macos \
target-sysroot-1-darwin-ios_sim target-sysroot-1-darwin-ios_sim
arch.ios_sim = x86_64 arch.ios_sim = x86_64
@@ -94,8 +94,8 @@ osVersionMinFlagClang.ios_sim = -mios-simulator-version-min
osVersionMin.ios_sim = 8.0 osVersionMin.ios_sim = 8.0
# Linux x86-64. # Linux x86-64.
llvmVersion.linux = 3.9.0 llvmVersion.linux = 5.0.0
llvmHome.linux = clang-llvm-3.9.0-linux-x86-64 llvmHome.linux = clang-llvm-5.0.0-linux-x86-64
gccToolchain.linux = target-gcc-toolchain-3-linux-x86-64 gccToolchain.linux = target-gcc-toolchain-3-linux-x86-64
targetToolchain.linux = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu targetToolchain.linux = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu
@@ -119,14 +119,14 @@ entrySelector.linux = --defsym main=Konan_main
# targetSysRoot relative # targetSysRoot relative
abiSpecificLibraries.linux = ../lib64 lib64 usr/lib64 abiSpecificLibraries.linux = ../lib64 lib64 usr/lib64
dependencies.linux = \ dependencies.linux = \
clang-llvm-3.9.0-linux-x86-64 \ clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-3-linux-x86-64 \ target-gcc-toolchain-3-linux-x86-64 \
libffi-3.2.1-2-linux-x86-64 libffi-3.2.1-2-linux-x86-64
# Raspberry Pi # Raspberry Pi
targetToolchain.linux-raspberrypi = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu targetToolchain.linux-raspberrypi = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu
dependencies.linux-raspberrypi = \ dependencies.linux-raspberrypi = \
clang-llvm-3.9.0-linux-x86-64 \ clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-3-linux-x86-64 \ target-gcc-toolchain-3-linux-x86-64 \
target-sysroot-1-raspberrypi \ target-sysroot-1-raspberrypi \
libffi-3.2.1-2-linux-x86-64 \ libffi-3.2.1-2-linux-x86-64 \
@@ -155,7 +155,7 @@ abiSpecificLibraries.raspberrypi = \
# MIPS # MIPS
targetToolchain.linux-linux_mips32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu targetToolchain.linux-linux_mips32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu
dependencies.linux-linux_mips32 = \ dependencies.linux-linux_mips32 = \
clang-llvm-3.9.0-linux-x86-64 \ clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-2-linux-mips \ target-gcc-toolchain-2-linux-mips \
target-sysroot-2-mips \ target-sysroot-2-mips \
libffi-3.2.1-2-linux-x86-64 \ libffi-3.2.1-2-linux-x86-64 \
@@ -179,7 +179,7 @@ abiSpecificLibraries.linux_mips32 =
# MIPSel # MIPSel
targetToolchain.linux-linux_mipsel32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu targetToolchain.linux-linux_mipsel32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu
dependencies.linux-linux_mipsel32 = \ dependencies.linux-linux_mipsel32 = \
clang-llvm-3.9.0-linux-x86-64 \ clang-llvm-5.0.0-linux-x86-64 \
target-gcc-toolchain-2-linux-mips \ target-gcc-toolchain-2-linux-mips \
target-sysroot-2-mipsel \ target-sysroot-2-mipsel \
libffi-3.2.1-2-linux-x86-64 \ libffi-3.2.1-2-linux-x86-64 \
@@ -204,13 +204,13 @@ abiSpecificLibraries.linux_mipsel32 =
targetToolchain.osx-android_arm32 = target-toolchain-21-osx-android_arm32 targetToolchain.osx-android_arm32 = target-toolchain-21-osx-android_arm32
# TODO: split dependencies to host-dependent and host-independent parts. # TODO: split dependencies to host-dependent and host-independent parts.
dependencies.osx-android_arm32 = \ dependencies.osx-android_arm32 = \
clang-llvm-3.9.0-darwin-macos \ clang-llvm-5.0.0-darwin-macos \
target-sysroot-21-android_arm32 \ target-sysroot-21-android_arm32 \
target-toolchain-21-osx-android_arm32 \ target-toolchain-21-osx-android_arm32 \
libffi-3.2.1-2-android_arm32 libffi-3.2.1-2-android_arm32
targetToolchain.linux-android_arm32 = target-toolchain-21-linux-android_arm32 targetToolchain.linux-android_arm32 = target-toolchain-21-linux-android_arm32
dependencies.linux-android_arm32 = \ dependencies.linux-android_arm32 = \
clang-llvm-3.9.0-linux-x86-64 \ clang-llvm-5.0.0-linux-x86-64 \
target-sysroot-21-android_arm32 \ target-sysroot-21-android_arm32 \
target-toolchain-21-linux-android_arm32 \ target-toolchain-21-linux-android_arm32 \
libffi-3.2.1-2-android_arm32 libffi-3.2.1-2-android_arm32
@@ -229,13 +229,13 @@ linkerKonanFlags.android_arm32 = -lm -latomic -lstdc++ -landroid
targetToolchain.osx-android_arm64 = target-toolchain-21-osx-android_arm64 targetToolchain.osx-android_arm64 = target-toolchain-21-osx-android_arm64
# TODO: split dependencies to host-dependent and host-independent parts. # TODO: split dependencies to host-dependent and host-independent parts.
dependencies.osx-android_arm64 = \ dependencies.osx-android_arm64 = \
clang-llvm-3.9.0-darwin-macos \ clang-llvm-5.0.0-darwin-macos \
target-sysroot-21-android_arm64 \ target-sysroot-21-android_arm64 \
target-toolchain-21-osx-android_arm64 \ target-toolchain-21-osx-android_arm64 \
libffi-3.2.1-2-android_arm64 libffi-3.2.1-2-android_arm64
targetToolchain.linux-android_arm64 = target-toolchain-21-linux-android_arm64 targetToolchain.linux-android_arm64 = target-toolchain-21-linux-android_arm64
dependencies.linux-android_arm64 = \ dependencies.linux-android_arm64 = \
clang-llvm-3.9.0-linux-x86-64 \ clang-llvm-5.0.0-linux-x86-64 \
target-sysroot-21-android_arm64 \ target-sysroot-21-android_arm64 \
target-toolchain-21-linux-android_arm64 \ target-toolchain-21-linux-android_arm64 \
libffi-3.2.1-2-android_arm64 libffi-3.2.1-2-android_arm64
@@ -249,34 +249,33 @@ linkerKonanFlags.android_arm64 = -lm -latomic -lstdc++ -landroid
linkerDebugFlags.android_arm64 = -Wl,-S linkerDebugFlags.android_arm64 = -Wl,-S
# Windows x86-64, based on mingw-w64. # Windows x86-64, based on mingw-w64.
llvmVersion.mingw = 3.9.1 llvmVersion.mingw = 5.0.0
llvmHome.mingw = msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64 llvmHome.mingw = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
targetToolchain.mingw = msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64 targetToolchain.mingw = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
quadruple.mingw = x86_64-w64-mingw32 quadruple.mingw = x86_64-w64-mingw32
targetSysRoot.mingw = msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64 targetSysRoot.mingw = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
libffiDir.mingw = libffi-3.2.1-mingw-w64-x86-64 libffiDir.mingw = libffi-3.2.1-mingw-w64-x86-64
llvmLtoFlags.mingw = llvmLtoFlags.mingw =
llvmLtoOptFlags.mingw = -O3 -function-sections llvmLtoOptFlags.mingw = -O3 -function-sections
llvmLtoNooptFlags.mingw = -O1 llvmLtoNooptFlags.mingw = -O1
linkerDebugFlags.mingw = -Wl,-S linkerDebugFlags.mingw = -Wl,-S
linkerKonanFlags.mingw = -static-libgcc -static-libstdc++ \ linkerKonanFlags.mingw =-static-libgcc -static-libstdc++ -Xclang -flto-visibility-public-std -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic
-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic
linkerOptimizationFlags.mingw = -Wl,--gc-sections linkerOptimizationFlags.mingw = -Wl,--gc-sections
entrySelector.mingw = -Wl,--defsym,main=Konan_main entrySelector.mingw = -Wl,--defsym,main=Konan_main
dependencies.mingw = \ dependencies.mingw = \
msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64 \ msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64 \
libffi-3.2.1-mingw-w64-x86-64 libffi-3.2.1-mingw-w64-x86-64
# WebAssembly 32-bit. # WebAssembly 32-bit.
targetToolchain.osx-wasm32 = target-toolchain-1-osx-wasm targetToolchain.osx-wasm32 = target-toolchain-2-osx-wasm
dependencies.osx-wasm32 = \ dependencies.osx-wasm32 = \
clang-llvm-3.9.0-darwin-macos \ clang-llvm-5.0.0-darwin-macos \
target-sysroot-1-wasm \ target-sysroot-2-wasm \
target-toolchain-1-osx-wasm target-toolchain-2-osx-wasm
quadruple.wasm32 = wasm32 quadruple.wasm32 = wasm32
llvmLtoFlags.wasm32 = llvmLtoFlags.wasm32 =
targetSysRoot.wasm32 = target-sysroot-1-wasm targetSysRoot.wasm32 = target-sysroot-2-wasm
# The stack size is in bytes. # The stack size is in bytes.
s2wasmFlags.wasm32 = --allocate-stack 1048576 --import-memory s2wasmFlags.wasm32 = --allocate-stack 1048576 --import-memory
+14 -6
View File
@@ -3,7 +3,7 @@ headers = llvm-c/Core.h llvm-c/Target.h llvm-c/Analysis.h llvm-c/BitWriter.h \
headerFilter = llvm-c/* DebugInfoC.h headerFilter = llvm-c/* DebugInfoC.h
compilerOpts = -std=c99 -fPIC \ compilerOpts = -std=c99 \
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers \ -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers \
-pedantic -Wno-long-long -Wcovered-switch-default -Wdelete-non-virtual-dtor \ -pedantic -Wno-long-long -Wcovered-switch-default -Wdelete-non-virtual-dtor \
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
@@ -11,28 +11,36 @@ compilerOpts = -std=c99 -fPIC \
linker = clang++ linker = clang++
linkerOpts = -fPIC -fvisibility-inlines-hidden \ linkerOpts = -fvisibility-inlines-hidden \
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers \ -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers \
-pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor \ -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor \
-std=c++11 \ -std=c++11 \
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \ -DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
-ldebugInfo -lLLVMTarget -lLLVMMC -lLLVMLinker -lLLVMTransformUtils -lLLVMBitWriter \ -ldebugInfo -lLLVMTarget -lLLVMMC -lLLVMLinker -lLLVMTransformUtils -lLLVMBitWriter \
-lLLVMBitReader -lLLVMAnalysis -lLLVMProfileData -lLLVMCore -lLLVMSupport -lLLVMBitReader -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC \
-lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle
# ./llvm-config --libs analysis bitreader bitwriter core linker target # ./llvm-config --libs analysis bitreader bitwriter core linker target
linkerOpts.osx = \ linkerOpts.osx = -fPIC \
-Wl,-search_paths_first -Wl,-headerpad_max_install_names \ -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
-lpthread -lz -lm -lcurses -lpthread -lz -lm -lcurses -Wl,-U,_futimens -Wl,-U,_LLVMDumpType
linkerOpts.linux=\ linkerOpts.linux= -fPIC \
-Wl,-z,noexecstack \ -Wl,-z,noexecstack \
-lrt -ldl -lpthread -lz -lm -lrt -ldl -lpthread -lz -lm
linkerOpts.mingw = -lole32 -luuid -static-libgcc -static-libstdc++ \ linkerOpts.mingw = -lole32 -luuid -static-libgcc -static-libstdc++ \
-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic
# It looks like mingw port compiled without LLVM_ENABLE_DUMP
#Note: ld on mingw process -Wl,-U,_LLVMDumpType use different from other platform
# way, using this option cause linkage error:
# ld: -r and -shared may not be used together
excludedFunctions.mingw = LLVMDumpType
excludedFunctions = LLVMInitializeAllAsmParsers LLVMInitializeAllAsmPrinters LLVMInitializeAllDisassemblers \ excludedFunctions = LLVMInitializeAllAsmParsers LLVMInitializeAllAsmPrinters LLVMInitializeAllDisassemblers \
LLVMInitializeAllTargetInfos LLVMInitializeAllTargetMCs LLVMInitializeAllTargets LLVMInitializeNativeTarget \ LLVMInitializeAllTargetInfos LLVMInitializeAllTargetMCs LLVMInitializeAllTargets LLVMInitializeNativeTarget \
LLVMInitializeNativeAsmParser LLVMInitializeNativeAsmPrinter LLVMInitializeNativeDisassembler LLVMInitializeNativeAsmParser LLVMInitializeNativeAsmPrinter LLVMInitializeNativeDisassembler
+4 -1
View File
@@ -21,8 +21,11 @@ model {
components { components {
debugInfo(NativeLibrarySpec) { debugInfo(NativeLibrarySpec) {
sources.cpp.source.srcDirs "src/main/cpp" sources.cpp.source.srcDirs "src/main/cpp"
binaries.withType(StaticLibraryBinarySpec) { binary -> binaries.withType(StaticLibraryBinarySpec) { binary ->
cppCompiler.args "--std=c++11", "-g", "-fPIC", "-I${llvmDir}/include", "-I${projectDir}/src/main/include" if (!project.parent.convention.plugins.platformInfo.isWindows())
cppCompiler.args "-fPIC"
cppCompiler.args "--std=c++11", "-g", "-I${llvmDir}/include", "-I${projectDir}/src/main/include"
linker.args "-L${llvmDir}/lib", "-lLLVMCore", "-lLLVMSupport" linker.args "-L${llvmDir}/lib", "-lLLVMCore", "-lLLVMSupport"
} }
binaries.withType(SharedLibraryBinarySpec) { binary -> binaries.withType(SharedLibraryBinarySpec) { binary ->
+8 -10
View File
@@ -29,7 +29,7 @@
*/ */
namespace llvm { namespace llvm {
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBuilder, DIBuilderRef) //DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBuilder, DIBuilderRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DICompileUnit, DICompileUnitRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DICompileUnit, DICompileUnitRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIFile, DIFileRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIFile, DIFileRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBasicType, DIBasicTypeRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIBasicType, DIBasicTypeRef)
@@ -45,7 +45,7 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DILocalVariable, DILocalVariableRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIExpression, DIExpressionRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DIExpression, DIExpressionRef)
// from Module.cpp // from Module.cpp
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef) //DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef)
} }
/** /**
@@ -68,7 +68,8 @@ DICompileUnitRef DICreateCompilationUnit(DIBuilderRef builder, unsigned int lang
const char *file, const char* dir, const char *file, const char* dir,
const char * producer, int isOptimized, const char * producer, int isOptimized,
const char * flags, unsigned int rv) { const char * flags, unsigned int rv) {
return llvm::wrap(llvm::unwrap(builder)->createCompileUnit(lang, file, dir, producer, isOptimized, flags, rv)); llvm::DIBuilder *D = llvm::unwrap(builder);
return llvm::wrap(llvm::unwrap(builder)->createCompileUnit(lang, D->createFile(file, dir), producer, isOptimized, flags, rv));
} }
DIFileRef DICreateFile(DIBuilderRef builder, const char *filename, const char *directory) { DIFileRef DICreateFile(DIBuilderRef builder, const char *filename, const char *directory) {
@@ -76,7 +77,7 @@ DIFileRef DICreateFile(DIBuilderRef builder, const char *filename, const char *d
} }
DIBasicTypeRef DICreateBasicType(DIBuilderRef builder, const char* name, uint64_t sizeInBits, uint64_t alignment, unsigned encoding) { DIBasicTypeRef DICreateBasicType(DIBuilderRef builder, const char* name, uint64_t sizeInBits, uint64_t alignment, unsigned encoding) {
return llvm::wrap(llvm::unwrap(builder)->createBasicType(name, sizeInBits, alignment, encoding)); return llvm::wrap(llvm::unwrap(builder)->createBasicType(name, sizeInBits, encoding));
} }
DIModuleRef DICreateModule(DIBuilderRef builder, DIScopeOpaqueRef scope, DIModuleRef DICreateModule(DIBuilderRef builder, DIScopeOpaqueRef scope,
@@ -111,7 +112,7 @@ DICompositeTypeRef DICreateStructType(DIBuilderRef refBuilder,
DICompositeTypeRef refPlace) { DICompositeTypeRef refPlace) {
auto builder = llvm::unwrap(refBuilder); auto builder = llvm::unwrap(refBuilder);
if ((flags & DI_FORWARD_DECLARAION) != 0) { if ((flags & DI_FORWARD_DECLARAION) != 0) {
return llvm::wrap(builder->createStructType(llvm::unwrap(scope), name, NULL, 0, 0, 0, flags, NULL, NULL)); return llvm::wrap(builder->createStructType(llvm::unwrap(scope), name, NULL, 0, 0, 0, (llvm::DINode::DIFlags)flags, NULL, NULL));
} }
std::vector<llvm::Metadata *> typeElements; std::vector<llvm::Metadata *> typeElements;
for(int i = 0; i < elementsCount; ++i) { for(int i = 0; i < elementsCount; ++i) {
@@ -121,7 +122,7 @@ DICompositeTypeRef DICreateStructType(DIBuilderRef refBuilder,
auto composite = builder->createStructType(llvm::unwrap(scope), auto composite = builder->createStructType(llvm::unwrap(scope),
name, llvm::unwrap(file), name, llvm::unwrap(file),
lineNumber, lineNumber,
sizeInBits, alignInBits, flags, sizeInBits, alignInBits, (llvm::DINode::DIFlags)flags,
llvm::unwrap(derivedFrom), llvm::unwrap(derivedFrom),
elementsArray); elementsArray);
builder->replaceTemporary(llvm::TempDIType(llvm::unwrap(refPlace)), composite); builder->replaceTemporary(llvm::TempDIType(llvm::unwrap(refPlace)), composite);
@@ -158,7 +159,7 @@ DIDerivedTypeRef DICreateMemberType(DIBuilderRef refBuilder,
sizeInBits, sizeInBits,
alignInBits, alignInBits,
offsetInBits, offsetInBits,
flags, (llvm::DINode::DIFlags)flags,
llvm::unwrap(type))); llvm::unwrap(type)));
} }
@@ -270,8 +271,5 @@ int DISubprogramDescribesFunction(DISubprogramRef sp, LLVMValueRef fn) {
return llvm::unwrap(sp)->describes(llvm::cast<llvm::Function>(llvm::unwrap(fn))); return llvm::unwrap(sp)->describes(llvm::cast<llvm::Function>(llvm::unwrap(fn)));
} }
void DIScopeDump(DIScopeOpaqueRef scope) {
llvm::unwrap(scope)->dump();
}
} /* extern "C" */ } /* extern "C" */
+4 -2
View File
@@ -20,7 +20,9 @@
# ifdef __cplusplus # ifdef __cplusplus
extern "C" { extern "C" {
# endif # endif
typedef struct DIBuilder *DIBuilderRef;
typedef struct LLVMOpaqueDIBuilder *DIBuilderRef;
//typedef struct DIBuilder *DIBuilderRef;
typedef struct DICompileUnit *DICompileUnitRef; typedef struct DICompileUnit *DICompileUnitRef;
typedef struct DIFile *DIFileRef; typedef struct DIFile *DIFileRef;
typedef struct DIBasicType *DIBasicTypeRef; typedef struct DIBasicType *DIBasicTypeRef;
@@ -103,7 +105,7 @@ const char* LLVMBuilderGetCurrentBbName(LLVMBuilderRef builder);
const char *DIGetSubprogramLinkName(DISubprogramRef sp); const char *DIGetSubprogramLinkName(DISubprogramRef sp);
LLVMValueRef LLVMBuilderGetCurrentFunction(LLVMBuilderRef builder); LLVMValueRef LLVMBuilderGetCurrentFunction(LLVMBuilderRef builder);
int DISubprogramDescribesFunction(DISubprogramRef sp, LLVMValueRef fn); int DISubprogramDescribesFunction(DISubprogramRef sp, LLVMValueRef fn);
void DIScopeDump(DIScopeOpaqueRef scope); //void DIScopeDump(DIScopeOpaqueRef scope);
# ifdef __cplusplus # ifdef __cplusplus
} }
# endif # endif
+2
View File
@@ -25,6 +25,8 @@ targetList.each { targetName ->
dependsOn ":common:${targetName}Hash" dependsOn ":common:${targetName}Hash"
dependsOn "${targetName}Launcher" dependsOn "${targetName}Launcher"
target targetName target targetName
if (!isWindows())
compilerArgs '-fPIC'
compilerArgs '-I' + project.file('../common/src/hash/headers') compilerArgs '-I' + project.file('../common/src/hash/headers')
if (rootProject.hasProperty("${targetName}LibffiDir")) if (rootProject.hasProperty("${targetName}LibffiDir"))
compilerArgs '-I' + project.file(rootProject.ext.get("${targetName}LibffiDir") + "/include") compilerArgs '-I' + project.file(rootProject.ext.get("${targetName}LibffiDir") + "/include")
+1 -1
View File
@@ -308,7 +308,7 @@ extern "C" {
void _ZNKSt3__221__basic_string_commonILb1EE20__throw_length_errorEv(void) { void _ZNKSt3__221__basic_string_commonILb1EE20__throw_length_errorEv(void) {
Konan_abort("TODO: throw_length_error not implemented."); Konan_abort("TODO: throw_length_error not implemented.");
} }
int _ZNSt3__212__next_primeEm(unsigned long n) { int _ZNSt3__212__next_primeEj(unsigned long n) {
static unsigned long primes[] = { static unsigned long primes[] = {
11UL, 11UL,
101UL, 101UL,
@@ -54,7 +54,7 @@ class ClangTarget(val target: KonanTarget, konanProperties: KonanProperties) {
KonanTarget.MINGW -> KonanTarget.MINGW ->
listOf("-target", targetArg!!, "--sysroot=$sysRoot", listOf("-target", targetArg!!, "--sysroot=$sysRoot",
"-DUSE_GCC_UNWIND=1", "-DUSE_PE_COFF_SYMBOLS=1", "-DKONAN_WINDOWS=1") "-DUSE_GCC_UNWIND=1", "-DUSE_PE_COFF_SYMBOLS=1", "-DKONAN_WINDOWS=1", "-Xclang", "-flto-visibility-public-std")
KonanTarget.MACBOOK -> KonanTarget.MACBOOK ->
listOf("--sysroot=$sysRoot", "-mmacosx-version-min=10.11", "-DKONAN_OSX=1", listOf("--sysroot=$sysRoot", "-mmacosx-version-min=10.11", "-DKONAN_OSX=1",
@@ -82,9 +82,10 @@ internal class KonanInteropRunner(project: Project)
{ {
init { init {
if (project.host == "mingw") { if (project.host == "mingw") {
//TODO: Oh-ho-ho fix it in more convinient way.
environment.put("PATH", DependencyProcessor.defaultDependenciesRoot.absolutePath + environment.put("PATH", DependencyProcessor.defaultDependenciesRoot.absolutePath +
"\\msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64" + "\\msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64" +
"\\bin;${System.getenv("PATH")}") "\\bin;${environment.get("PATH")}")
} }
} }
} }