mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-12 19:19:53 -04:00
Fix -debug when every initial file is excluded
The debug compile unit was made from the first file of the initial package. When build tags exclude all of its files, as for the Windows-only tests/issues/test_issue_7547.odin on other targets, there is none, and `odin test -debug` crashed on an out-of-bounds index. Without `-debug` such a test builds and reports that there are no tests to run, which `tests/issues/run.sh` relies on. Fall back to the package's path for the compile unit's file.
This commit is contained in:
2 files changed
+13
-2
No files matched your search
+12
-2
@@ -3706,7 +3706,10 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
||||
gbString split_name = gb_string_make(temporary_allocator(), "");
|
||||
|
||||
LLVMBool is_optimized = build_context.optimization_level > 0;
|
||||
AstFile *init_file = m->info->init_package->files[0];
|
||||
AstFile *init_file = nullptr;
|
||||
if (m->info->init_package->files.count > 0) {
|
||||
init_file = m->info->init_package->files[0];
|
||||
}
|
||||
|
||||
if (Entity *entry_point = m->info->entry_point) {
|
||||
if (Ast *ident = entry_point->identifier.load()) {
|
||||
@@ -3716,11 +3719,18 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
||||
}
|
||||
}
|
||||
|
||||
LLVMMetadataRef init_file_metadata = lb_get_file_metadata(m, init_file);
|
||||
if (init_file_metadata == nullptr) {
|
||||
// every file of the initial package was excluded by its build tags, as can be done for `odin test`
|
||||
String path = m->info->init_package->fullpath;
|
||||
init_file_metadata = LLVMDIBuilderCreateFile(m->debug_builder, cast(char const *)path.text, path.len, "", 0);
|
||||
}
|
||||
|
||||
LLVMBool split_debug_inlining = build_context.build_mode == BuildMode_Assembly;
|
||||
LLVMBool debug_info_for_profiling = false;
|
||||
|
||||
m->debug_compile_unit = LLVMDIBuilderCreateCompileUnit(m->debug_builder, LLVMDWARFSourceLanguageC99,
|
||||
lb_get_file_metadata(m, init_file),
|
||||
init_file_metadata,
|
||||
producer, gb_string_length(producer),
|
||||
is_optimized, "", 0,
|
||||
1, split_name, gb_string_length(split_name),
|
||||
|
||||
@@ -268,6 +268,7 @@ fi
|
||||
$ODIN test ../test_lifetime_markers.odin $COMMON -o:size -lifetime-markers
|
||||
$ODIN test ../test_lifetime_markers.odin $COMMON -o:speed -lifetime-markers
|
||||
$ODIN test ../test_issue_7547.odin $COMMON
|
||||
$ODIN test ../test_issue_7547.odin $COMMON -debug
|
||||
$ODIN test ../test_issue_7490.odin $COMMON
|
||||
$ODIN test ../test_issue_7779.odin $COMMON
|
||||
$ODIN run ../test_issue_7798.odin $COMMON
|
||||
|
||||
Reference in new issue
Block a user