Skip to content

Commit

Permalink
More build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Aug 15, 2023
1 parent 29af763 commit 844063e
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 29 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/llvm-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:
fail-fast: false
matrix:
config:
- { os: windows-2019, platform: x86, vs: "Program Files (x86)/Microsoft Visual Studio/2019" }
- { os: windows-2019, platform: x64, vs: "Program Files (x86)/Microsoft Visual Studio/2019" }
- { os: windows-2022, platform: x86, vs: "Program Files/Microsoft Visual Studio/2022" }
- { os: windows-2022, platform: x64, vs: "Program Files/Microsoft Visual Studio/2022" }

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
config:
- { os: ubuntu-22.04, platform: x64, cxx: g++-11, cc: gcc-11 }
- { os: macos-11, platform: x64, cxx: clang++, cc: clang }
- { os: windows-2019, platform: x64, vs: "Program Files (x86)/Microsoft Visual Studio/2019" }
- { os: windows-2022, platform: x64, vs: "Program Files/Microsoft Visual Studio/2022" }

runs-on: ${{ matrix.config.os }}
Expand Down
6 changes: 5 additions & 1 deletion build/LLVM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function SetupLLVMLibs()
"LLVMPasses",
"LLVMObjCARCOpts",
"LLVMLibDriver",
"LLVMFrontendHLSL",
"LLVMFrontendOpenMP",
"LLVMOption",
"LLVMCoverage",
Expand All @@ -172,6 +173,7 @@ function SetupLLVMLibs()
"LLVMVectorize",
"LLVMLinker",
"LLVMIRReader",
"LLVMIRPrinter",
"LLVMAsmParser",
"LLVMMCDisassembler",
"LLVMCFGuard",
Expand All @@ -181,6 +183,7 @@ function SetupLLVMLibs()
"LLVMDebugInfoDWARF",
"LLVMCodeGen",
"LLVMTarget",
"LLVMTargetParser",
"LLVMScalarOpts",
"LLVMInstCombine",
"LLVMAggressiveInstCombine",
Expand All @@ -204,7 +207,8 @@ function SetupLLVMLibs()
"lldCommon",
"lldCOFF",
"lldELF",
"lldMachO"
"lldMachO",
"lldMinGW"
}

filter(c)
Expand Down
4 changes: 1 addition & 3 deletions build/llvm/LLVM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function package_llvm(conf, llvm_base, llvm_build)
if os.isdir(out) then os.rmdir(out) end
os.mkdir(out)

os.copydir(llvm_base .. "/llvm/include", out .. "/include")
os.copydir(llvm_base .. "/llvm/include", out .. "/llvm/include")
os.copydir(llvm_base .. "/lld/include", out .. "/lld/include")
os.copydir(llvm_build .. "/include", out .. "/build/include")

Expand All @@ -486,12 +486,10 @@ function package_llvm(conf, llvm_base, llvm_build)
local out_lib_dir = out .. "/build/lib"
if os.ishost("windows") then
os.rmfiles(out_lib_dir, "clang*ARC*.lib")
os.rmfiles(out_lib_dir, "clang*Matchers*.lib")
os.rmfiles(out_lib_dir, "clang*Rewrite*.lib")
os.rmfiles(out_lib_dir, "clang*StaticAnalyzer*.lib")
else
os.rmfiles(out_lib_dir, "libclang*ARC*.a")
os.rmfiles(out_lib_dir, "libclang*Matchers*.a")
os.rmfiles(out_lib_dir, "libclang*Rewrite*.a")
os.rmfiles(out_lib_dir, "libclang*StaticAnalyzer*.a")
end
Expand Down
17 changes: 14 additions & 3 deletions src/CppParser/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
#include <Driver/ToolChains/Linux.h>
#include <lld/Common/Driver.h>

LLD_HAS_DRIVER(coff)
LLD_HAS_DRIVER(elf)
LLD_HAS_DRIVER(mingw)
LLD_HAS_DRIVER(macho)

#define LLD_DRIVERS \
{ \
{lld::WinLink, &lld::coff::link}, {lld::Gnu, &lld::elf::link}, \
{lld::MinGW, &lld::mingw::link}, {lld::Darwin, &lld::macho::link} \
}

using namespace CppSharp::CppParser;

bool Parser::Link(const std::string& File, const CppLinkerOptions* LinkerOptions)
Expand Down Expand Up @@ -100,7 +111,7 @@ bool Parser::LinkWindows(const CppLinkerOptions* LinkerOptions,
std::string Out("-out:" + std::string(Output));
args.push_back(Out.data());

return lld::coff::link(args, outs(), errs(), /*exitEarly=*/false, /*disableOutput=*/false);
return lld::lldMain(args, outs(), errs(), LLD_DRIVERS).retCode;
#else
return false;
#endif
Expand Down Expand Up @@ -141,7 +152,7 @@ bool Parser::LinkELF(const CppLinkerOptions* LinkerOptions,
std::string Out(Output);
args.push_back(Out.data());

return lld::elf::link(args, outs(), errs(), /*exitEarly=*/false, /*disableOutput=*/false);
return lld::lldMain(args, outs(), errs(), LLD_DRIVERS).retCode;
#else
return false;
#endif
Expand Down Expand Up @@ -182,7 +193,7 @@ bool Parser::LinkMachO(const CppLinkerOptions* LinkerOptions,
std::string Out(Output);
args.push_back(Out.data());

return lld::macho::link(args, outs(), errs(), /*exitEarly=*/false, /*disableOutput=*/false);
return lld::lldMain(args, outs(), errs(), LLD_DRIVERS).retCode;
#else
return false;
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/CppParser/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->calleeDecl = static_cast<AST::Declaration*>(WalkDeclaration(S->getCalleeDecl()));
_S->directCallee = static_cast<AST::Function*>(WalkDeclaration(S->getDirectCallee()));
_S->numArgs = S->getNumArgs();
_S->numCommas = S->getNumCommas();
_S->numCommas = 0; // Removed from Clang
_S->builtinCallee = S->getBuiltinCallee();
_S->isCallToStdMove = S->isCallToStdMove();
for (auto _E : S->arguments())
Expand Down Expand Up @@ -1172,7 +1172,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->calleeDecl = static_cast<AST::Declaration*>(WalkDeclaration(S->getCalleeDecl()));
_S->directCallee = static_cast<AST::Function*>(WalkDeclaration(S->getDirectCallee()));
_S->numArgs = S->getNumArgs();
_S->numCommas = S->getNumCommas();
_S->numCommas = 0; // Removed from Clang
_S->builtinCallee = S->getBuiltinCallee();
_S->isCallToStdMove = S->isCallToStdMove();
for (auto _E : S->arguments())
Expand Down Expand Up @@ -1207,7 +1207,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->calleeDecl = static_cast<AST::Declaration*>(WalkDeclaration(S->getCalleeDecl()));
_S->directCallee = static_cast<AST::Function*>(WalkDeclaration(S->getDirectCallee()));
_S->numArgs = S->getNumArgs();
_S->numCommas = S->getNumCommas();
_S->numCommas = 0; // Removed from Clang
_S->builtinCallee = S->getBuiltinCallee();
_S->isCallToStdMove = S->isCallToStdMove();
for (auto _E : S->arguments())
Expand Down Expand Up @@ -1241,7 +1241,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->calleeDecl = static_cast<AST::Declaration*>(WalkDeclaration(S->getCalleeDecl()));
_S->directCallee = static_cast<AST::Function*>(WalkDeclaration(S->getDirectCallee()));
_S->numArgs = S->getNumArgs();
_S->numCommas = S->getNumCommas();
_S->numCommas = 0; // Removed from Clang
_S->builtinCallee = S->getBuiltinCallee();
_S->isCallToStdMove = S->isCallToStdMove();
for (auto _E : S->arguments())
Expand Down Expand Up @@ -1391,7 +1391,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->calleeDecl = static_cast<AST::Declaration*>(WalkDeclaration(S->getCalleeDecl()));
_S->directCallee = static_cast<AST::Function*>(WalkDeclaration(S->getDirectCallee()));
_S->numArgs = S->getNumArgs();
_S->numCommas = S->getNumCommas();
_S->numCommas = 0; // Removed from Clang
_S->builtinCallee = S->getBuiltinCallee();
_S->isCallToStdMove = S->isCallToStdMove();
for (auto _E : S->arguments())
Expand Down Expand Up @@ -1850,7 +1850,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->operatorDelete = static_cast<AST::Function*>(WalkDeclaration(S->getOperatorDelete()));
_S->allocatedType = GetQualifiedType(S->getAllocatedType());
_S->isArray = S->isArray();
_S->arraySize = static_cast<AST::Expr*>(WalkExpression(S->getArraySize().getValue()));
_S->arraySize = static_cast<AST::Expr*>(WalkExpression(S->getArraySize().value()));
_S->numPlacementArgs = S->getNumPlacementArgs();
_S->isParenTypeId = S->isParenTypeId();
_S->isGlobalNew = S->isGlobalNew();
Expand Down
22 changes: 9 additions & 13 deletions src/CppParser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
{
auto TO = Type->getAs<clang::TypeOfType>();

Ty = WalkType(TO->getUnderlyingType());
Ty = WalkType(TO->getUnmodifiedType());
break;
}
case clang::Type::TypeOfExpr:
Expand Down Expand Up @@ -2648,8 +2648,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
TSTL = &TSpecTL;
}

ArrayRef<clang::TemplateArgument> TSArgs(TS->getArgs(), TS->getNumArgs());
TemplateArgumentList TArgs(TemplateArgumentList::OnStack, TSArgs);
TemplateArgumentList TArgs(TemplateArgumentList::OnStack, TS->template_arguments());
TST->Arguments = WalkTemplateArgumentList(&TArgs, TSTL);

Ty = TST;
Expand Down Expand Up @@ -2691,8 +2690,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
TSTL = &TSpecTL;
}

ArrayRef<clang::TemplateArgument> TSArgs(TS->getArgs(), TS->getNumArgs());
TemplateArgumentList TArgs(TemplateArgumentList::OnStack, TSArgs);
TemplateArgumentList TArgs(TemplateArgumentList::OnStack, TS->template_arguments());
TST->Arguments = WalkTemplateArgumentList(&TArgs, TSTL);

Ty = TST;
Expand Down Expand Up @@ -2755,9 +2753,9 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
auto RepTy = TP->getReplacementType();
TPT->replacement = GetQualifiedType(RepTy, &Next);
TPT->replacedParameter = (TemplateParameterType*)
WalkType(clang::QualType(TP->getReplacedParameter(), 0), 0);
WalkType(c->getASTContext().getTypeDeclType(TP->getReplacedParameter()), 0);
TPT->replacedParameter->parameter = WalkTypeTemplateParameter(
TP->getReplacedParameter()->getDecl());
TP->getReplacedParameter());

Ty = TPT;
break;
Expand Down Expand Up @@ -4379,10 +4377,8 @@ bool Parser::SetupSourceFiles(const std::vector<std::string>& SourceFiles,
std::vector<const clang::FileEntry*>& FileEntries)
{
// Check that the file is reachable.
clang::ConstSearchDirIterator *Dir;
llvm::SmallVector<
std::pair<const clang::FileEntry *, const clang::DirectoryEntry *>,
0> Includers;
clang::ConstSearchDirIterator *Dir = 0;
llvm::ArrayRef<std::pair<const clang::FileEntry*, clang::DirectoryEntryRef>> Includers;

for (const auto& SourceFile : SourceFiles)
{
Expand Down Expand Up @@ -4896,8 +4892,8 @@ ParserTargetInfo* Parser::GetTargetInfo()
parserTargetInfo->longDoubleWidth = TI.getLongDoubleWidth();
parserTargetInfo->longLongAlign = TI.getLongLongAlign();
parserTargetInfo->longLongWidth = TI.getLongLongWidth();
parserTargetInfo->pointerAlign = TI.getPointerAlign(0);
parserTargetInfo->pointerWidth = TI.getPointerWidth(0);
parserTargetInfo->pointerAlign = TI.getPointerAlign(clang::LangAS::Default);
parserTargetInfo->pointerWidth = TI.getPointerWidth(clang::LangAS::Default);
parserTargetInfo->wCharAlign = TI.getWCharAlign();
parserTargetInfo->wCharWidth = TI.getWCharWidth();
parserTargetInfo->float128Align = TI.getFloat128Align();
Expand Down
1 change: 1 addition & 0 deletions src/CppParser/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ clang_msvc_flags =
"/wd4355", "/wd4996", "/wd4624", "/wd4291",
"/wd4251",
"/wd4141", -- 'inline' : used more than once
"/Zc:preprocessor" -- needed for newer Clang Options.inc (VA_ARGS)
}

if EnableNativeProjects() then
Expand Down

0 comments on commit 844063e

Please sign in to comment.