]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Revert "gdb/compile: Use std::filesystem::remove_all in cleanup"
authorLancelot SIX <lancelot.six@amd.com>
Wed, 3 Apr 2024 14:39:10 +0000 (15:39 +0100)
committerLancelot SIX <lancelot.six@amd.com>
Wed, 3 Apr 2024 15:30:48 +0000 (16:30 +0100)
This reverts commit 7bba0ad08576309763e3f41193eaa93025e10b8b.

Tom de Vries reported that 7bba0ad0857 (gdb/compile: Use
std::filesystem::remove_all in cleanup) broke builds with gcc-7.5.0
which mostly supports c++17, but not std::filesystem[1].  As this change
is not critical, revert it to maintain compatibility.

[1] https://inbox.sourceware.org/gdb-patches/a06e6483-aa2e-4b8a-854f-e369a1e961ea@suse.de/

Change-Id: I58150bd27600c95052bdf1bbbd6b44718a5a0bbf
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31420
Approved-By: Tom Tromey <tom@tromey.com>
gdb/compile/compile.c

index bff69a5092dc7dbe78f6db3a2a33ce2942c54cd0..2d97a1b2005fc4d965e1fc719117fea25c0f36c6 100644 (file)
@@ -39,9 +39,7 @@
 #include "osabi.h"
 #include "gdbsupport/gdb_wait.h"
 #include "valprint.h"
-#include <filesystem>
 #include <optional>
-#include <system_error>
 #include "gdbsupport/gdb_unlinker.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/scoped_ignore_signal.h"
@@ -451,11 +449,15 @@ get_compile_file_tempdir (void)
   tempdir_name = xstrdup (tempdir_name);
   add_final_cleanup ([] ()
     {
-      std::error_code error;
-      if (std::filesystem::remove_all (tempdir_name, error)
-         == static_cast<std::uintmax_t> (-1))
-       warning (_("Could not remove temporary directory %s (%s)"),
-                tempdir_name, error.message ().c_str ());
+      char *zap;
+      int wstat;
+
+      gdb_assert (startswith (tempdir_name, TMP_PREFIX));
+      zap = concat ("rm -rf ", tempdir_name, (char *) NULL);
+      wstat = system (zap);
+      if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
+       warning (_("Could not remove temporary directory %s"), tempdir_name);
+      XDELETEVEC (zap);
     });
   return tempdir_name;
 }