Get rid of -nolink flag uses.
This commit is contained in:
committed by
alexander-gorshenev
parent
380010d1ee
commit
c93bddbba1
+3
-1
@@ -94,8 +94,10 @@ cinterop execution (see the `dumpParameters` task in `samles/csvparser/build.gra
|
|||||||
// naitve library for linking.
|
// naitve library for linking.
|
||||||
nativeLibrary project.file('path/to/native/library/')
|
nativeLibrary project.file('path/to/native/library/')
|
||||||
|
|
||||||
|
// Produce either a 'program' or a 'library' or a bare 'bitcode'.
|
||||||
|
produce 'library'
|
||||||
|
|
||||||
noStdLib() // Don't link with stdlib.
|
noStdLib() // Don't link with stdlib.
|
||||||
noLink() // Don't link, just produce a bitcode file.
|
|
||||||
enableOptimization() // Enable compiler optimizations.
|
enableOptimization() // Enable compiler optimizations.
|
||||||
|
|
||||||
// Arguments to be passed to a linker.
|
// Arguments to be passed to a linker.
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class RunInteropKonanTest extends KonanTest {
|
|||||||
|
|
||||||
void compileTest(List<String> filesToCompile, String exe) {
|
void compileTest(List<String> filesToCompile, String exe) {
|
||||||
String interopBc = exe + "-interop.bc"
|
String interopBc = exe + "-interop.bc"
|
||||||
runCompiler([interopConf.generatedSrcDir.absolutePath], interopBc, ["-nolink"])
|
runCompiler([interopConf.generatedSrcDir.absolutePath], interopBc, ['-produce', 'library'])
|
||||||
|
|
||||||
String interopStubsBc = new File(interopConf.nativeLibsDir, interop + "stubs.bc").absolutePath
|
String interopStubsBc = new File(interopConf.nativeLibsDir, interop + "stubs.bc").absolutePath
|
||||||
|
|
||||||
@@ -321,19 +321,6 @@ class RunInteropKonanTest extends KonanTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParallelizableTask
|
|
||||||
class LinkKonanTestNoStdlib extends KonanTest {
|
|
||||||
protected String lib
|
|
||||||
|
|
||||||
void compileTest(List<String> filesToCompile, String exe) {
|
|
||||||
def libDir = project.file(lib).absolutePath
|
|
||||||
def libBc = "${libDir}.bc"
|
|
||||||
|
|
||||||
runCompiler(lib, libBc, ['-nolink', '-nostdlib'])
|
|
||||||
runCompiler(filesToCompile, exe, ['-library', libBc])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParallelizableTask
|
@ParallelizableTask
|
||||||
class LinkKonanTest extends KonanTest {
|
class LinkKonanTest extends KonanTest {
|
||||||
protected String lib
|
protected String lib
|
||||||
@@ -342,7 +329,7 @@ class LinkKonanTest extends KonanTest {
|
|||||||
def libDir = project.file(lib).absolutePath
|
def libDir = project.file(lib).absolutePath
|
||||||
def libBc = "${libDir}.bc"
|
def libBc = "${libDir}.bc"
|
||||||
|
|
||||||
runCompiler(lib, libBc, ['-nolink'] + ((flags != null) ? flags :[]))
|
runCompiler(lib, libBc, ['-produce', 'library'] + ((flags != null) ? flags :[]))
|
||||||
runCompiler(filesToCompile, exe, ['-library', libBc] + ((flags != null) ? flags :[]))
|
runCompiler(filesToCompile, exe, ['-library', libBc] + ((flags != null) ? flags :[]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -24,7 +24,7 @@ fi
|
|||||||
declare -a java_args
|
declare -a java_args
|
||||||
declare -a interop_args
|
declare -a interop_args
|
||||||
|
|
||||||
OUTPUT_FILE_NAME=nativelib.kt.bc
|
OUTPUT_FILE_NAME=nativelib
|
||||||
TARGET=host
|
TARGET=host
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
@@ -96,5 +96,5 @@ $JAVACMD $JAVA_OPTS ${java_args[@]} \
|
|||||||
# Stubs may be rather big, so we may need more heap space.
|
# Stubs may be rather big, so we may need more heap space.
|
||||||
XMX_ARG=-J-Xmx3G
|
XMX_ARG=-J-Xmx3G
|
||||||
|
|
||||||
$KONAN_HOME/bin/konanc $XMX_ARG "$GENERATED_DIR" -nolink -nativelibrary "$NATIVES_DIR/$CSTUBSNAME.bc" \
|
$KONAN_HOME/bin/konanc $XMX_ARG "$GENERATED_DIR" -produce library -nativelibrary "$NATIVES_DIR/$CSTUBSNAME.bc" \
|
||||||
-o "$OUTPUT_FILE_NAME" -target "$TARGET"
|
-o "$OUTPUT_FILE_NAME" -target "$TARGET"
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ void dumpCompilationTask(Task task) {
|
|||||||
println("libraries : ${task.libraries}")
|
println("libraries : ${task.libraries}")
|
||||||
println("nativeLibraries : ${task.nativeLibraries}")
|
println("nativeLibraries : ${task.nativeLibraries}")
|
||||||
println("linkerOpts : ${task.linkerOpts}")
|
println("linkerOpts : ${task.linkerOpts}")
|
||||||
|
println("produce : ${task.produce}")
|
||||||
println("noStdLib : ${task.noStdLib}")
|
println("noStdLib : ${task.noStdLib}")
|
||||||
println("noLink : ${task.noLink}")
|
|
||||||
println("noMain : ${task.noMain}")
|
println("noMain : ${task.noMain}")
|
||||||
println("enableOptimization : ${task.enableOptimization}")
|
println("enableOptimization : ${task.enableOptimization}")
|
||||||
println("enableAssertions : ${task.enableAssertions}")
|
println("enableAssertions : ${task.enableAssertions}")
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ konanArtifacts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
build {
|
build {
|
||||||
project.ext { outputFile = "${projectDir.canonicalPath}/${file(compileKonanGitChurn.artifactPath).name}" }
|
project.ext { outputFile = "${projectDir.canonicalPath}/${file(compileKonanGitChurn.artifactPath).name}" }
|
||||||
doLast {
|
doLast {
|
||||||
@@ -36,8 +35,8 @@ void dumpCompilationTask(Task task) {
|
|||||||
println("libraries : ${task.libraries}")
|
println("libraries : ${task.libraries}")
|
||||||
println("nativeLibraries : ${task.nativeLibraries}")
|
println("nativeLibraries : ${task.nativeLibraries}")
|
||||||
println("linkerOpts : ${task.linkerOpts}")
|
println("linkerOpts : ${task.linkerOpts}")
|
||||||
|
println("produce : ${task.produce}")
|
||||||
println("noStdLib : ${task.noStdLib}")
|
println("noStdLib : ${task.noStdLib}")
|
||||||
println("noLink : ${task.noLink}")
|
|
||||||
println("noMain : ${task.noMain}")
|
println("noMain : ${task.noMain}")
|
||||||
println("enableOptimization : ${task.enableOptimization}")
|
println("enableOptimization : ${task.enableOptimization}")
|
||||||
println("enableAssertions : ${task.enableAssertions}")
|
println("enableAssertions : ${task.enableAssertions}")
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import java.io.File
|
|||||||
* nativeLibrary File("Library")
|
* nativeLibrary File("Library")
|
||||||
*
|
*
|
||||||
* noStdLib
|
* noStdLib
|
||||||
* noLink
|
* produce "library"|"program"|"bitcode"
|
||||||
* enableOptimization
|
* enableOptimization
|
||||||
*
|
*
|
||||||
* linkerOpts "linker" "args"
|
* linkerOpts "linker" "args"
|
||||||
@@ -61,6 +61,7 @@ import java.io.File
|
|||||||
* }
|
* }
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: check debug outputs
|
// TODO: check debug outputs
|
||||||
// TODO: Use +=/-= syntax for libraries and inputFiles
|
// TODO: Use +=/-= syntax for libraries and inputFiles
|
||||||
open class KonanCompilerConfig(
|
open class KonanCompilerConfig(
|
||||||
@@ -90,9 +91,9 @@ open class KonanCompilerConfig(
|
|||||||
anotherTask.target?.let { target(it) }
|
anotherTask.target?.let { target(it) }
|
||||||
anotherTask.languageVersion?.let { languageVersion(it) }
|
anotherTask.languageVersion?.let { languageVersion(it) }
|
||||||
anotherTask.apiVersion?.let { apiVersion(it) }
|
anotherTask.apiVersion?.let { apiVersion(it) }
|
||||||
|
anotherTask.produce?.let { produce(it) }
|
||||||
|
|
||||||
if (anotherTask.noStdLib) noStdLib()
|
if (anotherTask.noStdLib) noStdLib()
|
||||||
if (anotherTask.noLink) noLink()
|
|
||||||
if (anotherTask.noMain) noMain()
|
if (anotherTask.noMain) noMain()
|
||||||
if (anotherTask.enableOptimization) enableOptimization()
|
if (anotherTask.enableOptimization) enableOptimization()
|
||||||
if (anotherTask.enableAssertions) enableAssertions()
|
if (anotherTask.enableAssertions) enableAssertions()
|
||||||
@@ -174,8 +175,8 @@ open class KonanCompilerConfig(
|
|||||||
noStdLib = true
|
noStdLib = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun noLink() = with(compilationTask) {
|
fun produce(prod: String) = with(compilationTask) {
|
||||||
noLink = true
|
produce = prod
|
||||||
}
|
}
|
||||||
|
|
||||||
fun noMain() = with(compilationTask) {
|
fun noMain() = with(compilationTask) {
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ open class KonanCompileTask: DefaultTask() {
|
|||||||
outputDir = project.file("${project.konanCompilerOutputDir}/$artifactName")
|
outputDir = project.file("${project.konanCompilerOutputDir}/$artifactName")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val artifactSuffix = mapOf("program" to "kexe", "library" to "klib", "bitcode" to "bc")
|
||||||
|
|
||||||
val artifactPath: String
|
val artifactPath: String
|
||||||
get() = "${outputDir.absolutePath}/$artifactName.${ if (noLink) "bc" else "kexe" }"
|
get() = "${outputDir.absolutePath}/$artifactName.${artifactSuffix[produce]}"
|
||||||
|
|
||||||
// Other compilation parameters -------------------------------------------
|
// Other compilation parameters -------------------------------------------
|
||||||
|
|
||||||
@@ -58,13 +60,14 @@ open class KonanCompileTask: DefaultTask() {
|
|||||||
@InputFiles val libraries = mutableSetOf<FileCollection>()
|
@InputFiles val libraries = mutableSetOf<FileCollection>()
|
||||||
@InputFiles val nativeLibraries = mutableSetOf<FileCollection>()
|
@InputFiles val nativeLibraries = mutableSetOf<FileCollection>()
|
||||||
|
|
||||||
|
@Input var produce = "program"
|
||||||
|
internal set
|
||||||
|
|
||||||
@Input var linkerOpts = mutableListOf<String>()
|
@Input var linkerOpts = mutableListOf<String>()
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
@Input var noStdLib = false
|
@Input var noStdLib = false
|
||||||
internal set
|
internal set
|
||||||
@Input var noLink = false
|
|
||||||
internal set
|
|
||||||
@Input var noMain = false
|
@Input var noMain = false
|
||||||
internal set
|
internal set
|
||||||
@Input var enableOptimization = false
|
@Input var enableOptimization = false
|
||||||
@@ -89,6 +92,7 @@ open class KonanCompileTask: DefaultTask() {
|
|||||||
|
|
||||||
addFileArgs("-library", libraries)
|
addFileArgs("-library", libraries)
|
||||||
addFileArgs("-nativelibrary", nativeLibraries)
|
addFileArgs("-nativelibrary", nativeLibraries)
|
||||||
|
addArg("-produce", produce)
|
||||||
|
|
||||||
addListArg("-linkerArgs", linkerOpts)
|
addListArg("-linkerArgs", linkerOpts)
|
||||||
|
|
||||||
@@ -97,7 +101,6 @@ open class KonanCompileTask: DefaultTask() {
|
|||||||
addArgIfNotNull("-api-version", apiVersion)
|
addArgIfNotNull("-api-version", apiVersion)
|
||||||
|
|
||||||
addKey("-nostdlib", noStdLib)
|
addKey("-nostdlib", noStdLib)
|
||||||
addKey("-nolink", noLink)
|
|
||||||
addKey("-nomain", noMain)
|
addKey("-nomain", noMain)
|
||||||
addKey("-opt", enableOptimization)
|
addKey("-opt", enableOptimization)
|
||||||
addKey("-ea", enableAssertions)
|
addKey("-ea", enableAssertions)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ open class KonanInteropConfig(
|
|||||||
internal val compileStubsConfig = KonanCompilerConfig("${name}InteropStubs", project, "compile").apply {
|
internal val compileStubsConfig = KonanCompilerConfig("${name}InteropStubs", project, "compile").apply {
|
||||||
compilationTask.dependsOn(generateStubsTask)
|
compilationTask.dependsOn(generateStubsTask)
|
||||||
outputDir("${project.konanInteropCompiledStubsDir}/$name")
|
outputDir("${project.konanInteropCompiledStubsDir}/$name")
|
||||||
noLink()
|
produce("library")
|
||||||
inputFiles(project.fileTree(generateStubsTask.stubsDir).apply { builtBy(generateStubsTask) })
|
inputFiles(project.fileTree(generateStubsTask.stubsDir).apply { builtBy(generateStubsTask) })
|
||||||
}
|
}
|
||||||
val compileStubsTask = compileStubsConfig.compilationTask
|
val compileStubsTask = compileStubsConfig.compilationTask
|
||||||
|
|||||||
Reference in New Issue
Block a user