Update LLVM to 6.0.1 and WebAssembly target refactoring (#1788)
* wasm updates: removed binaryen, simplified morecore and launcher.js * Updated LLVM toolchain to 6.0.1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+6
-15
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.backend.konan
|
||||
import org.jetbrains.kotlin.konan.KonanExternalToolFailure
|
||||
import org.jetbrains.kotlin.konan.exec.Command
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.konan.file.createTempFile
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
|
||||
typealias BitcodeFile = String
|
||||
@@ -90,8 +89,8 @@ internal class LinkStage(val context: Context, val phaser: PhaseManager) {
|
||||
val configurables = platform.configurables as WasmConfigurables
|
||||
|
||||
val combinedBc = temporary("combined", ".bc")
|
||||
// TODO: use -only-needed for the stdlib
|
||||
hostLlvmTool("llvm-link", *bitcodeFiles.toTypedArray(), "-o", combinedBc)
|
||||
|
||||
val optFlags = (configurables.optFlags + when {
|
||||
optimize -> configurables.optOptFlags
|
||||
debug -> configurables.optDebugFlags
|
||||
@@ -99,24 +98,16 @@ internal class LinkStage(val context: Context, val phaser: PhaseManager) {
|
||||
} + llvmProfilingFlags()).toTypedArray()
|
||||
val optimizedBc = temporary("optimized", ".bc")
|
||||
hostLlvmTool("opt", combinedBc, "-o", optimizedBc, *optFlags)
|
||||
|
||||
val llcFlags = (configurables.llcFlags + when {
|
||||
optimize -> configurables.llcOptFlags
|
||||
debug -> configurables.llcDebugFlags
|
||||
else -> configurables.llcNooptFlags
|
||||
} + llvmProfilingFlags()).toTypedArray()
|
||||
val combinedS = temporary("combined", ".s")
|
||||
targetTool("llc", optimizedBc, "-o", combinedS, *llcFlags)
|
||||
|
||||
val s2wasmFlags = configurables.s2wasmFlags.toTypedArray()
|
||||
val combinedWast = temporary("combined", ".wast")
|
||||
targetTool("s2wasm", combinedS, "-o", combinedWast, *s2wasmFlags)
|
||||
|
||||
val combinedWasm = temporary("combined", ".wasm")
|
||||
val combinedSmap = temporary("combined", ".smap")
|
||||
targetTool("wasm-as", combinedWast, "-o", combinedWasm, "-g", "-s", combinedSmap)
|
||||
|
||||
return combinedWasm
|
||||
val combinedO = temporary("combined", ".o")
|
||||
hostLlvmTool("llc", optimizedBc, "-o", combinedO, *llcFlags, "-filetype=obj")
|
||||
val linkedWasm = temporary("linked", ".wasm")
|
||||
hostLlvmTool("wasm-ld", combinedO, "-o", linkedWasm, *configurables.lldFlags.toTypedArray())
|
||||
return linkedWasm
|
||||
}
|
||||
|
||||
private fun llvmLinkAndLlc(bitcodeFiles: List<BitcodeFile>): String {
|
||||
|
||||
@@ -32,6 +32,7 @@ linkerOpts.linux= -fPIC \
|
||||
-lrt -ldl -lpthread -lz -lm
|
||||
|
||||
linkerOpts.mingw = -lole32 -luuid -static-libgcc -static-libstdc++ \
|
||||
-Wl,-Bstatic -lz \
|
||||
-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive,-Bdynamic
|
||||
|
||||
# It looks like mingw port compiled without LLVM_ENABLE_DUMP
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ goto :eof
|
||||
rem libclang.dll is dynamically linked and thus requires correct PATH to be loaded.
|
||||
rem TODO: remove this hack.
|
||||
if "%KONAN_DATA_DIR%"=="" (set KONAN_DATA_DIR=%USERPROFILE%\.konan)
|
||||
set "PATH=%KONAN_DATA_DIR%\dependencies\msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64\bin;%PATH%"
|
||||
set "PATH=%KONAN_DATA_DIR%\dependencies\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1\bin;%PATH%"
|
||||
goto :eof
|
||||
|
||||
:end
|
||||
|
||||
+34
-33
@@ -31,10 +31,10 @@ downloadingAttemptIntervalMs = 3000
|
||||
homeDependencyCache = .konan/cache
|
||||
|
||||
llvmDebugOptFlags = -O1
|
||||
llvmVersion = 5.0.0
|
||||
llvmVersion = 6.0.1
|
||||
|
||||
# Mac OS X.
|
||||
llvmHome.macos_x64 = clang-llvm-5.0.0-darwin-macos
|
||||
llvmHome.macos_x64 = clang-llvm-6.0.1-darwin-macos
|
||||
targetToolchain.macos_x64 = target-toolchain-6-macos_x64
|
||||
|
||||
arch.macos_x64 = x86_64
|
||||
@@ -54,7 +54,7 @@ osVersionMin.macos_x64 = 10.11
|
||||
entrySelector.macos_x64 = -alias _Konan_main _main
|
||||
dependencies.macos_x64 = \
|
||||
libffi-3.2.1-2-darwin-macos \
|
||||
clang-llvm-5.0.0-darwin-macos
|
||||
clang-llvm-6.0.1-darwin-macos
|
||||
|
||||
target-sysroot-6-macos_x64.default = \
|
||||
remote:internal
|
||||
@@ -66,7 +66,7 @@ target-toolchain-6-macos_x64.default = \
|
||||
targetToolchain.macos_x64-ios_arm32 = target-toolchain-6-macos_x64
|
||||
dependencies.macos_x64-ios_arm32 = \
|
||||
libffi-3.2.1-2-darwin-ios \
|
||||
clang-llvm-5.0.0-darwin-macos
|
||||
clang-llvm-6.0.1-darwin-macos
|
||||
|
||||
target-sysroot-6-ios_arm32.default = \
|
||||
remote:internal
|
||||
@@ -92,7 +92,7 @@ osVersionMin.ios_arm32 = 9.0
|
||||
targetToolchain.macos_x64-ios_arm64 = target-toolchain-6-macos_x64
|
||||
dependencies.macos_x64-ios_arm64 = \
|
||||
libffi-3.2.1-2-darwin-ios \
|
||||
clang-llvm-5.0.0-darwin-macos
|
||||
clang-llvm-6.0.1-darwin-macos
|
||||
|
||||
target-sysroot-6-ios_arm64.default = \
|
||||
remote:internal
|
||||
@@ -117,7 +117,7 @@ osVersionMin.ios_arm64 = 8.0
|
||||
targetToolchain.macos_x64-ios_x64 = target-toolchain-6-macos_x64
|
||||
dependencies.macos_x64-ios_x64 = \
|
||||
libffi-3.2.1-1-darwin-ios_sim \
|
||||
clang-llvm-5.0.0-darwin-macos
|
||||
clang-llvm-6.0.1-darwin-macos
|
||||
|
||||
target-sysroot-6-ios_x64.default = \
|
||||
remote:internal
|
||||
@@ -139,7 +139,7 @@ osVersionMinFlagClang.ios_x64 = -mios-simulator-version-min
|
||||
osVersionMin.ios_x64 = 8.0
|
||||
|
||||
# Linux x86-64.
|
||||
llvmHome.linux_x64 = clang-llvm-5.0.0-linux-x86-64
|
||||
llvmHome.linux_x64 = clang-llvm-6.0.1-linux-x86-64
|
||||
gccToolchain.linux_x64 = target-gcc-toolchain-3-linux-x86-64
|
||||
targetToolchain.linux_x64 = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu
|
||||
|
||||
@@ -164,14 +164,14 @@ entrySelector.linux_x64 = --defsym main=Konan_main
|
||||
# targetSysRoot relative
|
||||
abiSpecificLibraries.linux_x64 = ../lib64 lib64 usr/lib64
|
||||
dependencies.linux_x64 = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
target-gcc-toolchain-3-linux-x86-64 \
|
||||
libffi-3.2.1-2-linux-x86-64
|
||||
|
||||
# Raspberry Pi
|
||||
targetToolchain.linux_x64-linux_arm32_hfp = target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu
|
||||
dependencies.linux_x64-linux_arm32_hfp = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
target-gcc-toolchain-3-linux-x86-64 \
|
||||
target-sysroot-1-raspberrypi \
|
||||
libffi-3.2.1-2-linux-x86-64 \
|
||||
@@ -203,7 +203,7 @@ abiSpecificLibraries.linux_arm32_hfp = \
|
||||
# MIPS
|
||||
targetToolchain.linux_x64-linux_mips32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu
|
||||
dependencies.linux_x64-linux_mips32 = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
target-gcc-toolchain-2-linux-mips \
|
||||
target-gcc-toolchain-3-linux-x86-64 \
|
||||
target-sysroot-2-mips \
|
||||
@@ -232,7 +232,7 @@ abiSpecificLibraries.linux_mips32 =
|
||||
# MIPSel
|
||||
targetToolchain.linux_x64-linux_mipsel32 = target-gcc-toolchain-2-linux-mips/x86_64-unknown-linux-gnu
|
||||
dependencies.linux_x64-linux_mipsel32 = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
target-gcc-toolchain-2-linux-mips \
|
||||
target-gcc-toolchain-3-linux-x86-64 \
|
||||
target-sysroot-2-mipsel \
|
||||
@@ -261,13 +261,13 @@ abiSpecificLibraries.linux_mipsel32 =
|
||||
targetToolchain.macos_x64-android_arm32 = target-toolchain-21-osx-android_arm32
|
||||
# TODO: split dependencies to host-dependent and host-independent parts.
|
||||
dependencies.macos_x64-android_arm32 = \
|
||||
clang-llvm-5.0.0-darwin-macos \
|
||||
clang-llvm-6.0.1-darwin-macos \
|
||||
target-sysroot-21-android_arm32 \
|
||||
target-toolchain-21-osx-android_arm32 \
|
||||
libffi-3.2.1-2-android_arm32
|
||||
targetToolchain.linux_x64-android_arm32 = target-toolchain-21-linux-android_arm32
|
||||
dependencies.linux_x64-android_arm32 = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
target-sysroot-21-android_arm32 \
|
||||
target-toolchain-21-linux-android_arm32 \
|
||||
libffi-3.2.1-2-android_arm32
|
||||
@@ -286,13 +286,13 @@ linkerKonanFlags.android_arm32 = -lm -latomic -lstdc++ -landroid
|
||||
targetToolchain.macos_x64-android_arm64 = target-toolchain-21-osx-android_arm64
|
||||
# TODO: split dependencies to host-dependent and host-independent parts.
|
||||
dependencies.macos_x64-android_arm64 = \
|
||||
clang-llvm-5.0.0-darwin-macos \
|
||||
clang-llvm-6.0.1-darwin-macos \
|
||||
target-sysroot-21-android_arm64 \
|
||||
target-toolchain-21-osx-android_arm64 \
|
||||
libffi-3.2.1-2-android_arm64
|
||||
targetToolchain.linux_x64-android_arm64 = target-toolchain-21-linux-android_arm64
|
||||
dependencies.linux_x64-android_arm64 = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
target-sysroot-21-android_arm64 \
|
||||
target-toolchain-21-linux-android_arm64 \
|
||||
libffi-3.2.1-2-android_arm64
|
||||
@@ -306,11 +306,11 @@ linkerKonanFlags.android_arm64 = -lm -latomic -lstdc++ -landroid
|
||||
linkerNoDebugFlags.android_arm64 = -Wl,-S
|
||||
|
||||
# Windows x86-64, based on mingw-w64.
|
||||
llvmHome.mingw_x64 = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
|
||||
targetToolchain.mingw_x64 = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
|
||||
llvmHome.mingw_x64 = msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1
|
||||
targetToolchain.mingw_x64 = msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1
|
||||
|
||||
quadruple.mingw_x64 = x86_64-w64-mingw32
|
||||
targetSysRoot.mingw_x64 = msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64
|
||||
targetSysRoot.mingw_x64 = msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1
|
||||
libffiDir.mingw_x64 = libffi-3.2.1-mingw-w64-x86-64
|
||||
llvmLtoFlags.mingw_x64 =
|
||||
llvmLtoOptFlags.mingw_x64 = -O3 -function-sections
|
||||
@@ -324,38 +324,39 @@ linkerKonanFlags.mingw_x64 =-static-libgcc -static-libstdc++ \
|
||||
linkerOptimizationFlags.mingw_x64 = -Wl,--gc-sections
|
||||
entrySelector.mingw_x64 = -Wl,--defsym,main=Konan_main
|
||||
dependencies.mingw_x64 = \
|
||||
msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64 \
|
||||
msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1 \
|
||||
libffi-3.2.1-mingw-w64-x86-64
|
||||
|
||||
# WebAssembly 32-bit.
|
||||
targetToolchain.macos_x64-wasm32 = target-toolchain-2-osx-wasm
|
||||
targetToolchain.macos_x64-wasm32 = target-toolchain-3-macos-wasm
|
||||
dependencies.macos_x64-wasm32 = \
|
||||
clang-llvm-5.0.0-darwin-macos \
|
||||
clang-llvm-6.0.1-darwin-macos \
|
||||
target-sysroot-2-wasm \
|
||||
target-toolchain-2-osx-wasm
|
||||
target-toolchain-3-macos-wasm
|
||||
|
||||
targetToolchain.linux_x64-wasm32 = target-toolchain-1-linux-wasm
|
||||
targetToolchain.linux_x64-wasm32 = target-toolchain-2-linux-wasm
|
||||
dependencies.linux_x64-wasm32 = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
target-sysroot-2-wasm \
|
||||
target-toolchain-1-linux-wasm
|
||||
target-toolchain-2-linux-wasm
|
||||
|
||||
targetToolchain.mingw_x64-wasm32 = target-toolchain-1-mingw-wasm
|
||||
targetToolchain.mingw_x64-wasm32 = target-toolchain-2-mingw-wasm
|
||||
dependencies.mingw_x64-wasm32 = \
|
||||
msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64 \
|
||||
msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1 \
|
||||
target-sysroot-2-wasm \
|
||||
target-toolchain-1-mingw-wasm
|
||||
target-toolchain-2-mingw-wasm
|
||||
|
||||
quadruple.wasm32 = wasm32
|
||||
quadruple.wasm32 = wasm32-unknown-unknown
|
||||
llvmLtoFlags.wasm32 =
|
||||
targetSysRoot.wasm32 = target-sysroot-2-wasm
|
||||
optFlags.wasm32 = -internalize -globaldce
|
||||
optFlags.wasm32 = -internalize -globaldce -mtriple=wasm32-unknown-unknown-wasm
|
||||
optNooptFlags.wasm32 = -O1
|
||||
optOptFlags.wasm32 = -O3
|
||||
optDebugFlags.wasm32 = -O0
|
||||
llcFlags.wasm32 =
|
||||
llcFlags.wasm32 = -mtriple=wasm32-unknown-unknown-wasm
|
||||
llcNooptFlags.wasm32 = -O1
|
||||
llcOptFlags.wasm32 = -O3
|
||||
llcDebugFlags.wasm32 = -O0
|
||||
# The stack size is in bytes.
|
||||
s2wasmFlags.wasm32 = --allocate-stack 1048576 --import-memory
|
||||
# TODO: make explicit list of external symbols
|
||||
lld.wasm32 = --allow-undefined --no-entry --global-base=0 --no-threads
|
||||
|
||||
|
||||
@@ -25,18 +25,18 @@ boardSpecificClangFlags.zephyr_stm32f4_disco = -mabi=aapcs -mthumb -mcpu=cortex-
|
||||
|
||||
targetToolchain.linux_x64-zephyr_stm32f4_disco = gcc-arm-none-eabi-7-2017-q4-major-linux/arm-none-eabi
|
||||
dependencies.linux_x64-zephyr_stm32f4_disco = \
|
||||
clang-llvm-5.0.0-linux-x86-64 \
|
||||
clang-llvm-6.0.1-linux-x86-64 \
|
||||
gcc-arm-none-eabi-7-2017-q4-major-linux \
|
||||
target-sysroot-2-wasm
|
||||
|
||||
targetToolchain.macos_x64-zephyr_stm32f4_disco = gcc-arm-none-eabi-7-2017-q4-major-mac/arm-none-eabi
|
||||
dependencies.macos_x64-zephyr_stm32f4_disco = \
|
||||
gcc-arm-none-eabi-7-2017-q4-major-mac \
|
||||
clang-llvm-5.0.0-darwin-macos \
|
||||
clang-llvm-6.0.1-darwin-macos \
|
||||
target-sysroot-2-wasm
|
||||
|
||||
targetToolchain.mingw_x64-zephyr_stm32f4_disco = gcc-arm-none-eabi-7-2017-q4-major-win32/arm-none-eabi
|
||||
dependencies.mingw_x64-zephyr_stm32f4_disco = \
|
||||
msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64 \
|
||||
msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1 \
|
||||
gcc-arm-none-eabi-7-2017-q4-major-win32 \
|
||||
target-sysroot-2-wasm
|
||||
|
||||
@@ -39,7 +39,9 @@ model {
|
||||
}
|
||||
}
|
||||
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
||||
cppCompiler.args "--std=c++11", "-g", "-fPIC", "-I${llvmDir}/include"
|
||||
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
||||
cppCompiler.args "-fPIC"
|
||||
cppCompiler.args "--std=c++11", "-g", "-I${llvmDir}/include"
|
||||
if (isEnabled) {
|
||||
cppCompiler.args '-DLIBCLANGEXT_ENABLE=1'
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ targetList.each { targetName ->
|
||||
if (!isWindows())
|
||||
compilerArgs '-fPIC'
|
||||
compilerArgs '-I' + project.file('../common/src/hash/headers')
|
||||
compilerArgs '-I' + file('src/main/cpp')
|
||||
if (rootProject.hasProperty("${targetName}LibffiDir"))
|
||||
compilerArgs '-I' + project.file(rootProject.ext.get("${targetName}LibffiDir") + "/include")
|
||||
linkerArgs project.file("../common/build/$targetName/hash.bc").path
|
||||
|
||||
@@ -14,38 +14,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var instance;
|
||||
var heap;
|
||||
var memory;
|
||||
var global_arguments;
|
||||
var globalBase = 0; // TODO: Is there any way to obtain global_base from JavaScript?
|
||||
|
||||
var konanStackTop;
|
||||
let instance;
|
||||
let heap;
|
||||
let global_arguments;
|
||||
|
||||
function isBrowser() {
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
};
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
|
||||
var runtime;
|
||||
let runtime;
|
||||
if (isBrowser()) {
|
||||
runtime = {
|
||||
print: console.log,
|
||||
stdout: '',
|
||||
write: function (message) {
|
||||
this.stdout += message;
|
||||
var lastNewlineIndex = this.stdout.lastIndexOf('\n');
|
||||
if (lastNewlineIndex == -1) return;
|
||||
this.print(this.stdout.substring(0, lastNewlineIndex));
|
||||
this.stdout = this.stdout.substring(lastNewlineIndex + 1)
|
||||
this.stdout += message;
|
||||
const lastNewlineIndex = this.stdout.lastIndexOf('\n');
|
||||
if (lastNewlineIndex == -1) return;
|
||||
this.print(this.stdout.substring(0, lastNewlineIndex));
|
||||
this.stdout = this.stdout.substring(lastNewlineIndex + 1)
|
||||
},
|
||||
flush: function () {
|
||||
this.print(this.stdout);
|
||||
},
|
||||
exit: function(status) {
|
||||
exit: function (status) {
|
||||
throw Error("Kotlin process called exit (" + status + ")");
|
||||
}
|
||||
};
|
||||
@@ -53,7 +45,8 @@ if (isBrowser()) {
|
||||
runtime = {
|
||||
write: write,
|
||||
print: print,
|
||||
flush: function() {},
|
||||
flush: function () {
|
||||
},
|
||||
exit: quit
|
||||
};
|
||||
}
|
||||
@@ -73,131 +66,110 @@ function utf8decode(s) {
|
||||
}
|
||||
|
||||
function fromString(string, pointer) {
|
||||
for (i = 0; i < string.length; i++) {
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
heap[pointer + i] = string.charCodeAt(i);
|
||||
}
|
||||
heap[pointer + string.length] = 0;
|
||||
}
|
||||
|
||||
function toString(pointer) {
|
||||
var string = '';
|
||||
for (var i = pointer; heap[i] != 0; i++) {
|
||||
let string = '';
|
||||
for (let i = pointer; heap[i] != 0; i++) {
|
||||
string += String.fromCharCode(heap[i]);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
function toUTF16String(pointer, size) {
|
||||
var string = '';
|
||||
for (var i = pointer; i < pointer + size; i+=2) {
|
||||
string += String.fromCharCode(heap[i] + heap[i+1]*256);
|
||||
let string = '';
|
||||
for (let i = pointer; i < pointer + size; i += 2) {
|
||||
string += String.fromCharCode(heap[i] + heap[i + 1] * 256);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
function twoIntsToDouble(upper, lower) {
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var ints = new Int32Array(buffer);
|
||||
var doubles = new Float64Array(buffer);
|
||||
const buffer = new ArrayBuffer(8);
|
||||
const ints = new Int32Array(buffer);
|
||||
const doubles = new Float64Array(buffer);
|
||||
ints[1] = upper;
|
||||
ints[0] = lower;
|
||||
return doubles[0];
|
||||
}
|
||||
|
||||
function doubleToTwoInts(value) {
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var ints = new Int32Array(buffer);
|
||||
var doubles = new Float64Array(buffer);
|
||||
const buffer = new ArrayBuffer(8);
|
||||
const ints = new Int32Array(buffer);
|
||||
const doubles = new Float64Array(buffer);
|
||||
doubles[0] = value;
|
||||
var twoInts = {upper: ints[1], lower: ints[0]};
|
||||
return twoInts
|
||||
return {upper: ints[1], lower: ints[0]}
|
||||
}
|
||||
|
||||
function int32ToHeap(value, pointer) {
|
||||
heap[pointer] = value & 0xff;
|
||||
heap[pointer+1] = (value & 0xff00) >>> 8;
|
||||
heap[pointer+2] = (value & 0xff0000) >>> 16;
|
||||
heap[pointer+3] = (value & 0xff000000) >>> 24;
|
||||
heap[pointer] = value & 0xff;
|
||||
heap[pointer + 1] = (value & 0xff00) >>> 8;
|
||||
heap[pointer + 2] = (value & 0xff0000) >>> 16;
|
||||
heap[pointer + 3] = (value & 0xff000000) >>> 24;
|
||||
}
|
||||
|
||||
function doubleToReturnSlot(value) {
|
||||
var twoInts = doubleToTwoInts(value);
|
||||
const twoInts = doubleToTwoInts(value);
|
||||
instance.exports.ReturnSlot_setDouble(twoInts.upper, twoInts.lower);
|
||||
}
|
||||
|
||||
function stackTop() {
|
||||
// Read the value module's `__stack_pointer` is initialized with.
|
||||
// It is the very first static in .data section.
|
||||
var addr = (globalBase == 0 ? 4 : globalBase);
|
||||
var fourBytes = heap.buffer.slice(addr, addr+4);
|
||||
return new Uint32Array(fourBytes)[0];
|
||||
}
|
||||
|
||||
var konan_dependencies = {
|
||||
let konan_dependencies = {
|
||||
env: {
|
||||
abort: function() {
|
||||
abort: function () {
|
||||
throw new Error("abort()");
|
||||
},
|
||||
// TODO: Account for file and size.
|
||||
fgets: function(str, size, file) {
|
||||
fgets: function (str, size, file) {
|
||||
// TODO: readline can't read lines without a newline.
|
||||
// Browsers cant read from console at all.
|
||||
fromString(utf8encode(readline() + '\n'), str);
|
||||
return str;
|
||||
},
|
||||
Konan_heap_upper: function() {
|
||||
return memory.buffer.byteLength;
|
||||
Konan_notify_memory_grow: function() {
|
||||
heap = new Uint8Array(instance.exports.memory.buffer);
|
||||
},
|
||||
Konan_heap_lower: function() {
|
||||
return konanStackTop;
|
||||
},
|
||||
Konan_heap_grow: function(pages) {
|
||||
// The buffer is allocated anew on calls to grow(),
|
||||
// so renew the heap array.
|
||||
var oldLength = memory.grow(pages);
|
||||
heap = new Uint8Array(konan_dependencies.env.memory.buffer);
|
||||
return oldLength;
|
||||
},
|
||||
Konan_abort: function(pointer) {
|
||||
Konan_abort: function (pointer) {
|
||||
throw new Error("Konan_abort(" + utf8decode(toString(pointer)) + ")");
|
||||
},
|
||||
Konan_exit: function(status) {
|
||||
Konan_exit: function (status) {
|
||||
runtime.exit(status);
|
||||
},
|
||||
Konan_js_arg_size: function(index) {
|
||||
Konan_js_arg_size: function (index) {
|
||||
if (index >= global_arguments.length) return -1;
|
||||
return global_arguments[index].length + 1; // + 1 for trailing zero.
|
||||
},
|
||||
Konan_js_fetch_arg: function(index, ptr) {
|
||||
var arg = utf8encode(global_arguments[index]);
|
||||
Konan_js_fetch_arg: function (index, ptr) {
|
||||
let arg = utf8encode(global_arguments[index]);
|
||||
fromString(arg, ptr);
|
||||
},
|
||||
Konan_date_now: function(pointer) {
|
||||
var now = Date.now();
|
||||
var high = Math.floor(now / 0xffffffff);
|
||||
var low = Math.floor(now % 0xffffffff);
|
||||
Konan_date_now: function (pointer) {
|
||||
let now = Date.now();
|
||||
let high = Math.floor(now / 0xffffffff);
|
||||
let low = Math.floor(now % 0xffffffff);
|
||||
int32ToHeap(low, pointer);
|
||||
int32ToHeap(high, pointer+4);
|
||||
int32ToHeap(high, pointer + 4);
|
||||
},
|
||||
stdin: 0, // This is for fgets(,,stdin) to resolve. It is ignored.
|
||||
// TODO: Account for fd and size.
|
||||
write: function(fd, str, size) {
|
||||
write: function (fd, str, size) {
|
||||
if (fd != 1 && fd != 2) throw ("write(" + fd + ", ...)");
|
||||
// TODO: There is no writeErr() in d8.
|
||||
// TODO: There is no writeErr() in d8.
|
||||
// Approximate it with write() to stdout for now.
|
||||
runtime.write(utf8decode(toString(str)));
|
||||
},
|
||||
memory: new WebAssembly.Memory({ initial: 256, maximum: 16384 })
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function linkJavaScriptLibraries() {
|
||||
konan.libraries.forEach ( function (library) {
|
||||
for (var property in library) {
|
||||
konan.libraries.forEach(function (library) {
|
||||
for (const property in library) {
|
||||
konan_dependencies.env[property] = library[property];
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function invokeModule(inst, args) {
|
||||
if (args.length < 1) print_usage();
|
||||
@@ -205,11 +177,9 @@ function invokeModule(inst, args) {
|
||||
|
||||
instance = inst;
|
||||
|
||||
memory = konan_dependencies.env.memory
|
||||
heap = new Uint8Array(konan_dependencies.env.memory.buffer);
|
||||
konanStackTop = stackTop();
|
||||
heap = new Uint8Array(instance.exports.memory.buffer);
|
||||
|
||||
var exit_status = 0;
|
||||
let exit_status = 0;
|
||||
|
||||
try {
|
||||
exit_status = instance.exports.Konan_js_main(args.length, isBrowser() ? 0 : 1);
|
||||
@@ -223,48 +193,37 @@ function invokeModule(inst, args) {
|
||||
return exit_status;
|
||||
}
|
||||
|
||||
function setupModule(module) {
|
||||
module.env = {};
|
||||
module.env.memoryBase = 0;
|
||||
module.env.tablebase = 0;
|
||||
linkJavaScriptLibraries();
|
||||
}
|
||||
|
||||
// Instantiate module in Browser in a sequence of promises.
|
||||
function instantiateAndRun(arraybuffer, args) {
|
||||
WebAssembly.compile(arraybuffer)
|
||||
.then(function(module) {
|
||||
setupModule(module);
|
||||
return WebAssembly.instantiate(module, konan_dependencies);
|
||||
}).then(function(instance) {
|
||||
return invokeModule(instance, args);
|
||||
});
|
||||
.then(module => {
|
||||
linkJavaScriptLibraries();
|
||||
return WebAssembly.instantiate(module, konan_dependencies);
|
||||
}).then(instance => invokeModule(instance, args));
|
||||
}
|
||||
|
||||
// Instantiate module in d8 synchronously.
|
||||
function instantiateAndRunSync(arraybuffer, args) {
|
||||
var module = WebAssembly.Module(arraybuffer)
|
||||
setupModule(module);
|
||||
var instance = WebAssembly.Instance(module, konan_dependencies);
|
||||
const module = new WebAssembly.Module(arraybuffer);
|
||||
linkJavaScriptLibraries();
|
||||
const instance = new WebAssembly.Instance(module, konan_dependencies);
|
||||
return invokeModule(instance, args)
|
||||
}
|
||||
|
||||
konan.moduleEntry = function (args) {
|
||||
if (isBrowser()) {
|
||||
if (!document.currentScript.hasAttribute("wasm")) {
|
||||
throw new Error('Could not find the wasm attribute pointing to the WebAssembly binary.') ;
|
||||
throw new Error('Could not find the wasm attribute pointing to the WebAssembly binary.');
|
||||
}
|
||||
var filename = document.currentScript.getAttribute("wasm");
|
||||
fetch(filename).then( function(response) {
|
||||
return response.arrayBuffer();
|
||||
}).then(function(arraybuffer) {
|
||||
instantiateAndRun(arraybuffer, [filename]);
|
||||
});
|
||||
const filename = document.currentScript.getAttribute("wasm");
|
||||
fetch(filename)
|
||||
.then(response => response.arrayBuffer())
|
||||
.then(arraybuffer => instantiateAndRun(arraybuffer, [filename]));
|
||||
} else {
|
||||
// Invoke from d8.
|
||||
var arrayBuffer = readbuffer(args[0]);
|
||||
var exitStatus = instantiateAndRunSync(arrayBuffer, args);
|
||||
const arrayBuffer = readbuffer(args[0]);
|
||||
const exitStatus = instantiateAndRunSync(arrayBuffer, args);
|
||||
quit(exitStatus);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Memory.h"
|
||||
#include "Natives.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Memory.h"
|
||||
#include "Natives.h"
|
||||
#include "KString.h"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#endif
|
||||
#endif // OMIT_BACKTRACE
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Exceptions.h"
|
||||
#include "ExecFormat.h"
|
||||
#include "Memory.h"
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -148,7 +148,7 @@ extern "C" bool AddressToSymbol(const void* address, char* resultBuffer, size_t
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "KAssert.h"
|
||||
#include "Porting.h"
|
||||
|
||||
void RuntimeAssertFailed(const char* location, const char* message) {
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Memory.h"
|
||||
#include "Natives.h"
|
||||
#include "Porting.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "City.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Memory.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <cstddef> // for offsetof
|
||||
|
||||
#include "Alloc.h"
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Atomic.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Memory.h"
|
||||
@@ -912,7 +912,7 @@ void ObjectContainer::Init(const TypeInfo* typeInfo) {
|
||||
// header->refCount_ is zero initialized by AllocContainer().
|
||||
SetHeader(GetPlace(), typeInfo);
|
||||
MEMORY_LOG("object at %p\n", GetPlace())
|
||||
OBJECT_ALLOC_EVENT(memoryState, type_info->instanceSize_, GetPlace())
|
||||
OBJECT_ALLOC_EVENT(memoryState, typeInfo->instanceSize_, GetPlace())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef RUNTIME_MEMORY_H
|
||||
#define RUNTIME_MEMORY_H
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Common.h"
|
||||
#include "TypeInfo.h"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Memory.h"
|
||||
#include "Natives.h"
|
||||
|
||||
@@ -218,7 +218,7 @@ Class Kotlin_objc_lookUpClass(const char* name) {
|
||||
|
||||
#else // KONAN_OBJC_INTEROP
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -78,7 +78,12 @@ int32_t consoleReadUtf8(void* utf8, uint32_t maxSizeBytes) {
|
||||
#ifdef KONAN_ZEPHYR
|
||||
return 0;
|
||||
#else
|
||||
char* result = ::fgets(reinterpret_cast<char*>(utf8), maxSizeBytes - 1, stdin);
|
||||
#ifdef KONAN_WASM
|
||||
FILE* file = nullptr;
|
||||
#else
|
||||
FILE* file = stdin;
|
||||
#endif
|
||||
char* result = ::fgets(reinterpret_cast<char*>(utf8), maxSizeBytes - 1, file);
|
||||
if (result == nullptr) return -1;
|
||||
int32_t length = ::strlen(result);
|
||||
// fgets reads until EOF or newline so we need to remove linefeeds.
|
||||
@@ -275,44 +280,49 @@ uint64_t getTimeMicros() {
|
||||
|
||||
#if KONAN_WASM
|
||||
|
||||
// This one is an interface to query module.env.memory.buffer.byteLength
|
||||
extern "C" unsigned long Konan_heap_upper();
|
||||
extern "C" unsigned long Konan_heap_lower();
|
||||
extern "C" unsigned long Konan_heap_grow(unsigned long);
|
||||
namespace {
|
||||
|
||||
#define MFAIL ((void*) ~(size_t)0)
|
||||
#define WASM_PAGESIZE_EXPONENT 16
|
||||
#define WASM_PAGESIZE (1u << WASM_PAGESIZE_EXPONENT)
|
||||
#define WASM_PAGEMASK ((WASM_PAGESIZE-(size_t)1))
|
||||
#define PAGE_ALIGN(value) ((value + WASM_PAGEMASK) & ~(WASM_PAGEMASK))
|
||||
#define IN_PAGES(value) (value >> WASM_PAGESIZE_EXPONENT)
|
||||
constexpr uint32_t MFAIL = ~(uint32_t)0;
|
||||
constexpr uint32_t WASM_PAGESIZE_EXPONENT = 16;
|
||||
constexpr uint32_t WASM_PAGESIZE = 1u << WASM_PAGESIZE_EXPONENT;
|
||||
constexpr uint32_t WASM_PAGEMASK = WASM_PAGESIZE-1;
|
||||
|
||||
void* moreCore(int size) {
|
||||
static int initialized = 0;
|
||||
static void* sbrk_top = MFAIL;
|
||||
static void* upperHeapLimit = MFAIL;
|
||||
uint32_t pageAlign(int32_t value) {
|
||||
return (value + WASM_PAGEMASK) & ~ (WASM_PAGEMASK);
|
||||
}
|
||||
|
||||
if (!initialized) {
|
||||
sbrk_top = (void*)PAGE_ALIGN(Konan_heap_lower());
|
||||
initialized = 1;
|
||||
uint32_t inBytes(uint32_t pageCount) {
|
||||
return pageCount << WASM_PAGESIZE_EXPONENT;
|
||||
}
|
||||
|
||||
uint32_t inPages(uint32_t value) {
|
||||
return value >> WASM_PAGESIZE_EXPONENT;
|
||||
}
|
||||
|
||||
extern "C" void Konan_notify_memory_grow();
|
||||
|
||||
uint32_t memorySize() {
|
||||
return __builtin_wasm_current_memory();
|
||||
}
|
||||
|
||||
int32_t growMemory(uint32_t delta) {
|
||||
int32_t oldLength = __builtin_wasm_grow_memory(delta);
|
||||
Konan_notify_memory_grow();
|
||||
return oldLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void* moreCore(int32_t delta) {
|
||||
uint32_t top = inBytes(memorySize());
|
||||
if (delta > 0) {
|
||||
if (growMemory(inPages(pageAlign(delta))) == 0) {
|
||||
return (void *) MFAIL;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
return sbrk_top;
|
||||
} else if (size < 0) {
|
||||
return MFAIL;
|
||||
}
|
||||
|
||||
size = PAGE_ALIGN(size);
|
||||
|
||||
void* old_sbrk_top = sbrk_top;
|
||||
long excess = (char*)sbrk_top + size - (char*)Konan_heap_upper();
|
||||
if (excess > 0) {
|
||||
Konan_heap_grow(IN_PAGES(PAGE_ALIGN(excess)));
|
||||
}
|
||||
sbrk_top = (char*)sbrk_top + size;
|
||||
|
||||
return old_sbrk_top;
|
||||
} else if (delta < 0) {
|
||||
return (void *) MFAIL;
|
||||
}
|
||||
return (void *) top;
|
||||
}
|
||||
|
||||
// dlmalloc wants to know the page size.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Porting.h"
|
||||
#include "Common.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Memory.h"
|
||||
#include "Natives.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "TypeInfo.h"
|
||||
|
||||
// If one shall use binary search when looking up methods and fields.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
|
||||
class SimpleMutex {
|
||||
private:
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#endif
|
||||
|
||||
#include "Alloc.h"
|
||||
#include "Assert.h"
|
||||
#include "KAssert.h"
|
||||
#include "Memory.h"
|
||||
#include "Runtime.h"
|
||||
#include "Types.h"
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef KONAN_WASM
|
||||
#include "Common.h"
|
||||
#endif
|
||||
|
||||
#ifdef KONAN_WASM
|
||||
RUNTIME_USED
|
||||
#endif
|
||||
double fmod(double x, double y)
|
||||
{
|
||||
union {double f; uint64_t i;} ux = {x}, uy = {y};
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef KONAN_WASM
|
||||
#include "Common.h"
|
||||
#endif
|
||||
|
||||
#ifdef KONAN_WASM
|
||||
RUNTIME_USED
|
||||
#endif
|
||||
float fmodf(float x, float y)
|
||||
{
|
||||
union {float f; uint32_t i;} ux = {x}, uy = {y};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
setlocal
|
||||
set DIR=.
|
||||
if "%KONAN_DATA_DIR%"=="" (set "KONAN_DATA_DIR=%userprofile%\.konan")
|
||||
set "PATH=..\..\dist\bin;..\..\bin;%KONAN_DATA_DIR%\dependencies\msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64\bin;%PATH%"
|
||||
set "PATH=..\..\dist\bin;..\..\bin;%KONAN_DATA_DIR%\dependencies\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1\bin;%PATH%"
|
||||
if "%TARGET%" == "" set TARGET=mingw
|
||||
rem Requires default mingw64 install path yet.
|
||||
set MINGW=\msys64\mingw64
|
||||
|
||||
@@ -51,7 +51,7 @@ konanArtifacts {
|
||||
}
|
||||
|
||||
target 'mingw', {
|
||||
linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -lSDL2 -mwindows"
|
||||
linkerOpts "$resFile -L${System.getenv("MINGW64_DIR")?:"c:/msys64/mingw64"}/lib -Wl,-Bstatic -lstdc++ -static -lSDL2 -limm32 -lole32 -loleaut32 -lversion -lwinmm -mwindows"
|
||||
dependsOn 'windowsResources'
|
||||
inputs.file resFile
|
||||
}
|
||||
@@ -62,7 +62,7 @@ task windowsResources (type: Exec) {
|
||||
def rcFile = file('Tetris.rc')
|
||||
def path = System.getenv("PATH")
|
||||
|
||||
def windresDir = "$konanUserDir/dependencies/msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64/bin"
|
||||
def windresDir = "$konanUserDir/dependencies/msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1/bin"
|
||||
|
||||
commandLine "$windresDir/windres", rcFile, '-O', 'coff', '-o', resFile
|
||||
environment 'PATH', "$windresDir;$path"
|
||||
|
||||
@@ -78,12 +78,22 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
"-I$absoluteTargetSysRoot/usr/include/c++/4.9.x",
|
||||
"-I$absoluteTargetSysRoot/usr/include/c++/4.9.x/aarch64-linux-android")
|
||||
|
||||
// By default wasm target forces `hidden` visibility which causes
|
||||
// linkage problems.
|
||||
KonanTarget.WASM32 ->
|
||||
listOf("-target", targetArg!!, "-fno-rtti", "-fno-exceptions",
|
||||
"-D_LIBCPP_ABI_VERSION=2", "-D_LIBCPP_NO_EXCEPTIONS=1",
|
||||
"-nostdinc", "-Xclang", "-nobuiltininc", "-Xclang", "-nostdsysteminc",
|
||||
"-Xclang", "-isystem$absoluteTargetSysRoot/include/libcxx", "-Xclang", "-isystem$absoluteTargetSysRoot/lib/libcxxabi/include",
|
||||
"-Xclang", "-isystem$absoluteTargetSysRoot/include/compat", "-Xclang", "-isystem$absoluteTargetSysRoot/include/libc")
|
||||
listOf("-target", targetArg!!,
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions",
|
||||
"-fvisibility=default",
|
||||
"-D_LIBCPP_ABI_VERSION=2",
|
||||
"-D_LIBCPP_NO_EXCEPTIONS=1",
|
||||
"-nostdinc",
|
||||
"-Xclang", "-nobuiltininc",
|
||||
"-Xclang", "-nostdsysteminc",
|
||||
"-Xclang", "-isystem$absoluteTargetSysRoot/include/libcxx",
|
||||
"-Xclang", "-isystem$absoluteTargetSysRoot/lib/libcxxabi/include",
|
||||
"-Xclang", "-isystem$absoluteTargetSysRoot/include/compat",
|
||||
"-Xclang", "-isystem$absoluteTargetSysRoot/include/libc")
|
||||
|
||||
is KonanTarget.ZEPHYR ->
|
||||
listOf("-target", targetArg!!,
|
||||
@@ -142,7 +152,7 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
KonanTarget.WASM32 ->
|
||||
listOf("-DKONAN_WASM=1", "-DKONAN_NO_FFI=1", "-DKONAN_NO_THREADS=1", "-DKONAN_NO_EXCEPTIONS=1",
|
||||
"-DKONAN_INTERNAL_DLMALLOC=1", "-DKONAN_INTERNAL_SNPRINTF=1",
|
||||
"-DKONAN_INTERNAL_NOW=1", "-DKONAN_NO_MEMMEM", "-DKONAN_NO_CTORS_SECTION")
|
||||
"-DKONAN_INTERNAL_NOW=1", "-DKONAN_NO_MEMMEM", "-DKONAN_NO_CTORS_SECTION=1")
|
||||
|
||||
is KonanTarget.ZEPHYR ->
|
||||
listOf( "-DKONAN_ZEPHYR=1", "-DKONAN_NO_FFI=1", "-DKONAN_NO_THREADS=1", "-DKONAN_NO_EXCEPTIONS=1",
|
||||
|
||||
@@ -76,7 +76,6 @@ interface RaspberryPiConfigurables : LinuxBasedConfigurables
|
||||
interface AndroidConfigurables : NonAppleConfigurables
|
||||
|
||||
interface WasmConfigurables : NonAppleConfigurables {
|
||||
val s2wasmFlags get() = targetList("s2wasmFlags")
|
||||
|
||||
val llcFlags get() = targetList("llcFlags")
|
||||
val llcNooptFlags get() = targetList("llcNooptFlags")
|
||||
@@ -87,6 +86,8 @@ interface WasmConfigurables : NonAppleConfigurables {
|
||||
val optNooptFlags get() = targetList("optNooptFlags")
|
||||
val optOptFlags get() = targetList("optOptFlags")
|
||||
val optDebugFlags get() = targetList("optDebugFlags")
|
||||
|
||||
val lldFlags get() = targetList("lld")
|
||||
}
|
||||
|
||||
interface ZephyrConfigurables : NonAppleConfigurables {
|
||||
|
||||
@@ -44,8 +44,6 @@ abstract class LinkerFlags(val configurables: Configurables)
|
||||
else -> error("Don't know libLTO location for this platform.")
|
||||
}
|
||||
|
||||
val libLTO = "$libLTODir/${System.mapLibraryName("LTO")}"
|
||||
|
||||
val targetLibffi = configurables.libffiDir?.let { listOf("${configurables.absoluteLibffiDir}/lib/libffi.a") }
|
||||
?: emptyList()
|
||||
|
||||
@@ -145,7 +143,6 @@ open class MacOSBasedLinker(targetProperties: AppleConfigurables)
|
||||
val dynamic = kind == LinkerOutputKind.DYNAMIC_LIBRARY
|
||||
return listOf(Command(linker).apply {
|
||||
+"-demangle"
|
||||
+listOf("-object_path_lto", "temporary.o", "-lto_library", libLTO)
|
||||
+listOf("-dynamic", "-arch", arch)
|
||||
+osVersionMinFlags
|
||||
+listOf("-syslibroot", absoluteTargetSysRoot, "-o", executable)
|
||||
@@ -250,11 +247,6 @@ open class LinuxBasedLinker(targetProperties: LinuxBasedConfigurables)
|
||||
if (!isMips) +"--hash-style=gnu" // MIPS doesn't support hash-style=gnu
|
||||
+specificLibs
|
||||
+listOf("-L$absoluteTargetSysRoot/../lib", "-L$absoluteTargetSysRoot/lib", "-L$absoluteTargetSysRoot/usr/lib")
|
||||
if (optimize) {
|
||||
+"-plugin"
|
||||
+"$llvmLib/LLVMgold.so"
|
||||
+pluginOptimizationFlags
|
||||
}
|
||||
if (optimize) +linkerOptimizationFlags
|
||||
if (!debug) +linkerNoDebugFlags
|
||||
if (dynamic) +linkerDynamicFlags
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ internal class KonanInteropRunner(project: Project, additionalJvmArgs: List<Stri
|
||||
if (HostManager.host == KonanTarget.MINGW_X64) {
|
||||
//TODO: Oh-ho-ho fix it in more convinient way.
|
||||
environment.put("PATH", DependencyProcessor.defaultDependenciesRoot.absolutePath +
|
||||
"\\msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64" +
|
||||
"\\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1" +
|
||||
"\\bin;${environment.get("PATH")}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user