alnyan/yggdrasil: aarch64 support, port libc++ and compiler-rt
This commit is contained in:
parent
cb0aaa45f9
commit
3f35eed2c5
@ -142,6 +142,8 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
|
||||
return std::make_unique<DarwinAArch64TargetInfo>(Triple, Opts);
|
||||
|
||||
switch (os) {
|
||||
case llvm::Triple::Yggdrasil:
|
||||
return std::make_unique<YggdrasilTargetInfo<AArch64leTargetInfo>>(Triple, Opts);
|
||||
case llvm::Triple::FreeBSD:
|
||||
return std::make_unique<FreeBSDTargetInfo<AArch64leTargetInfo>>(Triple,
|
||||
Opts);
|
||||
|
@ -885,6 +885,7 @@ protected:
|
||||
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
|
||||
MacroBuilder &Builder) const override {
|
||||
Builder.defineMacro("__yggdrasil__");
|
||||
Builder.defineMacro("__FLOAT128__");
|
||||
this->PlatformName = "yggdrasil";
|
||||
}
|
||||
public:
|
||||
@ -892,6 +893,7 @@ public:
|
||||
: OSTargetInfo<Target>(Triple, Opts) {
|
||||
this->WIntType = TargetInfo::UnsignedInt;
|
||||
this->MCountName = "__mcount";
|
||||
this->HasFloat128 = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -50,6 +50,8 @@ void yggdrasil::Linker::ConstructJob(
|
||||
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)) {
|
||||
@ -102,19 +104,19 @@ void yggdrasil::Linker::ConstructJob(
|
||||
// }
|
||||
|
||||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
|
||||
// if (D.CCCIsCXX()) {
|
||||
// if (ToolChain.ShouldLinkCXXStdlib(Args)) {
|
||||
// ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
|
||||
// CmdArgs.push_back("-lm");
|
||||
// CmdArgs.push_back("-lpthread");
|
||||
// }
|
||||
// }
|
||||
|
||||
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);
|
||||
@ -141,29 +143,44 @@ Yggdrasil::Yggdrasil(
|
||||
|
||||
std::string Yggdrasil::ComputeEffectiveClangTriple(const ArgList &Args,
|
||||
types::ID InputType) const {
|
||||
llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
|
||||
return Triple.str();
|
||||
llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
|
||||
return Triple.str();
|
||||
}
|
||||
|
||||
Tool *Yggdrasil::buildLinker() const {
|
||||
return new tools::yggdrasil::Linker(*this);
|
||||
return new tools::yggdrasil::Linker(*this);
|
||||
}
|
||||
|
||||
ToolChain::RuntimeLibType Yggdrasil::GetRuntimeLibType(const ArgList &Args) const {
|
||||
return ToolChain::RLT_CompilerRT;
|
||||
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;
|
||||
return ToolChain::UNW_None;
|
||||
}
|
||||
|
||||
ToolChain::CXXStdlibType Yggdrasil::GetCXXStdlibType(const ArgList &Args) const {
|
||||
return ToolChain::CST_Libcxx;
|
||||
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) {
|
||||
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");
|
||||
|
@ -38,14 +38,11 @@ public:
|
||||
bool IsIntegratedAssemblerDefault() const override { return true; }
|
||||
bool IsMathErrnoDefault() const override { return false; }
|
||||
bool useRelaxRelocations() const override { return true; }
|
||||
RuntimeLibType GetDefaultRuntimeLibType() const override {
|
||||
return ToolChain::RLT_CompilerRT;
|
||||
}
|
||||
CXXStdlibType GetDefaultCXXStdlibType() const override {
|
||||
return ToolChain::CST_Libcxx;
|
||||
}
|
||||
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 false;
|
||||
return true;
|
||||
}
|
||||
llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const override {
|
||||
return llvm::ExceptionHandling::DwarfCFI;
|
||||
|
@ -1157,8 +1157,11 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
|
||||
unsigned Vendor;
|
||||
unsigned Model, Family;
|
||||
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(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, "");
|
||||
#endif
|
||||
|
||||
// This function needs to run just once.
|
||||
if (__cpu_model.__cpu_vendor)
|
||||
|
@ -314,7 +314,7 @@ public:
|
||||
# else
|
||||
static const mask __regex_word = 1 << 10;
|
||||
# endif // defined(__BIONIC__)
|
||||
#elif defined(__GLIBC__)
|
||||
#elif defined(__GLIBC__) || defined(__yggdrasil__)
|
||||
typedef unsigned short mask;
|
||||
static const mask space = _ISspace;
|
||||
static const mask print = _ISprint;
|
||||
@ -326,7 +326,7 @@ public:
|
||||
static const mask punct = _ISpunct;
|
||||
static const mask xdigit = _ISxdigit;
|
||||
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));
|
||||
# else
|
||||
static const mask __regex_word = 0x80;
|
||||
|
@ -244,7 +244,11 @@ _LIBCPP_PUSH_MACROS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(__yggdrasil__)
|
||||
typedef ssize_t streamsize;
|
||||
#else
|
||||
typedef ptrdiff_t streamsize;
|
||||
#endif
|
||||
|
||||
class _LIBCPP_EXPORTED_FROM_ABI ios_base {
|
||||
public:
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
// Baseline is just a timed backoff
|
||||
|
@ -985,7 +985,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {
|
||||
return _LIBCPP_GET_C_LOCALE->__ctype_b;
|
||||
# elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
return __pctype_func();
|
||||
# elif defined(__EMSCRIPTEN__)
|
||||
# elif defined(__EMSCRIPTEN__) || defined(__yggdrasil__)
|
||||
return *__ctype_b_loc();
|
||||
# elif defined(_NEWLIB_VERSION)
|
||||
// Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1].
|
||||
|
@ -217,7 +217,7 @@ elseif(FUCHSIA OR UNIX)
|
||||
else()
|
||||
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
|
||||
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_UNIX 0)
|
||||
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user