Skip to content

Commit

Permalink
Use more deterministic module names
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Feb 25, 2025
1 parent f9d85a7 commit 5aafbc7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/llvm_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ struct lbModule {

StringMap<lbProcedure *> gen_procs; // key is the canonicalized name

std::atomic<u32> nested_type_name_guid;

Array<lbProcedure *> procedures_to_generate;
Array<Entity *> global_procedures_to_create;
Array<Entity *> global_types_to_create;
Expand Down Expand Up @@ -229,7 +227,6 @@ struct lbGenerator : LinkerData {
PtrMap<Ast *, lbProcedure *> anonymous_proc_lits;

std::atomic<u32> global_array_index;
std::atomic<u32> global_generated_index;

isize used_module_count;

Expand Down
11 changes: 9 additions & 2 deletions src/llvm_backend_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ gb_internal void lb_init_module(lbModule *m, Checker *c) {

gbString module_name = gb_string_make(heap_allocator(), "odin_package");
if (m->file) {
module_name = gb_string_append_fmt(module_name, "-%u", m->file->id+1);
if (m->pkg) {
module_name = gb_string_appendc(module_name, "-");
module_name = gb_string_append_length(module_name, m->pkg->name.text, m->pkg->name.len);
}
module_name = gb_string_appendc(module_name, "-");
String filename = filename_from_path(m->file->filename);
module_name = gb_string_append_length(module_name, filename.text, filename.len);
} else if (m->pkg) {
module_name = gb_string_appendc(module_name, "-");
module_name = gb_string_append_length(module_name, m->pkg->name.text, m->pkg->name.len);
Expand Down Expand Up @@ -2814,10 +2820,11 @@ gb_internal lbAddr lb_add_global_generated_from_procedure(lbProcedure *p, Type *
u32 index = ++p->global_generated_index;

gbString s = gb_string_make(temporary_allocator(), "ggv$");
s = gb_string_appendc(s, p->module->module_name);
s = gb_string_appendc(s, "$");
s = gb_string_append_length(s, p->name.text, p->name.len);
s = gb_string_append_fmt(s, "$%u", index);


String name = make_string(cast(u8 const *)s, gb_string_length(s));
return lb_add_global_generated_with_name(p->module, type, value, name);
}
Expand Down

0 comments on commit 5aafbc7

Please # to comment.