From 6d3c1f5d2ffef3d104bd5526b4e8e9343c9739f6 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 26 Feb 2025 02:51:42 +0100 Subject: [PATCH] Fix final? issues with -o. --- src/compiler/codegen_general.c | 10 ++++++---- src/compiler/module.c | 5 ----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/compiler/codegen_general.c b/src/compiler/codegen_general.c index 1dcf13141..916374529 100644 --- a/src/compiler/codegen_general.c +++ b/src/compiler/codegen_general.c @@ -301,12 +301,15 @@ void codegen_setup_object_names(Module *module, const char **ir_filename, const assert(compiler.build.object_file_dir); if (codegen_single_obj_output()) { + const char *res = compiler.build.output_name; + if (!res) res = compiler.build.name; + if (!res) res = result; const char *ext = get_object_extension(); - if (!str_has_suffix(result, ext)) + if (!str_has_suffix(res, ext)) { - result = str_printf("%s%s", result, ext); + res = str_printf("%s%s", result, ext); } - compiler.obj_output = *object_filename = file_append_path(compiler.build.output_dir ? compiler.build.output_dir : ".", result); + compiler.obj_output = *object_filename = file_append_path(compiler.build.output_dir ? compiler.build.output_dir : ".", res); char *dir_path = NULL; char *filename = NULL; file_get_dir_and_filename_from_full(compiler.obj_output, &filename, &dir_path); @@ -314,7 +317,6 @@ void codegen_setup_object_names(Module *module, const char **ir_filename, const { error_exit("Can't output '%s', the directory '%s' could not be found.", compiler.obj_output, dir_path); } - result = str_remove_suffix(filename, ext); } else { diff --git a/src/compiler/module.c b/src/compiler/module.c index 20210b1b3..aa24e37bc 100644 --- a/src/compiler/module.c +++ b/src/compiler/module.c @@ -43,11 +43,6 @@ void scratch_buffer_append_module(Module *module, bool is_export) const char *module_create_object_file_name(Module *module) { - if (compiler.build.single_module == SINGLE_MODULE_ON) - { - if (compiler.build.output_name) return compiler.build.output_name; - if (compiler.build.name) return compiler.build.name; - } scratch_buffer_clear(); char c; const char *name = module->name->module;