From 8f2c84e3323ebfbb40b62dfb02c9f57d0bb40989 Mon Sep 17 00:00:00 2001 From: harrand Date: Thu, 18 Apr 2024 21:54:22 +0100 Subject: [PATCH] [cpp] on successful link, remove intermediate object files generated during codegen --- cpp/src/link.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpp/src/link.cpp b/cpp/src/link.cpp index a665d1f..cf57481 100644 --- a/cpp/src/link.cpp +++ b/cpp/src/link.cpp @@ -77,6 +77,14 @@ namespace link #endif } + void post_link(std::vector object_files) + { + for(auto file : object_files) + { + std::filesystem::remove(file); + } + } + void executable(std::vector object_files, std::filesystem::path output_path, std::string output_name, std::string linker) { if(linker.empty()) @@ -106,6 +114,7 @@ namespace link int ret = std::system(cmd.c_str()); diag::assert_that(ret == 0, "detected that linker failed. unlucky, dickface!"); + post_link(object_files); } void library(std::vector object_files, std::filesystem::path output_path, std::string output_name, std::string linker) @@ -140,5 +149,6 @@ namespace link int ret = std::system(cmd.c_str()); diag::assert_that(ret == 0, "detected that archiver failed. unlucky, dickface!"); + post_link(object_files); } } \ No newline at end of file