Ports: Remove obsolete mold patch

This is no longer needed, as both toolchains now support
std::filesystem.
This commit is contained in:
Daniel Bertalan 2022-01-12 13:03:12 +01:00 committed by Andreas Kling
parent c7423dc20b
commit 3cbf20ca5d
Notes: sideshowbarker 2024-07-17 21:05:16 +09:00

View file

@ -1,89 +0,0 @@
From b7141fc8a74705a0a772f5495a9a92ed7768a6af Mon Sep 17 00:00:00 2001
From: Andrew Kaster <akaster@serenityos.org>
Date: Tue, 11 Jan 2022 01:02:44 -0700
Subject: [PATCH 3/7] Replace std::filesystem usage with Core::File
At least the Clang toolchain does not support std::filesystem, so hack
up the two files that use it to use Core::File abstractions instead.
---
elf/subprocess.cc | 11 +++++++++++
filepath.cc | 19 +++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/elf/subprocess.cc b/elf/subprocess.cc
index 3ed66c89..9e2fa9f6 100644
--- a/elf/subprocess.cc
+++ b/elf/subprocess.cc
@@ -1,6 +1,12 @@
#include "mold.h"
+#ifdef __serenity__
+#define AK_DONT_REPLACE_STD
+#include <LibCore/File.h>
+#else
#include <filesystem>
+#endif
+
#include <signal.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -251,7 +257,12 @@ void daemonize(Context<E> &ctx, std::function<void()> *wait_for_client,
}
static std::string get_self_path() {
+#ifdef __serenity__
+ auto str = Core::File::read_link("/proc/self/exe");
+ return { str.characters(), str.length() };
+#else
return std::filesystem::read_symlink("/proc/self/exe");
+#endif
}
static bool is_regular_file(const std::string &path) {
diff --git a/filepath.cc b/filepath.cc
index e12043bf..0e158da2 100644
--- a/filepath.cc
+++ b/filepath.cc
@@ -1,20 +1,39 @@
#include "mold.h"
+#ifdef __serenity__
+#define AK_DONT_REPLACE_STD
+#include <LibCore/File.h>
+#else
#include <filesystem>
+#endif
#include <sys/stat.h>
namespace mold {
std::string get_current_dir() {
+#ifdef __serenity__
+ auto str = Core::File::current_working_directory();
+ return { str.characters(), str.length() };
+#else
return std::filesystem::current_path();
+#endif
}
std::string get_realpath(std::string_view path) {
+#ifdef __serenity__
+ StringView sv{ path.data(), path.length() };
+ errno = 0;
+ auto str = Core::File::real_path_for(sv);
+ if (str.is_empty() || errno != 0)
+ return std::string(path);
+ return { str.characters(), str.length() };
+#else
std::error_code ec;
std::string ret = std::filesystem::canonical(path, ec);
if (ec)
return std::string(path);
return ret;
+#endif
}
bool path_is_dir(std::string_view path) {
--
2.25.1