Update LLVM in the hope of fixing the lld crash

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
This commit is contained in:
Dimitar Dobrev 2020-11-29 17:34:42 +02:00
Родитель 526be03417
Коммит 30afe2f822
8 изменённых файлов: 30 добавлений и 10 удалений

5
.github/workflows/llvm-win.yml поставляемый
Просмотреть файл

@ -53,6 +53,11 @@ jobs:
shell: bash
run: build/build.sh clone_llvm
working-directory: C:\CppSharp
- name: Patch LLD
shell: powershell
run: build/lld.ps1
working-directory: C:\CppSharp
- name: Build LLVM
shell: bash

Просмотреть файл

@ -125,6 +125,8 @@ clone_llvm()
build_llvm()
{
rm -rf "$builddir/../Directory.Build.props"
rm -rf "$builddir/../Directory.Packages.props"
"$builddir/premake.sh" --file="$builddir/llvm/LLVM.lua" build_llvm --os=$os --arch=$platform --configuration=$configuration
}

11
build/lld.ps1 Normal file
Просмотреть файл

@ -0,0 +1,11 @@
$driver = 'C:\CppSharp\build\llvm\llvm-project\lld\COFF\Driver.cpp'
$patched = $false
if (Test-Path $driver) {
$content = ((Get-Content $driver) -replace 'static void createImportLibrary(bool asLib) {', 'static void createImportLibrary(bool asLib) { return;')
[IO.File]::WriteAllLines($driver, $content)
$patched = $true
}
if (!$patched) {
Write-Warning "This hack is no longer needed and should be removed."
}

Просмотреть файл

@ -1 +1 @@
0c8f9b8099fd0500cd885bc699924e20371014ff
c40cea6f083a8a67ea950e058e16d37bb04e8c4b

Просмотреть файл

@ -260,7 +260,6 @@ function cmake(gen, conf, builddir, options)
.. ' -DLLVM_TOOL_DSYMUTIL_BUILD=false'
.. ' -DLLVM_TOOL_GOLD_BUILD=false'
.. ' -DLLVM_TOOL_LLC_BUILD=false'
.. ' -DLLVM_TOOL_LLD_BUILD=false'
.. ' -DLLVM_TOOL_LLDB_BUILD=false'
.. ' -DLLVM_TOOL_LLGO_BUILD=false'
.. ' -DLLVM_TOOL_LLI_BUILD=false'

Просмотреть файл

@ -79,7 +79,9 @@ void Parser::LinkMSVC(const LinkerOptions* LinkerOptions,
args.push_back(LibraryPath.data());
args.push_back("-dll");
args.push_back("-noentry");
args.push_back("libcmt.lib");
args.push_back("libucrt.lib");
std::vector<std::string> Libraries;
for (const auto& Library : LinkerOptions->Libraries)
@ -93,6 +95,11 @@ void Parser::LinkMSVC(const LinkerOptions* LinkerOptions,
std::string Out("-out:" + std::string(Output));
args.push_back(Out.data());
SmallString<1024> Outputsees(Dir);
sys::path::append(Outputsees, Stem + ".lib");
std::string Outsees("-implib:" + std::string(Outputsees));
args.push_back(Outsees.data());
lld::coff::link(args, false, outs(), errs());
#endif
}

Просмотреть файл

@ -2074,7 +2074,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->hasPlaceholderType = S->hasPlaceholderType();
_S->typeAsWritten = GetQualifiedType(S->getTypeAsWritten());
_S->isListInitialization = S->isListInitialization();
_S->arg_size = S->arg_size();
_S->arg_size = S->getNumArgs();
for (auto _E : S->arguments())
{
auto _ES = WalkExpression(_E);

Просмотреть файл

@ -100,8 +100,6 @@ static CppAbi GetClassLayoutAbi(clang::TargetCXXABI::Kind abi)
return CppAbi::ARM;
case clang::TargetCXXABI::iOS:
return CppAbi::iOS;
case clang::TargetCXXABI::iOS64:
return CppAbi::iOS64;
default:
llvm_unreachable("Unsupported C++ ABI kind");
}
@ -229,8 +227,6 @@ ConvertToClangTargetCXXABI(CppSharp::CppParser::AST::CppAbi abi)
return TargetCXXABI::GenericARM;
case CppSharp::CppParser::AST::CppAbi::iOS:
return TargetCXXABI::iOS;
case CppSharp::CppParser::AST::CppAbi::iOS64:
return TargetCXXABI::iOS64;
}
llvm_unreachable("Unsupported C++ ABI.");
@ -3710,7 +3706,7 @@ AST::ExpressionObsolete* Parser::WalkVariableInitializerExpression(const clang::
return WalkExpressionObsolete(Expr);
clang::Expr::EvalResult result;
if (Expr->EvaluateAsConstantExpr(result, clang::Expr::ConstExprUsage::EvaluateForCodeGen, c->getASTContext(), false))
if (Expr->EvaluateAsConstantExpr(result, c->getASTContext()))
{
std::string s;
llvm::raw_string_ostream out(s);
@ -4423,9 +4419,9 @@ static ArchType ConvertArchType(unsigned int archType)
}
template<class ELFT>
static void ReadELFDependencies(const llvm::object::ELFFile<ELFT>* ELFFile, CppSharp::CppParser::NativeLibrary*& NativeLib)
static void ReadELFDependencies(const llvm::object::ELFFile<ELFT>& ELFFile, CppSharp::CppParser::NativeLibrary*& NativeLib)
{
ELFDumper<ELFT> ELFDumper(ELFFile);
ELFDumper<ELFT> ELFDumper(&ELFFile);
for (const auto& Dependency : ELFDumper.getNeededLibraries())
NativeLib->Dependencies.push_back(Dependency.str());
}