Remove consecutive linking libraries

This commit is contained in:
gingerBill
2024-04-04 16:14:05 +01:00
parent 0e5a482c42
commit b979fd4c43
+13 -1
View File
@@ -143,6 +143,8 @@ gb_internal i32 linker_stage(LinkerData *gen) {
string_set_init(&min_libs_set, 64); string_set_init(&min_libs_set, 64);
defer (string_set_destroy(&min_libs_set)); defer (string_set_destroy(&min_libs_set));
String prev_lib = {};
StringSet asm_files = {}; StringSet asm_files = {};
string_set_init(&asm_files, 64); string_set_init(&asm_files, 64);
defer (string_set_destroy(&asm_files)); defer (string_set_destroy(&asm_files));
@@ -191,7 +193,10 @@ gb_internal i32 linker_stage(LinkerData *gen) {
} }
} else if (!string_set_update(&min_libs_set, lib) || } else if (!string_set_update(&min_libs_set, lib) ||
!build_context.min_link_libs) { !build_context.min_link_libs) {
lib_str = gb_string_append_fmt(lib_str, " \"%.*s\"", LIT(lib)); if (prev_lib != lib) {
lib_str = gb_string_append_fmt(lib_str, " \"%.*s\"", LIT(lib));
}
prev_lib = lib;
} }
} }
} }
@@ -317,6 +322,8 @@ gb_internal i32 linker_stage(LinkerData *gen) {
StringSet min_libs_set = {}; StringSet min_libs_set = {};
string_set_init(&min_libs_set, 64); string_set_init(&min_libs_set, 64);
defer (string_set_destroy(&min_libs_set)); defer (string_set_destroy(&min_libs_set));
String prev_lib = {};
for (Entity *e : gen->foreign_libraries) { for (Entity *e : gen->foreign_libraries) {
GB_ASSERT(e->kind == Entity_LibraryName); GB_ASSERT(e->kind == Entity_LibraryName);
@@ -388,6 +395,11 @@ gb_internal i32 linker_stage(LinkerData *gen) {
continue; continue;
} }
if (prev_lib == lib) {
continue;
}
prev_lib = lib;
// Do not add libc again, this is added later already, and omitted with // Do not add libc again, this is added later already, and omitted with
// the `-no-crt` flag, not skipping here would cause duplicate library // the `-no-crt` flag, not skipping here would cause duplicate library
// warnings when linking on darwin and might link libc silently even with `-no-crt`. // warnings when linking on darwin and might link libc silently even with `-no-crt`.