diff --git a/src/build/build_options.c b/src/build/build_options.c
index 23aa22ec3..30ff0dbfb 100644
--- a/src/build/build_options.c
+++ b/src/build/build_options.c
@@ -147,6 +147,8 @@ static void usage(void)
OUTPUT(" --list-targets - List all architectures the compiler supports.");
OUTPUT(" --list-type-properties - List all type properties.");
OUTPUT("");
+ OUTPUT(" --print-output - Print the object files created to stdout.");
+ OUTPUT("");
OUTPUT(" --winsdk
- Set the directory for Windows system library files for cross compilation.");
OUTPUT(" --wincrt= - Windows CRT linking: none, static, dynamic (default).");
OUTPUT("");
@@ -643,6 +645,11 @@ static void parse_option(BuildOptions *options)
options->emit_asm = true;
return;
}
+ if (match_longopt("print-output"))
+ {
+ options->print_output = true;
+ return;
+ }
if (match_longopt("cc"))
{
if (at_end() || next_is_opt()) error_exit("error: --cc needs a compiler name.");
diff --git a/src/build/build_options.h b/src/build/build_options.h
index a942afb54..682c19877 100644
--- a/src/build/build_options.h
+++ b/src/build/build_options.h
@@ -272,6 +272,7 @@ typedef struct BuildOptions_
bool no_libc;
bool force_linker;
bool read_stdin;
+ bool print_output;
const char *panicfn;
const char *cc;
const char *build_dir;
@@ -357,6 +358,7 @@ typedef struct
bool benchmarking;
bool testing;
bool read_stdin;
+ bool print_output;
int build_threads;
OptimizationLevel optimization_level;
SizeOptimizationLevel size_optimization_level;
diff --git a/src/build/builder.c b/src/build/builder.c
index 0ce7fdad8..8a7721b26 100644
--- a/src/build/builder.c
+++ b/src/build/builder.c
@@ -219,6 +219,7 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
}
if (options->no_stdlib) target->no_stdlib = true;
if (options->no_libc) target->no_libc = true;
+ target->print_output = options->print_output;
target->emit_llvm = options->emit_llvm;
target->build_threads = options->build_threads;
target->emit_asm = options->emit_asm;
diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c
index 1337cf46c..28d0c73e7 100644
--- a/src/compiler/compiler.c
+++ b/src/compiler/compiler.c
@@ -413,11 +413,23 @@ void compiler_compile(void)
TaskQueueRef queue = taskqueue_create(active_target.build_threads, tasks);
taskqueue_wait_for_completion(queue);
+ if (active_target.print_output)
+ {
+ puts("# output-files-begin");
+ }
for (unsigned i = 0; i < output_file_count; i++)
{
obj_files[i] = compile_data[i].object_name;
+ if (active_target.print_output)
+ {
+ puts(obj_files[i]);
+ }
assert(obj_files[i] || !output_exe);
}
+ if (active_target.print_output)
+ {
+ puts("# output-files-end");
+ }
output_file_count += cfiles;
free(compile_data);
diff --git a/src/version.h b/src/version.h
index ffc92f0b4..a907a1242 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1 +1 @@
-#define COMPILER_VERSION "0.4.2"
\ No newline at end of file
+#define COMPILER_VERSION "0.4.3"
\ No newline at end of file