WebAssembly effort (#721)
This commit is contained in:
@@ -161,7 +161,9 @@ targetList.each { target ->
|
||||
"-Djava.library.path=${project.buildDir}/nativelibs",
|
||||
"-Dfile.encoding=UTF-8"]
|
||||
|
||||
def konanArgs = ['-nopack', '-nostdlib','-ea', '-g',
|
||||
def defaultArgs = ['-nopack', '-nostdlib','-ea' ]
|
||||
if (target != "wasm32") defaultArgs += '-g'
|
||||
def konanArgs = [*defaultArgs,
|
||||
'-target', target,
|
||||
'-runtime', project(':runtime').file("build/${target}/runtime.bc"),
|
||||
'-properties', rootProject.konanPropertiesFile.canonicalPath,
|
||||
|
||||
+17
@@ -169,6 +169,21 @@ internal open class MingwPlatform(distribution: Distribution)
|
||||
override fun linkCommandSuffix() = linkerKonanFlags
|
||||
}
|
||||
|
||||
internal open class WasmPlatform(distribution: Distribution)
|
||||
: PlatformFlags(distribution.targetProperties) {
|
||||
|
||||
private val clang = "clang"
|
||||
|
||||
override val useCompilerDriverAsLinker: Boolean get() = false
|
||||
|
||||
override fun linkCommand(objectFiles: List<ObjectFile>, executable: ExecutableFile, optimize: Boolean, debug: Boolean): List<String> {
|
||||
|
||||
return mutableListOf(clang).apply{
|
||||
throw Error("Implement me!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class LinkStage(val context: Context) {
|
||||
|
||||
val config = context.config.configuration
|
||||
@@ -184,6 +199,8 @@ internal class LinkStage(val context: Context) {
|
||||
AndroidPlatform(distribution)
|
||||
KonanTarget.MINGW ->
|
||||
MingwPlatform(distribution)
|
||||
KonanTarget.WASM32 ->
|
||||
WasmPlatform(distribution)
|
||||
else ->
|
||||
error("Unexpected target platform: ${context.config.targetManager.target}")
|
||||
}
|
||||
|
||||
+7
-4
@@ -43,11 +43,14 @@ class Runtime(bitcodeFile: String) {
|
||||
val target = LLVMGetTarget(llvmModule)!!.toKString()
|
||||
|
||||
// TODO: deduce TLS model from explicit config parameter.
|
||||
val tlsMode = if (target.indexOf("android") != -1)
|
||||
LLVMThreadLocalMode.LLVMGeneralDynamicTLSModel else LLVMThreadLocalMode.LLVMLocalExecTLSModel
|
||||
|
||||
val tlsMode by lazy {
|
||||
when {
|
||||
target.indexOf("android") != -1 -> LLVMThreadLocalMode.LLVMGeneralDynamicTLSModel
|
||||
target.indexOf("wasm") != -1 -> LLVMThreadLocalMode.LLVMNotThreadLocal
|
||||
else -> LLVMThreadLocalMode.LLVMLocalExecTLSModel
|
||||
}
|
||||
}
|
||||
val dataLayout = LLVMGetDataLayout(llvmModule)!!.toKString()
|
||||
|
||||
val targetData = LLVMCreateTargetData(dataLayout)!!
|
||||
|
||||
}
|
||||
|
||||
@@ -209,3 +209,22 @@ entrySelector.mingw = -Wl,--defsym,main=Konan_main
|
||||
dependencies.mingw = \
|
||||
msys2-mingw-w64-x86_64-gcc-6.3.0-clang-llvm-3.9.1-windows-x86-64 \
|
||||
libffi-3.2.1-mingw-w64-x86-64
|
||||
|
||||
# WebAssembly 32-bit.
|
||||
targetToolchain.osx-wasm32 = target-toolchain-1-osx-wasm
|
||||
dependencies.osx-wasm32 = \
|
||||
clang-llvm-3.9.0-darwin-macos \
|
||||
target-sysroot-1-wasm \
|
||||
target-toolchain-1-osx-wasm
|
||||
|
||||
quadruple.wasm32 = wasm32
|
||||
entrySelector.wasm32 = -Wl,--defsym -Wl,main=Konan_main
|
||||
llvmLtoFlags.wasm32 = -exported-symbol=Konan_main
|
||||
targetSysRoot.wasm32 = target-sysroot-1-wasm
|
||||
clangFlags.wasm32 = -O1 -fno-rtti -fno-exceptions \
|
||||
-D_LIBCPP_ABI_VERSION=2 -DKONAN_NO_FFI=1 -DKONAN_NO_THREADS=1 -DKONAN_NO_EXCEPTIONS=1 \
|
||||
-nostdinc -Xclang -nobuiltininc -Xclang -nostdsysteminc \
|
||||
-Xclang -isystem<sysrootDir>/include/libcxx -Xclang -isystem<sysrootDir>/lib/libcxxabi/include \
|
||||
-Xclang -isystem<sysrootDir>/include/compat -Xclang -isystem<sysrootDir>/include/libc
|
||||
linkerKonanFlags.wasm32 = -lc
|
||||
linkerDebugFlags.wasm32 = -Wl,-S
|
||||
Reference in New Issue
Block a user