summaryrefslogtreecommitdiff
path: root/src/task_ld.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2025-01-24 08:37:42 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2025-01-24 08:37:42 +0100
commitf4221bc281e34e3171ba8bc4b1e49d1f53aaf118 (patch)
tree56a568a2ce89f454fdae6a201cf938cde452bc9b /src/task_ld.cc
parentd286c9b4b5c1acb9f6b9f9b382c37e7ed6757cd1 (diff)
Delete target file if generating tool fails, ensuring no half written/corrupted files are left on disk.
Diffstat (limited to 'src/task_ld.cc')
-rw-r--r--src/task_ld.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/task_ld.cc b/src/task_ld.cc
index d719ce7..69c3a8a 100644
--- a/src/task_ld.cc
+++ b/src/task_ld.cc
@@ -129,7 +129,13 @@ int TaskLD::runInner()
auto tool = compiler();
const auto& c = ctor::get_configuration();
- return execute(settings, tool, args, c.env, is_self);
+ auto res = execute(settings, tool, args, c.env, is_self);
+ if(res != 0)
+ {
+ std::filesystem::remove(targetFile());
+ }
+
+ return res;
}
int TaskLD::clean()