Get rid of -nolink flag uses.
This commit is contained in:
committed by
alexander-gorshenev
parent
380010d1ee
commit
c93bddbba1
+4
-2
@@ -94,8 +94,10 @@ cinterop execution (see the `dumpParameters` task in `samles/csvparser/build.gra
|
||||
// naitve library for linking.
|
||||
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.
|
||||
noLink() // Don't link, just produce a bitcode file.
|
||||
enableOptimization() // Enable compiler optimizations.
|
||||
|
||||
// Arguments to be passed to a linker.
|
||||
@@ -128,4 +130,4 @@ cinterop execution (see the `dumpParameters` task in `samles/csvparser/build.gra
|
||||
|
||||
link <files which will be linked with native stubs> // Additional files to link with native stubs.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ class RunInteropKonanTest extends KonanTest {
|
||||
|
||||
void compileTest(List<String> filesToCompile, String exe) {
|
||||
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
|
||||
|
||||
@@ -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
|
||||
class LinkKonanTest extends KonanTest {
|
||||
protected String lib
|
||||
@@ -342,7 +329,7 @@ class LinkKonanTest extends KonanTest {
|
||||
def libDir = project.file(lib).absolutePath
|
||||
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 :[]))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ fi
|
||||
declare -a java_args
|
||||
declare -a interop_args
|
||||
|
||||
OUTPUT_FILE_NAME=nativelib.kt.bc
|
||||
OUTPUT_FILE_NAME=nativelib
|
||||
TARGET=host
|
||||
|
||||
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.
|
||||
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"
|
||||
|
||||
@@ -32,8 +32,8 @@ void dumpCompilationTask(Task task) {
|
||||
println("libraries : ${task.libraries}")
|
||||
println("nativeLibraries : ${task.nativeLibraries}")
|
||||
println("linkerOpts : ${task.linkerOpts}")
|
||||
println("produce : ${task.produce}")
|
||||
println("noStdLib : ${task.noStdLib}")
|
||||
println("noLink : ${task.noLink}")
|
||||
println("noMain : ${task.noMain}")
|
||||
println("enableOptimization : ${task.enableOptimization}")
|
||||
println("enableAssertions : ${task.enableAssertions}")
|
||||
@@ -69,4 +69,4 @@ clean {
|
||||
doLast {
|
||||
delete outputFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ konanArtifacts {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
build {
|
||||
project.ext { outputFile = "${projectDir.canonicalPath}/${file(compileKonanGitChurn.artifactPath).name}" }
|
||||
doLast {
|
||||
@@ -36,8 +35,8 @@ void dumpCompilationTask(Task task) {
|
||||
println("libraries : ${task.libraries}")
|
||||
println("nativeLibraries : ${task.nativeLibraries}")
|
||||
println("linkerOpts : ${task.linkerOpts}")
|
||||
println("produce : ${task.produce}")
|
||||
println("noStdLib : ${task.noStdLib}")
|
||||
println("noLink : ${task.noLink}")
|
||||
println("noMain : ${task.noMain}")
|
||||
println("enableOptimization : ${task.enableOptimization}")
|
||||
println("enableAssertions : ${task.enableAssertions}")
|
||||
@@ -73,4 +72,4 @@ clean {
|
||||
doLast {
|
||||
delete outputFile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.io.File
|
||||
* nativeLibrary File("Library")
|
||||
*
|
||||
* noStdLib
|
||||
* noLink
|
||||
* produce "library"|"program"|"bitcode"
|
||||
* enableOptimization
|
||||
*
|
||||
* linkerOpts "linker" "args"
|
||||
@@ -61,6 +61,7 @@ import java.io.File
|
||||
* }
|
||||
|
||||
*/
|
||||
|
||||
// TODO: check debug outputs
|
||||
// TODO: Use +=/-= syntax for libraries and inputFiles
|
||||
open class KonanCompilerConfig(
|
||||
@@ -90,9 +91,9 @@ open class KonanCompilerConfig(
|
||||
anotherTask.target?.let { target(it) }
|
||||
anotherTask.languageVersion?.let { languageVersion(it) }
|
||||
anotherTask.apiVersion?.let { apiVersion(it) }
|
||||
anotherTask.produce?.let { produce(it) }
|
||||
|
||||
if (anotherTask.noStdLib) noStdLib()
|
||||
if (anotherTask.noLink) noLink()
|
||||
if (anotherTask.noMain) noMain()
|
||||
if (anotherTask.enableOptimization) enableOptimization()
|
||||
if (anotherTask.enableAssertions) enableAssertions()
|
||||
@@ -174,8 +175,8 @@ open class KonanCompilerConfig(
|
||||
noStdLib = true
|
||||
}
|
||||
|
||||
fun noLink() = with(compilationTask) {
|
||||
noLink = true
|
||||
fun produce(prod: String) = with(compilationTask) {
|
||||
produce = prod
|
||||
}
|
||||
|
||||
fun noMain() = with(compilationTask) {
|
||||
@@ -189,4 +190,4 @@ open class KonanCompilerConfig(
|
||||
fun enableAssertions() = with(compilationTask) {
|
||||
enableAssertions = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,10 @@ open class KonanCompileTask: DefaultTask() {
|
||||
outputDir = project.file("${project.konanCompilerOutputDir}/$artifactName")
|
||||
}
|
||||
|
||||
private val artifactSuffix = mapOf("program" to "kexe", "library" to "klib", "bitcode" to "bc")
|
||||
|
||||
val artifactPath: String
|
||||
get() = "${outputDir.absolutePath}/$artifactName.${ if (noLink) "bc" else "kexe" }"
|
||||
get() = "${outputDir.absolutePath}/$artifactName.${artifactSuffix[produce]}"
|
||||
|
||||
// Other compilation parameters -------------------------------------------
|
||||
|
||||
@@ -58,13 +60,14 @@ open class KonanCompileTask: DefaultTask() {
|
||||
@InputFiles val libraries = mutableSetOf<FileCollection>()
|
||||
@InputFiles val nativeLibraries = mutableSetOf<FileCollection>()
|
||||
|
||||
@Input var produce = "program"
|
||||
internal set
|
||||
|
||||
@Input var linkerOpts = mutableListOf<String>()
|
||||
internal set
|
||||
|
||||
@Input var noStdLib = false
|
||||
internal set
|
||||
@Input var noLink = false
|
||||
internal set
|
||||
@Input var noMain = false
|
||||
internal set
|
||||
@Input var enableOptimization = false
|
||||
@@ -89,6 +92,7 @@ open class KonanCompileTask: DefaultTask() {
|
||||
|
||||
addFileArgs("-library", libraries)
|
||||
addFileArgs("-nativelibrary", nativeLibraries)
|
||||
addArg("-produce", produce)
|
||||
|
||||
addListArg("-linkerArgs", linkerOpts)
|
||||
|
||||
@@ -97,7 +101,6 @@ open class KonanCompileTask: DefaultTask() {
|
||||
addArgIfNotNull("-api-version", apiVersion)
|
||||
|
||||
addKey("-nostdlib", noStdLib)
|
||||
addKey("-nolink", noLink)
|
||||
addKey("-nomain", noMain)
|
||||
addKey("-opt", enableOptimization)
|
||||
addKey("-ea", enableAssertions)
|
||||
|
||||
@@ -60,7 +60,7 @@ open class KonanInteropConfig(
|
||||
internal val compileStubsConfig = KonanCompilerConfig("${name}InteropStubs", project, "compile").apply {
|
||||
compilationTask.dependsOn(generateStubsTask)
|
||||
outputDir("${project.konanInteropCompiledStubsDir}/$name")
|
||||
noLink()
|
||||
produce("library")
|
||||
inputFiles(project.fileTree(generateStubsTask.stubsDir).apply { builtBy(generateStubsTask) })
|
||||
}
|
||||
val compileStubsTask = compileStubsConfig.compilationTask
|
||||
|
||||
Reference in New Issue
Block a user