[llvm] [llvm] Add managarm support (PR #138854)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 04:49:28 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: no92 (no92)
<details>
<summary>Changes</summary>
This PR is part of a series to upstream managarm support, as laid out in the [RFC](https://discourse.llvm.org/t/rfc-new-proposed-managarm-support-for-llvm-and-clang-87845/85884/1). This PR is a follow-up to #<!-- -->87845.
The intention here is to add the managarm target to the LLVM support lib, in preparation for a follow-up that would add the missing clang driver bits.
---
Full diff: https://github.com/llvm/llvm-project/pull/138854.diff
2 Files Affected:
- (modified) llvm/include/llvm/ADT/bit.h (+1-1)
- (modified) llvm/lib/Support/Unix/Path.inc (+8-5)
``````````diff
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 915a7de50aaff..8544efb5c45d4 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -30,7 +30,7 @@
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || \
- defined(__OpenBSD__) || defined(__DragonFly__)
+ defined(__OpenBSD__) || defined(__DragonFly__) || defined(__managarm__)
#include <endian.h>
#elif defined(_AIX)
#include <sys/machine.h>
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 6004e007c0c7a..593f4111d06c1 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -69,7 +69,8 @@ extern char **environ;
#include <sys/types.h>
#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && \
- !defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX)
+ !defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX) && \
+ !defined(__managarm__)
#include <sys/statvfs.h>
#define STATVFS statvfs
#define FSTATVFS fstatvfs
@@ -78,7 +79,7 @@ extern char **environ;
#if defined(__OpenBSD__) || defined(__FreeBSD__)
#include <sys/mount.h>
#include <sys/param.h>
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__managarm__)
#if defined(HAVE_LINUX_MAGIC_H)
#include <linux/magic.h>
#else
@@ -124,7 +125,8 @@ const file_t kInvalidFile = -1;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__FreeBSD_kernel__) || defined(__linux__) || defined(__CYGWIN__) || \
defined(__DragonFly__) || defined(_AIX) || defined(__GNU__) || \
- (defined(__sun__) && defined(__svr4__) || defined(__HAIKU__))
+ (defined(__sun__) && defined(__svr4__) || defined(__HAIKU__)) || \
+ defined(__managarm__)
static int test_dir(char ret[PATH_MAX], const char *dir, const char *bin) {
struct stat sb;
char fullpath[PATH_MAX];
@@ -245,7 +247,8 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
// If we don't have procfs mounted, fall back to argv[0]
if (getprogpath(exe_path, argv0) != NULL)
return exe_path;
-#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__)
+#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__) || \
+ defined(__managarm__)
char exe_path[PATH_MAX];
const char *aPath = "/proc/self/exe";
if (sys::fs::exists(aPath)) {
@@ -472,7 +475,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) {
}
static bool is_local_impl(struct STATVFS &Vfs) {
-#if defined(__linux__) || defined(__GNU__)
+#if defined(__linux__) || defined(__GNU__) || defined(__managarm__)
#ifndef NFS_SUPER_MAGIC
#define NFS_SUPER_MAGIC 0x6969
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/138854
More information about the llvm-commits
mailing list