Compare commits

...

2 Commits

45 changed files with 508 additions and 45 deletions

View File

@ -142,6 +142,8 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
return std::make_unique<DarwinAArch64TargetInfo>(Triple, Opts); return std::make_unique<DarwinAArch64TargetInfo>(Triple, Opts);
switch (os) { switch (os) {
case llvm::Triple::Yggdrasil:
return std::make_unique<YggdrasilTargetInfo<AArch64leTargetInfo>>(Triple, Opts);
case llvm::Triple::FreeBSD: case llvm::Triple::FreeBSD:
return std::make_unique<FreeBSDTargetInfo<AArch64leTargetInfo>>(Triple, return std::make_unique<FreeBSDTargetInfo<AArch64leTargetInfo>>(Triple,
Opts); Opts);
@ -439,6 +441,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
case llvm::Triple::riscv64: case llvm::Triple::riscv64:
switch (os) { switch (os) {
case llvm::Triple::Yggdrasil:
return std::make_unique<YggdrasilTargetInfo<RISCV64TargetInfo>>(Triple,
Opts);
case llvm::Triple::FreeBSD: case llvm::Triple::FreeBSD:
return std::make_unique<FreeBSDTargetInfo<RISCV64TargetInfo>>(Triple, return std::make_unique<FreeBSDTargetInfo<RISCV64TargetInfo>>(Triple,
Opts); Opts);
@ -578,6 +583,8 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
} }
case llvm::Triple::Haiku: case llvm::Triple::Haiku:
return std::make_unique<HaikuX86_32TargetInfo>(Triple, Opts); return std::make_unique<HaikuX86_32TargetInfo>(Triple, Opts);
case llvm::Triple::Yggdrasil:
return std::make_unique<YggdrasilTargetInfo<X86_32TargetInfo>>(Triple, Opts);
case llvm::Triple::RTEMS: case llvm::Triple::RTEMS:
return std::make_unique<RTEMSX86_32TargetInfo>(Triple, Opts); return std::make_unique<RTEMSX86_32TargetInfo>(Triple, Opts);
case llvm::Triple::NaCl: case llvm::Triple::NaCl:
@ -638,6 +645,8 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
} }
case llvm::Triple::Haiku: case llvm::Triple::Haiku:
return std::make_unique<HaikuTargetInfo<X86_64TargetInfo>>(Triple, Opts); return std::make_unique<HaikuTargetInfo<X86_64TargetInfo>>(Triple, Opts);
case llvm::Triple::Yggdrasil:
return std::make_unique<YggdrasilTargetInfo<X86_64TargetInfo>>(Triple, Opts);
case llvm::Triple::NaCl: case llvm::Triple::NaCl:
return std::make_unique<NaClTargetInfo<X86_64TargetInfo>>(Triple, Opts); return std::make_unique<NaClTargetInfo<X86_64TargetInfo>>(Triple, Opts);
case llvm::Triple::PS4: case llvm::Triple::PS4:

View File

@ -878,6 +878,25 @@ public:
} }
}; };
// Yggdrasil Target
template <typename Target>
class LLVM_LIBRARY_VISIBILITY YggdrasilTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
Builder.defineMacro("__yggdrasil__");
Builder.defineMacro("__FLOAT128__");
this->PlatformName = "yggdrasil";
}
public:
YggdrasilTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: OSTargetInfo<Target>(Triple, Opts) {
this->WIntType = TargetInfo::UnsignedInt;
this->MCountName = "__mcount";
this->HasFloat128 = true;
}
};
// WebAssembly target // WebAssembly target
template <typename Target> template <typename Target>
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo

View File

@ -85,6 +85,7 @@ add_clang_library(clangDriver
ToolChains/PPCFreeBSD.cpp ToolChains/PPCFreeBSD.cpp
ToolChains/InterfaceStubs.cpp ToolChains/InterfaceStubs.cpp
ToolChains/ZOS.cpp ToolChains/ZOS.cpp
ToolChains/Yggdrasil.cpp
Types.cpp Types.cpp
XRayArgs.cpp XRayArgs.cpp

View File

@ -21,6 +21,7 @@
#include "ToolChains/DragonFly.h" #include "ToolChains/DragonFly.h"
#include "ToolChains/FreeBSD.h" #include "ToolChains/FreeBSD.h"
#include "ToolChains/Fuchsia.h" #include "ToolChains/Fuchsia.h"
#include "ToolChains/Yggdrasil.h"
#include "ToolChains/Gnu.h" #include "ToolChains/Gnu.h"
#include "ToolChains/HIPAMD.h" #include "ToolChains/HIPAMD.h"
#include "ToolChains/HIPSPV.h" #include "ToolChains/HIPSPV.h"
@ -1965,10 +1966,17 @@ int Driver::ExecuteCompilation(
// llvm/lib/Support/*/Signals.inc will exit with a special return code // llvm/lib/Support/*/Signals.inc will exit with a special return code
// for SIGPIPE. Do not print diagnostics for this case. // for SIGPIPE. Do not print diagnostics for this case.
#if defined(__yggdrasil__)
if (CommandRes == -1) {
Res = CommandRes;
continue;
}
#else
if (CommandRes == EX_IOERR) { if (CommandRes == EX_IOERR) {
Res = CommandRes; Res = CommandRes;
continue; continue;
} }
#endif
// Print extra information about abnormal failures, if possible. // Print extra information about abnormal failures, if possible.
// //
@ -6351,6 +6359,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::Haiku: case llvm::Triple::Haiku:
TC = std::make_unique<toolchains::Haiku>(*this, Target, Args); TC = std::make_unique<toolchains::Haiku>(*this, Target, Args);
break; break;
case llvm::Triple::Yggdrasil:
TC = std::make_unique<toolchains::Yggdrasil>(*this, Target, Args);
break;
case llvm::Triple::Darwin: case llvm::Triple::Darwin:
case llvm::Triple::MacOSX: case llvm::Triple::MacOSX:
case llvm::Triple::IOS: case llvm::Triple::IOS:

View File

@ -0,0 +1,260 @@
#include "Yggdrasil.h"
#include "CommonArgs.h"
#include "clang/Config/config.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/MultilibBuilder.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/Option/ArgList.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <iostream>
using namespace clang::driver;
using namespace clang::driver::toolchains;
using namespace clang::driver::tools;
using namespace clang;
using namespace llvm::opt;
using tools::addMultilibFlag;
void yggdrasil::Linker::ConstructJob(
Compilation &C,
const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput
) const {
const toolchains::Yggdrasil &ToolChain = static_cast<const toolchains::Yggdrasil &>(getToolChain());
const Driver &D = ToolChain.getDriver();
ArgStringList CmdArgs;
// Silence warning for "clang -g foo.o -o foo"
Args.ClaimAllArgs(options::OPT_g_Group);
// and "clang -emit-llvm foo.o -o foo"
Args.ClaimAllArgs(options::OPT_emit_llvm);
// and for "clang -w foo.o -o foo". Other warning options are already
// handled somewhere else.
Args.ClaimAllArgs(options::OPT_w);
const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
CmdArgs.push_back("-z");
CmdArgs.push_back("max-page-size=4096");
CmdArgs.push_back("--eh-frame-hdr");
if (!Args.hasArg(options::OPT_shared) &&
!Args.hasArg(options::OPT_static) &&
!Args.hasArg(options::OPT_r)) {
CmdArgs.push_back("-pie");
}
if (Args.hasArg(options::OPT_r)) {
CmdArgs.push_back("-r");
} else {
CmdArgs.push_back("--build-id");
CmdArgs.push_back("--hash-style=gnu");
}
if (!D.SysRoot.empty()) {
CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
}
if (Args.hasArg(options::OPT_s)) {
CmdArgs.push_back("-s");
}
if (Args.hasArg(options::OPT_static)) {
CmdArgs.push_back("-Bstatic");
} else {
if (Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back("-shared");
}
CmdArgs.push_back("--dynamic-linker=/libexec/dyn-loader");
}
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, options::OPT_r)) {
if (!Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
}
}
Args.AddAllArgs(CmdArgs, options::OPT_L);
Args.AddAllArgs(CmdArgs, options::OPT_u);
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
// if (D.isUsingLTO()) {
// assert(!Inputs.empty() && "Must have at least one input.");
// addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
// D.getLTOMode() == LTOK_Thin);
// }
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
if (!Args.hasArg(options::OPT_nolibc)) {
CmdArgs.push_back("-lygglibc");
}
if (D.CCCIsCXX()) {
if (ToolChain.ShouldLinkCXXStdlib(Args)) {
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
CmdArgs.push_back("-lm");
// CmdArgs.push_back("-lpthread");
}
}
}
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
Exec, CmdArgs, Inputs, Output));
}
/// Yggdrasil - Yggdrasil OS tool chain which can call as(1) and ld(1) directly.
Yggdrasil::Yggdrasil(
const Driver &D,
const llvm::Triple &Triple,
const ArgList &Args
): ToolChain(D, Triple, Args) {
getProgramPaths().push_back(getDriver().Dir);
if (!D.SysRoot.empty()) {
SmallString<128> P(D.SysRoot);
llvm::sys::path::append(P, "lib");
getFilePaths().push_back(std::string(P));
}
getFilePaths().push_back(concat(getDriver().SysRoot, "/lib"));
getFilePaths().push_back(concat(getDriver().SysRoot, "/usr/lib"));
}
std::string Yggdrasil::ComputeEffectiveClangTriple(const ArgList &Args,
types::ID InputType) const {
llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
return Triple.str();
}
Tool *Yggdrasil::buildLinker() const {
return new tools::yggdrasil::Linker(*this);
}
ToolChain::RuntimeLibType Yggdrasil::GetRuntimeLibType(const ArgList &Args) const {
return ToolChain::RLT_CompilerRT;
}
ToolChain::RuntimeLibType Yggdrasil::GetDefaultRuntimeLibType() const {
return ToolChain::RLT_CompilerRT;
}
ToolChain::CXXStdlibType Yggdrasil::GetDefaultCXXStdlibType() const {
return ToolChain::CST_Libcxx;
}
ToolChain::UnwindLibType Yggdrasil::GetUnwindLibType(const ArgList &Args) const {
return ToolChain::UNW_None;
}
ToolChain::CXXStdlibType Yggdrasil::GetCXXStdlibType(const ArgList &Args) const {
return ToolChain::CST_Libcxx;
}
ToolChain::UnwindTableLevel Yggdrasil::getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const {
return ToolChain::UnwindTableLevel::None;
}
void Yggdrasil::addClangTargetOptions(const ArgList &DriverArgs,
ArgStringList &CC1Args,
Action::OffloadKind) const {
if (getArch() == llvm::Triple::x86 || getArch() == llvm::Triple::riscv64) {
CC1Args.push_back("-mstack-alignment=16");
}
// if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
// options::OPT_fno_use_init_array, true))
// CC1Args.push_back("-fno-use-init-array");
// CC1Args.push_back("-mlong-double-64"); // for newlib + libc++ compat
// CC1Args.push_back("-ffunction-sections"); // better to optimize binary sizes
// CC1Args.push_back("-fdata-sections");
}
void Yggdrasil::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
const Driver &D = getDriver();
if (DriverArgs.hasArg(options::OPT_nostdinc)) {
return;
}
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
SmallString<128> P(D.ResourceDir);
llvm::sys::path::append(P, "include");
addSystemInclude(DriverArgs, CC1Args, P);
}
if (DriverArgs.hasArg(options::OPT_nostdlibinc)) {
return;
}
if (!D.SysRoot.empty()) {
SmallString<128> P(D.SysRoot);
llvm::sys::path::append(P, "include");
addExternCSystemInclude(DriverArgs, CC1Args, P.str());
}
addSystemInclude(DriverArgs, CC1Args, concat(getDriver().SysRoot, "/usr/include"));
}
void Yggdrasil::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx)) {
return;
}
switch (GetCXXStdlibType(DriverArgs)) {
case ToolChain::CST_Libcxx: {
SmallString<128> P(getDriver().SysRoot);
llvm::sys::path::append(P, "include", "c++", "v1");
addSystemInclude(DriverArgs, CC1Args, P.str());
break;
}
default:
llvm_unreachable("invalid stdlib name");
}
}
void Yggdrasil::AddCXXStdlibLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
switch (GetCXXStdlibType(Args)) {
case ToolChain::CST_Libcxx:
CmdArgs.push_back("-lc++");
break;
case ToolChain::CST_Libstdcxx:
llvm_unreachable("invalid stdlib name");
}
}
std::string Yggdrasil::getCompilerRTPath() const {
SmallString<128> Path(getDriver().SysRoot);
llvm::sys::path::append(Path, "lib", getOSLibName());
return std::string(Path.str());
}

View File

@ -0,0 +1,98 @@
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_YGGDRASIL_H
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_YGGDRASIL_H
#include "Gnu.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "llvm/MC/MCTargetOptions.h"
namespace clang {
namespace driver {
namespace tools {
namespace yggdrasil {
class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
public:
Linker(const ToolChain &TC) : Tool("yggdrasil::Linker", "ld.lld", TC) {}
bool hasIntegratedCPP() const override { return false; }
bool isLinkJob() const override { return true; }
void ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
} // end yggdrasil
} // end tools
namespace toolchains {
class LLVM_LIBRARY_VISIBILITY Yggdrasil : public ToolChain {
public:
Yggdrasil(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args);
bool HasNativeLLVMSupport() const override { return true; }
bool IsIntegratedAssemblerDefault() const override { return true; }
bool IsMathErrnoDefault() const override { return false; }
bool useRelaxRelocations() const override { return true; }
UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
RuntimeLibType GetDefaultRuntimeLibType() const override;
CXXStdlibType GetDefaultCXXStdlibType() const override;
bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const {
return true;
}
llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const override {
return llvm::ExceptionHandling::DwarfCFI;
}
bool isPICDefault() const override { return false; }
bool isPIEDefault(const llvm::opt::ArgList &Args) const override { return false; }
bool isPICDefaultForced() const override { return false; }
llvm::DebuggerKind getDefaultDebuggerTuning() const override {
return llvm::DebuggerKind::GDB;
}
LangOptions::StackProtectorMode GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
return LangOptions::SSPStrong;
}
std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
types::ID InputType) const override;
RuntimeLibType
GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
UnwindLibType
GetUnwindLibType(const llvm::opt::ArgList &Args) const override;
CXXStdlibType
GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const override;
void
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void
AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
const char *getDefaultLinker() const override {
return "ld.lld";
}
virtual std::string getCompilerRTPath() const override;
protected:
Tool *buildLinker() const override;
};
} // end toolchains
} // end driver
} // end clang
#endif

View File

@ -1157,8 +1157,11 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
unsigned Vendor; unsigned Vendor;
unsigned Model, Family; unsigned Model, Family;
unsigned Features[(CPU_FEATURE_MAX + 31) / 32] = {0}; unsigned Features[(CPU_FEATURE_MAX + 31) / 32] = {0};
// TODO static_assert is not defined
#if !defined(__yggdrasil__)
static_assert(sizeof(Features) / sizeof(Features[0]) == 4, ""); static_assert(sizeof(Features) / sizeof(Features[0]) == 4, "");
static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, ""); static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, "");
#endif
// This function needs to run just once. // This function needs to run just once.
if (__cpu_model.__cpu_vendor) if (__cpu_model.__cpu_vendor)

View File

@ -817,7 +817,8 @@ typedef __char32_t char32_t;
defined(__APPLE__) || \ defined(__APPLE__) || \
defined(__MVS__) || \ defined(__MVS__) || \
defined(_AIX) || \ defined(_AIX) || \
defined(__EMSCRIPTEN__) defined(__EMSCRIPTEN__) || \
defined(__yggdrasil__)
// clang-format on // clang-format on
# define _LIBCPP_HAS_THREAD_API_PTHREAD # define _LIBCPP_HAS_THREAD_API_PTHREAD
# elif defined(__Fuchsia__) # elif defined(__Fuchsia__)

View File

@ -314,7 +314,7 @@ public:
# else # else
static const mask __regex_word = 1 << 10; static const mask __regex_word = 1 << 10;
# endif // defined(__BIONIC__) # endif // defined(__BIONIC__)
#elif defined(__GLIBC__) #elif defined(__GLIBC__) || defined(__yggdrasil__)
typedef unsigned short mask; typedef unsigned short mask;
static const mask space = _ISspace; static const mask space = _ISspace;
static const mask print = _ISprint; static const mask print = _ISprint;
@ -326,7 +326,7 @@ public:
static const mask punct = _ISpunct; static const mask punct = _ISpunct;
static const mask xdigit = _ISxdigit; static const mask xdigit = _ISxdigit;
static const mask blank = _ISblank; static const mask blank = _ISblank;
# if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN) # if !defined(__yggdrasil__) && (defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN))
static const mask __regex_word = static_cast<mask>(_ISbit(15)); static const mask __regex_word = static_cast<mask>(_ISbit(15));
# else # else
static const mask __regex_word = 0x80; static const mask __regex_word = 0x80;

View File

@ -244,7 +244,11 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
#if defined(__yggdrasil__)
typedef ssize_t streamsize;
#else
typedef ptrdiff_t streamsize; typedef ptrdiff_t streamsize;
#endif
class _LIBCPP_EXPORTED_FROM_ABI ios_base { class _LIBCPP_EXPORTED_FROM_ABI ios_base {
public: public:

View File

@ -101,6 +101,18 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL); _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);
} }
#elif defined(__yggdrasil__)
static void __libcpp_platform_wait_on_address(
__cxx_atomic_contention_t const volatile* __ptr,
__cxx_contention_t __val
) {}
static void __libcpp_platform_wake_by_address(
__cxx_atomic_contention_t const volatile*,
bool
) {}
#else // <- Add other operating systems here #else // <- Add other operating systems here
// Baseline is just a timed backoff // Baseline is just a timed backoff

View File

@ -33,7 +33,7 @@
// OpenBSD does not have a fully conformant suite of POSIX timers, but // OpenBSD does not have a fully conformant suite of POSIX timers, but
// it does have clock_gettime and CLOCK_MONOTONIC which is all we need. // it does have clock_gettime and CLOCK_MONOTONIC which is all we need.
#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) #if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || defined(__yggdrasil__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
# define _LIBCPP_HAS_CLOCK_GETTIME # define _LIBCPP_HAS_CLOCK_GETTIME
#endif #endif

View File

@ -985,7 +985,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {
return _LIBCPP_GET_C_LOCALE->__ctype_b; return _LIBCPP_GET_C_LOCALE->__ctype_b;
# elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) # elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
return __pctype_func(); return __pctype_func();
# elif defined(__EMSCRIPTEN__) # elif defined(__EMSCRIPTEN__) || defined(__yggdrasil__)
return *__ctype_b_loc(); return *__ctype_b_loc();
# elif defined(_NEWLIB_VERSION) # elif defined(_NEWLIB_VERSION)
// Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1]. // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1].

View File

@ -18,7 +18,7 @@
#include "llvm/Support/Parallel.h" #include "llvm/Support/Parallel.h"
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/TimeProfiler.h"
#if LLVM_ON_UNIX #if LLVM_ON_UNIX || defined(__yggdrasil__)
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <thread> #include <thread>

View File

@ -1238,7 +1238,7 @@ if( LLVM_INCLUDE_UTILS )
if( LLVM_INCLUDE_TESTS ) if( LLVM_INCLUDE_TESTS )
set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test") set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest) add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
set(LLVM_SUBPROJECT_TITLE) set(LLVM_SUBPROJECT_TITLE)
endif() endif()
else() else()
if ( LLVM_INCLUDE_TESTS ) if ( LLVM_INCLUDE_TESTS )

View File

@ -217,7 +217,7 @@ elseif(FUCHSIA OR UNIX)
else() else()
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif() endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic") elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic" OR CMAKE_SYSTEM_NAME STREQUAL "yggdrasil")
set(LLVM_ON_WIN32 0) set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 0) set(LLVM_ON_UNIX 0)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)

View File

@ -393,7 +393,9 @@ void GenericCycleInfo<ContextT>::compute(FunctionT &F) {
<< "\n"); << "\n");
Compute.run(&F.front()); Compute.run(&F.front());
#if !defined(NDEBUG)
assert(validateTree()); assert(validateTree());
#endif
} }
template <typename ContextT> template <typename ContextT>
@ -406,7 +408,9 @@ void GenericCycleInfo<ContextT>::splitCriticalEdge(BlockT *Pred, BlockT *Succ,
return; return;
addBlockToCycle(NewBlock, Cycle); addBlockToCycle(NewBlock, Cycle);
#if !defined(NDEBUG)
assert(validateTree()); assert(validateTree());
#endif
} }
/// \brief Find the innermost cycle containing a given block. /// \brief Find the innermost cycle containing a given block.

View File

@ -135,7 +135,7 @@ inline perms operator~(perms x) {
/// represents the information provided by Windows FileFirstFile/FindNextFile. /// represents the information provided by Windows FileFirstFile/FindNextFile.
class basic_file_status { class basic_file_status {
protected: protected:
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
time_t fs_st_atime = 0; time_t fs_st_atime = 0;
time_t fs_st_mtime = 0; time_t fs_st_mtime = 0;
uint32_t fs_st_atime_nsec = 0; uint32_t fs_st_atime_nsec = 0;
@ -159,7 +159,7 @@ public:
explicit basic_file_status(file_type Type) : Type(Type) {} explicit basic_file_status(file_type Type) : Type(Type) {}
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
basic_file_status(file_type Type, perms Perms, time_t ATime, basic_file_status(file_type Type, perms Perms, time_t ATime,
uint32_t ATimeNSec, time_t MTime, uint32_t MTimeNSec, uint32_t ATimeNSec, time_t MTime, uint32_t MTimeNSec,
uid_t UID, gid_t GID, off_t Size) uid_t UID, gid_t GID, off_t Size)
@ -198,7 +198,7 @@ public:
/// same machine. /// same machine.
TimePoint<> getLastModificationTime() const; TimePoint<> getLastModificationTime() const;
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
uint32_t getUser() const { return fs_st_uid; } uint32_t getUser() const { return fs_st_uid; }
uint32_t getGroup() const { return fs_st_gid; } uint32_t getGroup() const { return fs_st_gid; }
uint64_t getSize() const { return fs_st_size; } uint64_t getSize() const { return fs_st_size; }
@ -225,7 +225,7 @@ public:
class file_status : public basic_file_status { class file_status : public basic_file_status {
friend bool equivalent(file_status A, file_status B); friend bool equivalent(file_status A, file_status B);
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
dev_t fs_st_dev = 0; dev_t fs_st_dev = 0;
nlink_t fs_st_nlinks = 0; nlink_t fs_st_nlinks = 0;
ino_t fs_st_ino = 0; ino_t fs_st_ino = 0;
@ -240,7 +240,7 @@ public:
explicit file_status(file_type Type) : basic_file_status(Type) {} explicit file_status(file_type Type) : basic_file_status(Type) {}
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
file_status(file_type Type, perms Perms, dev_t Dev, nlink_t Links, ino_t Ino, file_status(file_type Type, perms Perms, dev_t Dev, nlink_t Links, ino_t Ino,
time_t ATime, uint32_t ATimeNSec, time_t ATime, uint32_t ATimeNSec,
time_t MTime, uint32_t MTimeNSec, time_t MTime, uint32_t MTimeNSec,
@ -1209,7 +1209,7 @@ std::error_code unlockFile(int FD);
/// means that the filesystem may have failed to perform some buffered writes. /// means that the filesystem may have failed to perform some buffered writes.
std::error_code closeFile(file_t &F); std::error_code closeFile(file_t &F);
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
/// @brief Change ownership of a file. /// @brief Change ownership of a file.
/// ///
/// @param Owner The owner of the file to change to. /// @param Owner The owner of the file to change to.

View File

@ -28,7 +28,7 @@ namespace sys {
/// This is the OS-specific separator for PATH like environment variables: /// This is the OS-specific separator for PATH like environment variables:
// a colon on Unix or a semicolon on Windows. // a colon on Unix or a semicolon on Windows.
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
const char EnvPathSeparator = ':'; const char EnvPathSeparator = ':';
#elif defined (_WIN32) #elif defined (_WIN32)
const char EnvPathSeparator = ';'; const char EnvPathSeparator = ';';

View File

@ -31,7 +31,7 @@ typedef PVOID HANDLE;
namespace llvm { namespace llvm {
#if LLVM_ON_UNIX || _WIN32 #if LLVM_ON_UNIX || defined(__yggdrasil__) || _WIN32
/// LLVM thread following std::thread interface with added constructor to /// LLVM thread following std::thread interface with added constructor to
/// specify stack size. /// specify stack size.
@ -46,7 +46,7 @@ class thread {
} }
public: public:
#if LLVM_ON_UNIX #if LLVM_ON_UNIX || defined(__yggdrasil__)
using native_handle_type = pthread_t; using native_handle_type = pthread_t;
using id = pthread_t; using id = pthread_t;
using start_routine_type = void *(*)(void *); using start_routine_type = void *(*)(void *);

View File

@ -238,6 +238,7 @@ public:
ShaderModel, // DirectX ShaderModel ShaderModel, // DirectX ShaderModel
LiteOS, LiteOS,
Serenity, Serenity,
Yggdrasil,
Vulkan, // Vulkan SPIR-V Vulkan, // Vulkan SPIR-V
LastOSType = Vulkan LastOSType = Vulkan
}; };

View File

@ -716,7 +716,7 @@ static bool constantIsDead(const Constant *C, bool RemoveDeadUsers) {
ReplaceableMetadataImpl::SalvageDebugInfo(*C); ReplaceableMetadataImpl::SalvageDebugInfo(*C);
const_cast<Constant *>(C)->destroyConstant(); const_cast<Constant *>(C)->destroyConstant();
} }
return true; return true;
} }
@ -2239,10 +2239,10 @@ Constant *ConstantExpr::getPointerBitCastOrAddrSpaceCast(Constant *S,
} }
Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG // #ifndef NDEBUG
bool fromVec = isa<VectorType>(C->getType()); bool fromVec = isa<VectorType>(C->getType());
bool toVec = isa<VectorType>(Ty); bool toVec = isa<VectorType>(Ty);
#endif // #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer"); assert(C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer");
assert(Ty->isIntOrIntVectorTy() && "Trunc produces only integral"); assert(Ty->isIntOrIntVectorTy() && "Trunc produces only integral");

View File

@ -382,11 +382,11 @@ StringRef DIScope::getName() const {
return ""; return "";
} }
#ifndef NDEBUG // #ifndef NDEBUG
static bool isCanonical(const MDString *S) { static bool isCanonical(const MDString *S) {
return !S || !S->getString().empty(); return !S || !S->getString().empty();
} }
#endif // #endif
dwarf::Tag GenericDINode::getTag() const { return (dwarf::Tag)SubclassData16; } dwarf::Tag GenericDINode::getTag() const { return (dwarf::Tag)SubclassData16; }
GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag, GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,

View File

@ -465,7 +465,7 @@ void Value::assertModuleIsMaterializedImpl() const {
#endif #endif
} }
#ifndef NDEBUG // #ifndef NDEBUG
static bool contains(SmallPtrSetImpl<ConstantExpr *> &Cache, ConstantExpr *Expr, static bool contains(SmallPtrSetImpl<ConstantExpr *> &Cache, ConstantExpr *Expr,
Constant *C) { Constant *C) {
if (!Cache.insert(Expr).second) if (!Cache.insert(Expr).second)
@ -498,7 +498,7 @@ static bool contains(Value *Expr, Value *V) {
SmallPtrSet<ConstantExpr *, 4> Cache; SmallPtrSet<ConstantExpr *, 4> Cache;
return contains(Cache, CE, C); return contains(Cache, CE, C);
} }
#endif // NDEBUG // #endif // NDEBUG
void Value::doRAUW(Value *New, ReplaceMetadataUses ReplaceMetaUses) { void Value::doRAUW(Value *New, ReplaceMetadataUses ReplaceMetaUses) {
assert(New && "Value::replaceAllUsesWith(<null>) is invalid!"); assert(New && "Value::replaceAllUsesWith(<null>) is invalid!");
@ -827,7 +827,7 @@ bool Value::canBeFreed() const {
// which is why we need the explicit opt in on a per collector basis. // which is why we need the explicit opt in on a per collector basis.
if (!F->hasGC()) if (!F->hasGC())
return true; return true;
const auto &GCName = F->getGC(); const auto &GCName = F->getGC();
if (GCName == "statepoint-example") { if (GCName == "statepoint-example") {
auto *PT = cast<PointerType>(this->getType()); auto *PT = cast<PointerType>(this->getType());

View File

@ -37,6 +37,10 @@ if(LLVM_ENABLE_ZSTD)
list(APPEND imported_libs ${zstd_target}) list(APPEND imported_libs ${zstd_target})
endif() endif()
if (CMAKE_SYSTEM_NAME STREQUAL "yggdrasil")
set(system_libs ${system_libs} m)
endif()
if( WIN32 ) if( WIN32 )
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc. # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc. # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.

View File

@ -15,7 +15,7 @@
#include "llvm/Config/llvm-config.h" #include "llvm/Config/llvm-config.h"
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/COM.inc" #include "Unix/COM.inc"
#elif defined(_WIN32) #elif defined(_WIN32)
#include "Windows/COM.inc" #include "Windows/COM.inc"

View File

@ -26,7 +26,7 @@ static inline struct tm getStructTM(TimePoint<> TP) {
struct tm Storage; struct tm Storage;
std::time_t OurTime = toTimeT(TP); std::time_t OurTime = toTimeT(TP);
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
struct tm *LT = ::localtime_r(&OurTime, &Storage); struct tm *LT = ::localtime_r(&OurTime, &Storage);
assert(LT); assert(LT);
(void)LT; (void)LT;
@ -44,7 +44,7 @@ static inline struct tm getStructTMUtc(UtcTime<> TP) {
struct tm Storage; struct tm Storage;
std::time_t OurTime = toTimeT(TP); std::time_t OurTime = toTimeT(TP);
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
struct tm *LT = ::gmtime_r(&OurTime, &Storage); struct tm *LT = ::gmtime_r(&OurTime, &Storage);
assert(LT); assert(LT);
(void)LT; (void)LT;

View File

@ -344,8 +344,16 @@ static void uninstallExceptionOrSignalHandlers() {
#include <signal.h> #include <signal.h>
static const int Signals[] = static const int Signals[] = {
{ SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV, SIGTRAP }; SIGABRT,
SIGBUS,
SIGFPE,
#if !defined(__yggdrasil__)
SIGILL,
#endif
SIGSEGV,
SIGTRAP
};
static const unsigned NumSignals = std::size(Signals); static const unsigned NumSignals = std::size(Signals);
static struct sigaction PrevActions[NumSignals]; static struct sigaction PrevActions[NumSignals];
@ -372,10 +380,12 @@ static void CrashRecoverySignalHandler(int Signal) {
} }
// Unblock the signal we received. // Unblock the signal we received.
#if !defined(__yggdrasil__)
sigset_t SigMask; sigset_t SigMask;
sigemptyset(&SigMask); sigemptyset(&SigMask);
sigaddset(&SigMask, Signal); sigaddset(&SigMask, Signal);
sigprocmask(SIG_UNBLOCK, &SigMask, nullptr); sigprocmask(SIG_UNBLOCK, &SigMask, nullptr);
#endif
// Return the same error code as if the program crashed, as mentioned in the // Return the same error code as if the program crashed, as mentioned in the
// section "Exit Status for Commands": // section "Exit Status for Commands":
@ -383,8 +393,10 @@ static void CrashRecoverySignalHandler(int Signal) {
int RetCode = 128 + Signal; int RetCode = 128 + Signal;
// Don't consider a broken pipe as a crash (see clang/lib/Driver/Driver.cpp) // Don't consider a broken pipe as a crash (see clang/lib/Driver/Driver.cpp)
#if !defined(__yggdrasil__)
if (Signal == SIGPIPE) if (Signal == SIGPIPE)
RetCode = EX_IOERR; RetCode = EX_IOERR;
#endif
if (CRCI) if (CRCI)
const_cast<CrashRecoveryContextImpl *>(CRCI)->HandleCrash(RetCode, Signal); const_cast<CrashRecoveryContextImpl *>(CRCI)->HandleCrash(RetCode, Signal);

View File

@ -19,7 +19,7 @@
#endif // ifndef NDEBUG #endif // ifndef NDEBUG
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Memory.inc" #include "Unix/Memory.inc"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32

View File

@ -1196,7 +1196,7 @@ Error readNativeFileToEOF(file_t FileHandle, SmallVectorImpl<char> &Buffer,
} // end namespace llvm } // end namespace llvm
// Include the truly platform-specific parts. // Include the truly platform-specific parts.
#if defined(LLVM_ON_UNIX) #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Path.inc" #include "Unix/Path.inc"
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)

View File

@ -119,7 +119,7 @@ bool Process::AreCoreFilesPrevented() { return coreFilesPrevented; }
} }
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Process.inc" #include "Unix/Process.inc"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32

View File

@ -100,7 +100,7 @@ void sys::printArg(raw_ostream &OS, StringRef Arg, bool Quote) {
} }
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Program.inc" #include "Unix/Program.inc"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32

View File

@ -273,7 +273,7 @@ static bool printMarkupStackTrace(StringRef Argv0, void **StackTrace, int Depth,
} }
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Signals.inc" #include "Unix/Signals.inc"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32

View File

@ -158,8 +158,10 @@ void StdThreadPool::wait(ThreadPoolTaskGroup &Group) {
return; return;
} }
// Make sure to not deadlock waiting for oneself. // Make sure to not deadlock waiting for oneself.
#ifndef NDEBUG
assert(CurrentThreadTaskGroups == nullptr || assert(CurrentThreadTaskGroups == nullptr ||
!llvm::is_contained(*CurrentThreadTaskGroups, &Group)); !llvm::is_contained(*CurrentThreadTaskGroups, &Group));
#endif
// Handle the case of recursive call from another task in a different group, // Handle the case of recursive call from another task in a different group,
// in which case process tasks while waiting to keep the thread busy and avoid // in which case process tasks while waiting to keep the thread busy and avoid
// possible deadlock. // possible deadlock.

View File

@ -65,7 +65,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
} }
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Threading.inc" #include "Unix/Threading.inc"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32

View File

@ -112,7 +112,7 @@ typedef uint_t uint;
#endif #endif
#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \ #if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
defined(__MVS__) defined(__MVS__) || defined(__yggdrasil__)
#define STATVFS_F_FLAG(vfs) (vfs).f_flag #define STATVFS_F_FLAG(vfs) (vfs).f_flag
#else #else
#define STATVFS_F_FLAG(vfs) (vfs).f_flags #define STATVFS_F_FLAG(vfs) (vfs).f_flags
@ -505,6 +505,9 @@ static bool is_local_impl(struct STATVFS &Vfs) {
#elif defined(__Fuchsia__) #elif defined(__Fuchsia__)
// Fuchsia doesn't yet support remote filesystem mounts. // Fuchsia doesn't yet support remote filesystem mounts.
return true; return true;
#elif defined(__yggdrasil__)
// Yggdrasil doesn't yet support remote filesystem mounts.
return true;
#elif defined(__EMSCRIPTEN__) #elif defined(__EMSCRIPTEN__)
// Emscripten doesn't currently support remote filesystem mounts. // Emscripten doesn't currently support remote filesystem mounts.
return true; return true;

View File

@ -92,7 +92,9 @@ Expected<unsigned> Process::getPageSize() {
} }
size_t Process::GetMallocUsage() { size_t Process::GetMallocUsage() {
#if defined(HAVE_MALLINFO2) #if defined(__yggdrasil__)
return 1;
#elif defined(HAVE_MALLINFO2)
struct mallinfo2 mi; struct mallinfo2 mi;
mi = ::mallinfo2(); mi = ::mallinfo2();
return mi.uordblks; return mi.uordblks;

View File

@ -426,7 +426,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
// Parent process: Wait for the child process to terminate. // Parent process: Wait for the child process to terminate.
int status = 0; int status = 0;
ProcessInfo WaitResult; ProcessInfo WaitResult;
#ifndef __Fuchsia__ #if !defined(__Fuchsia__)
rusage Info; rusage Info;
if (ProcStat) if (ProcStat)
ProcStat->reset(); ProcStat->reset();
@ -473,7 +473,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
sigaction(SIGALRM, &Old, nullptr); sigaction(SIGALRM, &Old, nullptr);
} }
#ifndef __Fuchsia__ #if !defined(__Fuchsia__) && !defined(__yggdrasil__)
if (ProcStat) { if (ProcStat) {
std::chrono::microseconds UserT = toDuration(Info.ru_utime); std::chrono::microseconds UserT = toDuration(Info.ru_utime);
std::chrono::microseconds KernelT = toDuration(Info.ru_stime); std::chrono::microseconds KernelT = toDuration(Info.ru_stime);

View File

@ -213,7 +213,10 @@ static const int IntSigs[] = {SIGHUP, SIGINT, SIGTERM, SIGUSR2};
/// Signals that represent that we have a bug, and our prompt termination has /// Signals that represent that we have a bug, and our prompt termination has
/// been ordered. /// been ordered.
static const int KillSigs[] = {SIGILL, static const int KillSigs[] = {
#if !defined(__yggdrasil__)
SIGILL,
#endif
SIGTRAP, SIGTRAP,
SIGABRT, SIGABRT,
SIGFPE, SIGFPE,
@ -437,7 +440,11 @@ void llvm::sys::SetOneShotPipeSignalFunction(void (*Handler)()) {
void llvm::sys::DefaultOneShotPipeSignalHandler() { void llvm::sys::DefaultOneShotPipeSignalHandler() {
// Send a special return code that drivers can check for, from sysexits.h. // Send a special return code that drivers can check for, from sysexits.h.
#if defined(__yggdrasil__)
exit(-1);
#else
exit(EX_IOERR); exit(EX_IOERR);
#endif
} }
// The public API // The public API

View File

@ -2323,9 +2323,11 @@ RedirectingFileSystem::lookupPathImpl(
sys::path::const_iterator Start, sys::path::const_iterator End, sys::path::const_iterator Start, sys::path::const_iterator End,
RedirectingFileSystem::Entry *From, RedirectingFileSystem::Entry *From,
llvm::SmallVectorImpl<Entry *> &Entries) const { llvm::SmallVectorImpl<Entry *> &Entries) const {
#ifndef NDEBUG
assert(!isTraversalComponent(*Start) && assert(!isTraversalComponent(*Start) &&
!isTraversalComponent(From->getName()) && !isTraversalComponent(From->getName()) &&
"Paths should not contain traversal components"); "Paths should not contain traversal components");
#endif
StringRef FromName = From->getName(); StringRef FromName = From->getName();
@ -2725,7 +2727,9 @@ void YAMLVFSWriter::addEntry(StringRef VirtualPath, StringRef RealPath,
bool IsDirectory) { bool IsDirectory) {
assert(sys::path::is_absolute(VirtualPath) && "virtual path not absolute"); assert(sys::path::is_absolute(VirtualPath) && "virtual path not absolute");
assert(sys::path::is_absolute(RealPath) && "real path not absolute"); assert(sys::path::is_absolute(RealPath) && "real path not absolute");
#ifndef NDEBUG
assert(!pathHasTraversal(VirtualPath) && "path traversal is not supported"); assert(!pathHasTraversal(VirtualPath) && "path traversal is not supported");
#endif
Mappings.emplace_back(VirtualPath, RealPath, IsDirectory); Mappings.emplace_back(VirtualPath, RealPath, IsDirectory);
} }

View File

@ -14,7 +14,7 @@
#include "llvm/Config/llvm-config.h" #include "llvm/Config/llvm-config.h"
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Watchdog.inc" #include "Unix/Watchdog.inc"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32

View File

@ -11,6 +11,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#if !defined(__yggdrasil__)
#include "llvm/Support/raw_socket_stream.h" #include "llvm/Support/raw_socket_stream.h"
#include "llvm/Config/config.h" #include "llvm/Config/config.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
@ -339,3 +341,5 @@ ssize_t raw_socket_stream::read(char *Ptr, size_t Size,
} }
return raw_fd_stream::read(Ptr, Size); return raw_fd_stream::read(Ptr, Size);
} }
#endif // defined(__yggdrasil__)

View File

@ -120,8 +120,8 @@ static char *pchar(int);
#define SP(t, s, c) print(m, t, s, c, stdout) #define SP(t, s, c) print(m, t, s, c, stdout)
#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) #define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
#define NOTE(str) { if (m->eflags&REG_TRACE) (void)printf("=%s\n", (str)); } #define NOTE(str) { if (m->eflags&REG_TRACE) (void)printf("=%s\n", (str)); }
static int nope = 0;
#else #else
static int nope = 0;
#define SP(t, s, c) /* nothing */ #define SP(t, s, c) /* nothing */
#define AT(t, p1, p2, s1, s2) /* nothing */ #define AT(t, p1, p2, s1, s2) /* nothing */
#define NOTE(s) /* nothing */ #define NOTE(s) /* nothing */
@ -1047,7 +1047,7 @@ print(struct match *m, const char *caption, states st, int ch, FILE *d)
(void)fprintf(d, "\n"); (void)fprintf(d, "\n");
} }
/* /*
- at - print current situation - at - print current situation
*/ */
static void static void

View File

@ -23,7 +23,7 @@
#include <string.h> #include <string.h>
// Include the platform-specific parts of this class. // Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX #if defined(LLVM_ON_UNIX) || defined(__yggdrasil__)
#include "Unix/Host.inc" #include "Unix/Host.inc"
#include <sched.h> #include <sched.h>
#endif #endif

View File

@ -292,6 +292,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case RTEMS: return "rtems"; case RTEMS: return "rtems";
case Solaris: return "solaris"; case Solaris: return "solaris";
case Serenity: return "serenity"; case Serenity: return "serenity";
case Yggdrasil: return "yggdrasil";
case TvOS: return "tvos"; case TvOS: return "tvos";
case UEFI: return "uefi"; case UEFI: return "uefi";
case WASI: return "wasi"; case WASI: return "wasi";
@ -686,6 +687,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("shadermodel", Triple::ShaderModel) .StartsWith("shadermodel", Triple::ShaderModel)
.StartsWith("liteos", Triple::LiteOS) .StartsWith("liteos", Triple::LiteOS)
.StartsWith("serenity", Triple::Serenity) .StartsWith("serenity", Triple::Serenity)
.StartsWith("yggdrasil", Triple::Yggdrasil)
.StartsWith("vulkan", Triple::Vulkan) .StartsWith("vulkan", Triple::Vulkan)
.Default(Triple::UnknownOS); .Default(Triple::UnknownOS);
} }