Fix some more deprecations with LLVM 16 (#4185)

This commit is contained in:
Nicholas Wilson 2022-09-18 08:00:30 +08:00 committed by GitHub
parent f27b9461b8
commit 19e7024377
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View file

@ -321,14 +321,30 @@ void outputIR2ObjRelevantCmdlineArgs(llvm::raw_ostream &hash_os) {
hash_os << opts::getFeaturesStr();
hash_os << opts::floatABI;
const auto relocModel = opts::getRelocModel();
#if LDC_LLVM_VER >= 1600
if (relocModel.has_value())
hash_os << relocModel.value();
#else
if (relocModel.hasValue())
hash_os << relocModel.getValue();
#endif
const auto codeModel = opts::getCodeModel();
#if LDC_LLVM_VER >= 1600
if (codeModel.has_value())
hash_os << codeModel.value();
#else
if (codeModel.hasValue())
hash_os << codeModel.getValue();
#endif
const auto framePointerUsage = opts::framePointerUsage();
#if LDC_LLVM_VER >= 1600
if (framePointerUsage.has_value())
hash_os << static_cast<int>(framePointerUsage.value());
#else
if (framePointerUsage.hasValue())
hash_os << static_cast<int>(framePointerUsage.getValue());
#endif
}
// Output to `hash_os` all environment flags that influence object code output

View file

@ -426,7 +426,12 @@ createTargetMachine(const std::string targetTriple, const std::string arch,
}
// Handle cases where LLVM picks wrong default relocModel
if (!relocModel.hasValue()) {
#if LDC_LLVM_VER >= 1600
if (relocModel.has_value()) {}
#else
if (relocModel.hasValue()) {}
#endif
else {
if (triple.isOSDarwin()) {
// Darwin defaults to PIC (and as of 10.7.5/LLVM 3.1-3.3, TLS use leads
// to crashes for non-PIC code). LLVM doesn't handle this.