Native Libraries:

- made C methods `static` (similar to `private` in Java) to avoid that they are added (exported) to shared library symbol table
- macOS and Linux: added `-fvisibility=hidden` to compiler options to mark C methods hidden by default
This commit is contained in:
Karl Tauber
2025-01-07 19:49:04 +01:00
parent d7462bd424
commit 251198c66d
10 changed files with 72 additions and 32 deletions

View File

@@ -14,6 +14,8 @@
* limitations under the License.
*/
import java.io.FileOutputStream
plugins {
`cpp-library`
`flatlaf-cpp-library`
@@ -67,7 +69,7 @@ tasks {
compilerArgs.addAll( toolChain.map {
when( it ) {
is Gcc, is Clang -> listOf()
is Gcc, is Clang -> listOf( "-fvisibility=hidden" )
else -> emptyList()
}
} )
@@ -108,6 +110,29 @@ tasks {
into( nativesDir )
rename( "libflatlaf-natives-linux.so", libraryName )
}
/*dump
val dylib = linkedFile.asFile.get()
val dylibDir = dylib.parent
exec { commandLine( "size", dylib ) }
exec {
commandLine( "objdump",
// commands
"--archive-headers",
"--section-headers",
"--private-headers",
"--reloc",
"--dynamic-reloc",
"--syms",
// options
// "--private-header",
// files
dylib )
standardOutput = FileOutputStream( "$dylibDir/objdump.txt" )
}
exec { commandLine( "objdump", "--disassemble-all", dylib ); standardOutput = FileOutputStream( "$dylibDir/disassemble.txt" ) }
exec { commandLine( "objdump", "--full-contents", dylib ); standardOutput = FileOutputStream( "$dylibDir/full-contents.txt" ) }
dump*/
}
}
}