gold-plugin: delete the output file for OT_DISABLE
authorMichael Kuperstein <michael.m.kuperstein@intel.com>
Thu, 12 Feb 2015 18:21:50 +0000 (18:21 +0000)
committerMichael Kuperstein <michael.m.kuperstein@intel.com>
Thu, 12 Feb 2015 18:21:50 +0000 (18:21 +0000)
bfd creates the output file early, so calling exit(0) is not enough, the file needs to be explicitly deleted.

Patch by: H.J. Lu <hjl.tools@gmail.com>

llvm-svn: 228946

llvm/tools/gold/gold-plugin.cpp

index dd6d47f..b1a28c5 100644 (file)
@@ -869,8 +869,13 @@ static ld_plugin_status all_symbols_read_hook(void) {
   llvm_shutdown();
 
   if (options::TheOutputType == options::OT_BC_ONLY ||
-      options::TheOutputType == options::OT_DISABLE)
+      options::TheOutputType == options::OT_DISABLE) {
+    if (options::TheOutputType == options::OT_DISABLE)
+      // Remove the output file here since ld.bfd creates the output file
+      // early.
+      sys::fs::remove(output_name);
     exit(0);
+  }
 
   return Ret;
 }