From 36386de9a2c4d9a048e3f44d8da391abc2601937 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Thu, 10 Jun 2021 15:12:32 +0700 Subject: [PATCH] [Native] Drop explicit -fPIC flag setup We don't need to explicitly set -fPIC flag everywhere because since d82109cc927d65268ddef3d446d0b71399e77eeb it is set by default for all ClangArgs users. --- kotlin-native/Interop/Indexer/build.gradle.kts | 3 --- kotlin-native/Interop/Indexer/clang.def | 4 +--- kotlin-native/Interop/Runtime/build.gradle.kts | 3 --- kotlin-native/backend.native/build.gradle | 6 ------ kotlin-native/backend.native/llvm.def | 4 ++-- .../kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt | 2 +- kotlin-native/libclangext/build.gradle.kts | 3 --- kotlin-native/llvmCoverageMappingC/build.gradle.kts | 3 --- kotlin-native/llvmDebugInfoC/build.gradle.kts | 3 --- 9 files changed, 4 insertions(+), 27 deletions(-) diff --git a/kotlin-native/Interop/Indexer/build.gradle.kts b/kotlin-native/Interop/Indexer/build.gradle.kts index 07f03a46781..2f840d06978 100644 --- a/kotlin-native/Interop/Indexer/build.gradle.kts +++ b/kotlin-native/Interop/Indexer/build.gradle.kts @@ -46,9 +46,6 @@ val libclang = val cflags = mutableListOf( "-I$llvmDir/include", "-I${project(":kotlin-native:libclangext").projectDir.absolutePath}/src/main/include", *platformManager.hostPlatform.clang.hostCompilerArgsForJni) -if (!HostManager.hostIsMingw) { - cflags += "-fPIC" -} val ldflags = mutableListOf("$llvmDir/$libclang", "-L${libclangextDir.absolutePath}", "-lclangext") diff --git a/kotlin-native/Interop/Indexer/clang.def b/kotlin-native/Interop/Indexer/clang.def index 9bbd52a7b1d..21a534e584c 100644 --- a/kotlin-native/Interop/Indexer/clang.def +++ b/kotlin-native/Interop/Indexer/clang.def @@ -4,13 +4,11 @@ headerFilter = clang-c/** compiler = clang -compilerOpts = -std=c99 -fPIC +compilerOpts = -std=c99 linkerOpts.linux = -Wl,-z,noexecstack linker = clang++ -linkerOpts = -fPIC - strictEnums = CXErrorCode CXCursorKind CXTypeKind CXDiagnosticSeverity CXLoadDiag_Error CXSaveError \ CXTUResourceUsageKind CXLinkageKind CXVisibilityKind CXLanguageKind CXCallingConv CXChildVisitResult \ CXTokenKind CXEvalResultKind CXVisitorResult CXResult CXIdxEntityKind diff --git a/kotlin-native/Interop/Runtime/build.gradle.kts b/kotlin-native/Interop/Runtime/build.gradle.kts index 516a08347ee..f6a47fc0fcf 100644 --- a/kotlin-native/Interop/Runtime/build.gradle.kts +++ b/kotlin-native/Interop/Runtime/build.gradle.kts @@ -36,9 +36,6 @@ native { val hostLibffiDir = rootProject.project(":kotlin-native").extra["${host}LibffiDir"] val cflags = mutableListOf("-I$hostLibffiDir/include", *platformManager.hostPlatform.clang.hostCompilerArgsForJni) - if (!HostManager.hostIsMingw) { - cflags += "-fPIC" - } suffixes { (".c" to ".$obj") { tool(*platformManager.hostPlatform.clang.clangC("").toTypedArray()) diff --git a/kotlin-native/backend.native/build.gradle b/kotlin-native/backend.native/build.gradle index fd7954614b9..1279659b627 100644 --- a/kotlin-native/backend.native/build.gradle +++ b/kotlin-native/backend.native/build.gradle @@ -49,17 +49,11 @@ kotlinNativeInterop { dependsOn ":kotlin-native:llvmDebugInfoC:${NativePluginKt.lib("debugInfo")}" dependsOn ":kotlin-native:llvmCoverageMappingC:${NativePluginKt.lib("coverageMapping")}" defFile 'llvm.def' - if (!project.parent.convention.plugins.platformInfo.isWindows()) - compilerOpts "-fPIC" compilerOpts "-I$llvmDir/include", "-I${rootProject.project(':kotlin-native:llvmDebugInfoC').projectDir}/src/main/include", "-I${rootProject.project(':kotlin-native:llvmCoverageMappingC').projectDir}/src/main/include" linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').buildDir}", "-L${rootProject.project(':kotlin-native:llvmCoverageMappingC').buildDir}" } files { - if (!project.project(":kotlin-native").convention.plugins.platformInfo.isWindows()) { - compilerOpts '-fPIC' - linkerOpts '-fPIC' - } linker 'clang++' linkOutputs ":kotlin-native:common:${hostName}Files" diff --git a/kotlin-native/backend.native/llvm.def b/kotlin-native/backend.native/llvm.def index 33f813845c1..4fee599269a 100644 --- a/kotlin-native/backend.native/llvm.def +++ b/kotlin-native/backend.native/llvm.def @@ -21,7 +21,7 @@ linkerOpts = -fvisibility-inlines-hidden \ -ldebugInfo -lcoverageMapping # ./llvm-config --libs analysis bitreader bitwriter core linker target coverage analysis ipo instrumentation lto objcarcopts arm aarch64 webassembly x86 mips -linkerOpts.osx = -fPIC \ +linkerOpts.osx = \ -Wl,-search_paths_first -Wl,-headerpad_max_install_names \ -lpthread -lz -lm -lcurses -Wl,-U,_futimens -Wl,-U,_LLVMDumpType \ -Wl,-exported_symbols_list,llvm.list \ @@ -41,7 +41,7 @@ linkerOpts.osx = -fPIC \ # ./llvm-config --libs analysis bitreader bitwriter core linker target coverage analysis ipo instrumentation lto arm aarch64 webassembly x86 mips -linkerOpts.linux = -fPIC \ +linkerOpts.linux = \ -Wl,-z,noexecstack \ -lrt -ldl -lpthread -lz -lm \ -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter \ diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt index d1c3feb11b0..2ac266505ea 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt @@ -92,7 +92,7 @@ open class CompileToBitcode @Inject constructor( listOfNotNull("-std=c++17", "-Werror", "-O2", "-Wall", "-Wextra", "-Wno-unused-parameter", // False positives with polymorphic functions. - "-fPIC".takeIf { !HostManager().targetByName(target).isMINGW }) + ) } return commonFlags + sanitizerFlags + languageFlags + compilerArgs } diff --git a/kotlin-native/libclangext/build.gradle.kts b/kotlin-native/libclangext/build.gradle.kts index f22ca577ddd..dc378d5e71e 100644 --- a/kotlin-native/libclangext/build.gradle.kts +++ b/kotlin-native/libclangext/build.gradle.kts @@ -31,9 +31,6 @@ native { "-Isrc/main/include", "-I${project.findProperty("llvmDir")}/include", "-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1") - if (!org.jetbrains.kotlin.konan.target.HostManager.hostIsMingw) { - cxxflags += "-fPIC" - } if (libclangextEnabled) { cxxflags += "-DLIBCLANGEXT_ENABLE=1" } diff --git a/kotlin-native/llvmCoverageMappingC/build.gradle.kts b/kotlin-native/llvmCoverageMappingC/build.gradle.kts index 25c2ecfcb2e..559f339a71a 100644 --- a/kotlin-native/llvmCoverageMappingC/build.gradle.kts +++ b/kotlin-native/llvmCoverageMappingC/build.gradle.kts @@ -45,9 +45,6 @@ native { cxxflags += "-DKONAN_MACOS=1" } } - if (!HostManager.hostIsMingw) { - cxxflags += "-fPIC" - } suffixes { (".cpp" to ".$obj") { tool(*platformManager.hostPlatform.clang.clangCXX("").toTypedArray()) diff --git a/kotlin-native/llvmDebugInfoC/build.gradle.kts b/kotlin-native/llvmDebugInfoC/build.gradle.kts index d6e6ff40894..e10ebf79a19 100644 --- a/kotlin-native/llvmDebugInfoC/build.gradle.kts +++ b/kotlin-native/llvmDebugInfoC/build.gradle.kts @@ -35,9 +35,6 @@ native { "-I${llvmDir}/include", "-I${projectDir}/src/main/include" ) - if (!HostManager.hostIsMingw) { - cxxflags += "-fPIC" - } suffixes { (".cpp" to ".$obj") { tool(*platformManager.hostPlatform.clang.clangCXX("").toTypedArray())