mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
Ports: Add LLVM port
This commit is contained in:
parent
794cf8eef4
commit
023df8e596
6 changed files with 235 additions and 0 deletions
9
Ports/llvm/patches/ReadMe.md
Normal file
9
Ports/llvm/patches/ReadMe.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Patches for LLVM on SerenityOS
|
||||
|
||||
## `remove-wstring.patch`
|
||||
|
||||
Removes `wstring`s from the source code, as SerenityOS doesn't support them yet.
|
||||
|
||||
## `insert-ifdef-serenity.patch`
|
||||
|
||||
This patch adds several defines in order to omit things not supported by SerenityOS.
|
109
Ports/llvm/patches/insert-ifdef-serenity.patch
Normal file
109
Ports/llvm/patches/insert-ifdef-serenity.patch
Normal file
|
@ -0,0 +1,109 @@
|
|||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/SmallVector.cpp llvm-project-llvmorg-12.0.0/llvm/lib/Support/SmallVector.cpp
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/SmallVector.cpp 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/lib/Support/SmallVector.cpp 2021-06-09 16:18:35.039546181 +0300
|
||||
@@ -132,7 +132,7 @@
|
||||
// Both uint32_t and uint64_t instantiations are needed for 64-bit builds.
|
||||
// This instantiation will never be used in 32-bit builds, and will cause
|
||||
// warnings when sizeof(Size_T) > sizeof(size_t).
|
||||
-#if SIZE_MAX > UINT32_MAX
|
||||
+#if SIZE_MAX > UINT32_MAX && !defined(__serenity__)
|
||||
template class llvm::SmallVectorBase<uint64_t>;
|
||||
|
||||
// Assertions to ensure this #if stays in sync with SmallVectorSizeType.
|
||||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Path.inc llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Path.inc
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Path.inc 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Path.inc 2021-06-09 16:24:37.446095863 +0300
|
||||
@@ -108,7 +108,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
|
||||
- defined(__MVS__)
|
||||
+ defined(__MVS__) || defined(__serenity__)
|
||||
#define STATVFS_F_FLAG(vfs) (vfs).f_flag
|
||||
#else
|
||||
#define STATVFS_F_FLAG(vfs) (vfs).f_flags
|
||||
@@ -524,7 +524,7 @@
|
||||
|
||||
// vmount entry not found; "remote" is the conservative answer.
|
||||
return false;
|
||||
-#elif defined(__MVS__)
|
||||
+#elif defined(__MVS__) || defined(__serenity__)
|
||||
// The file system can have an arbitrary structure on z/OS; must go with the
|
||||
// conservative answer.
|
||||
return false;
|
||||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Program.inc llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Program.inc
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Program.inc 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/lib/Support/Unix/Program.inc 2021-06-10 11:04:28.765989133 +0300
|
||||
@@ -335,7 +335,7 @@
|
||||
namespace llvm {
|
||||
namespace sys {
|
||||
|
||||
-#ifndef _AIX
|
||||
+#if !defined(_AIX) && !defined(__serenity__)
|
||||
using ::wait4;
|
||||
#else
|
||||
static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage);
|
||||
@@ -344,7 +344,7 @@
|
||||
} // namespace sys
|
||||
} // namespace llvm
|
||||
|
||||
-#ifdef _AIX
|
||||
+#if defined(_AIX) || defined(__serenity__)
|
||||
#ifndef _ALL_SOURCE
|
||||
extern "C" pid_t (wait4)(pid_t pid, int *status, int options,
|
||||
struct rusage *usage);
|
||||
@@ -357,7 +357,7 @@
|
||||
|
||||
// AIX wait4 does not work well with WNOHANG.
|
||||
if (!(options & WNOHANG))
|
||||
- return ::wait4(pid, status, options, usage);
|
||||
+ return ::waitpid(pid, status, options);
|
||||
|
||||
// For WNOHANG, we use waitid (which supports WNOWAIT) until the child process
|
||||
// has terminated.
|
||||
@@ -374,7 +374,7 @@
|
||||
// The child has already terminated, so a blocking wait on it is okay in the
|
||||
// absence of indiscriminate `wait` calls from the current process (which
|
||||
// would cause the call here to fail with ECHILD).
|
||||
- return ::wait4(pid, status, options & ~WNOHANG, usage);
|
||||
+ return ::waitpid(pid, status, options & ~WNOHANG);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -519,10 +519,10 @@
|
||||
|
||||
bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
|
||||
ArrayRef<StringRef> Args) {
|
||||
- static long ArgMax = sysconf(_SC_ARG_MAX);
|
||||
+ static long ArgMax = 4096;
|
||||
// POSIX requires that _POSIX_ARG_MAX is 4096, which is the lowest possible
|
||||
// value for ARG_MAX on a POSIX compliant system.
|
||||
- static long ArgMin = _POSIX_ARG_MAX;
|
||||
+ static long ArgMin = 4096;
|
||||
|
||||
// This the same baseline used by xargs.
|
||||
long EffectiveArgMax = 128 * 1024;
|
||||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink.cpp llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink.cpp 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink.cpp 2021-06-09 19:52:15.384543089 +0300
|
||||
@@ -660,7 +660,7 @@
|
||||
|
||||
Expected<std::unique_ptr<TargetProcessControl>>
|
||||
LLVMJITLinkRemoteTargetProcessControl::ConnectToExecutor() {
|
||||
-#ifndef LLVM_ON_UNIX
|
||||
+#if !defined(LLVM_ON_UNIX) || defined(__serenity__)
|
||||
// FIXME: Add TCP support for Windows.
|
||||
return make_error<StringError>("-" + OutOfProcessExecutorConnect.ArgStr +
|
||||
" not supported on non-unix platforms",
|
||||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp 2021-06-09 16:43:06.154952293 +0300
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
int openListener(std::string Host, int Port) {
|
||||
-#ifndef LLVM_ON_UNIX
|
||||
+#if !defined(LLVM_ON_UNIX) || defined(__serenity__)
|
||||
// FIXME: Add TCP support for Windows.
|
||||
printErrorAndExit("listen option not supported");
|
||||
return 0;
|
69
Ports/llvm/patches/remove-wstring.patch
Normal file
69
Ports/llvm/patches/remove-wstring.patch
Normal file
|
@ -0,0 +1,69 @@
|
|||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/SwapByteOrder.h 2021-06-09 16:00:20.111549941 +0300
|
||||
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
|
||||
- defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
|
||||
+ defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__serenity__)
|
||||
#include <endian.h>
|
||||
#elif defined(_AIX)
|
||||
#include <sys/machine.h>
|
||||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/ConvertUTF.h llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/ConvertUTF.h
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/ConvertUTF.h 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/include/llvm/Support/ConvertUTF.h 2021-06-09 16:04:10.069288846 +0300
|
||||
@@ -200,19 +200,19 @@
|
||||
* Converts a UTF-8 StringRef to a std::wstring.
|
||||
* \return true on success.
|
||||
*/
|
||||
-bool ConvertUTF8toWide(llvm::StringRef Source, std::wstring &Result);
|
||||
+bool ConvertUTF8toWide(llvm::StringRef Source, std::string &Result);
|
||||
|
||||
/**
|
||||
* Converts a UTF-8 C-string to a std::wstring.
|
||||
* \return true on success.
|
||||
*/
|
||||
-bool ConvertUTF8toWide(const char *Source, std::wstring &Result);
|
||||
+bool ConvertUTF8toWide(const char *Source, std::string &Result);
|
||||
|
||||
/**
|
||||
* Converts a std::wstring to a UTF-8 encoded std::string.
|
||||
* \return true on success.
|
||||
*/
|
||||
-bool convertWideToUTF8(const std::wstring &Source, std::string &Result);
|
||||
+bool convertWideToUTF8(const std::string &Source, std::string &Result);
|
||||
|
||||
|
||||
/**
|
||||
diff -ruN llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/ConvertUTFWrapper.cpp llvm-project-llvmorg-12.0.0/llvm/lib/Support/ConvertUTFWrapper.cpp
|
||||
--- llvm-orig/llvm-project-llvmorg-12.0.0/llvm/lib/Support/ConvertUTFWrapper.cpp 2021-04-06 19:38:18.000000000 +0300
|
||||
+++ llvm-project-llvmorg-12.0.0/llvm/lib/Support/ConvertUTFWrapper.cpp 2021-06-09 16:15:53.330400711 +0300
|
||||
@@ -196,15 +196,15 @@
|
||||
Result.clear();
|
||||
return false;
|
||||
}
|
||||
- Result.resize(reinterpret_cast<wchar_t *>(ResultPtr) - &Result[0]);
|
||||
+ Result.resize(reinterpret_cast<char *>(ResultPtr) - &Result[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
-bool ConvertUTF8toWide(llvm::StringRef Source, std::wstring &Result) {
|
||||
+bool ConvertUTF8toWide(llvm::StringRef Source, std::string &Result) {
|
||||
return ConvertUTF8toWideInternal(Source, Result);
|
||||
}
|
||||
|
||||
-bool ConvertUTF8toWide(const char *Source, std::wstring &Result) {
|
||||
+bool ConvertUTF8toWide(const char *Source, std::string &Result) {
|
||||
if (!Source) {
|
||||
Result.clear();
|
||||
return true;
|
||||
@@ -212,7 +212,7 @@
|
||||
return ConvertUTF8toWide(llvm::StringRef(Source), Result);
|
||||
}
|
||||
|
||||
-bool convertWideToUTF8(const std::wstring &Source, std::string &Result) {
|
||||
+bool convertWideToUTF8(const std::string &Source, std::string &Result) {
|
||||
if (sizeof(wchar_t) == 1) {
|
||||
const UTF8 *Start = reinterpret_cast<const UTF8 *>(Source.data());
|
||||
const UTF8 *End =
|
Loading…
Add table
Add a link
Reference in a new issue