@@ -45,20 +45,17 @@ void main(List<String> args) async {
4545 ),
4646 );
4747 case CompileSqlite (: final sourceFile, : final defines):
48- String ? linkerScript;
49-
5048 // With Flutter on Linux (which already dynamically links SQLite through
5149 // its libgtk dependency), we run into issues where loading our SQLite
5250 // build causes internal symbols to be resolved against the already
5351 // loaded library from the system.
5452 // This is terrible and not what we ever want. A proper solution may be
5553 // to use namespaces or RTLD_DEEPBIND, but hooks don't support that yet.
56- // An alternative that seems to work is to explicitly mark public
57- // entrypoints (list generated with FFIgen) and then use linker version
58- // scripts to mark other symbols as private. We get the public symbols
59- // through dlsym, and private symbols don't seem to clash with those
60- // that have already been loaded.
54+ // An alternative that seems to work is to pass -Bsymbolic-functions to
55+ // the linker.
6156 // For the full discussion, see https://github.com/dart-lang/native/issues/2724
57+
58+ String ? linkerScript;
6259 if (input.config.code.targetOS == OS .linux) {
6360 linkerScript = input.outputDirectory.resolve ('sqlite.map' ).path;
6461
@@ -79,12 +76,16 @@ ${usedSqliteSymbols.map((symbol) => ' $symbol;').join('\n')}
7976 sources: [sourceFile],
8077 includes: [p.dirname (sourceFile)],
8178 defines: defines,
79+ buildMode: BuildMode .debug,
80+ optimizationLevel: OptimizationLevel .o1,
8281 flags: [
8382 if (input.config.code.targetOS == OS .linux) ...[
84- // This avoids issues with Flutter , see comment above.
85- '-Wl,--version-script=$ linkerScript ' ,
83+ // This avoids loading issues on Linux , see comment above.
84+ '-Wl,-Bsymbolic-functions ' ,
8685 // And since we already have a designated list of symbols to
8786 // export, we might as well strip the rest.
87+ // TODO: Port this to other targets too.
88+ '-Wl,--version-script=$linkerScript ' ,
8889 '-ffunction-sections' ,
8990 '-fdata-sections' ,
9091 '-Wl,--gc-sections' ,
0 commit comments