[clang] 13078cb - [clang-repl] Skip cross-JIT tests if specified target is not available (#84461)
Stefan Gränitz via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 25 03:51:24 PDT 2024
Author: Stefan Gränitz
Date: 2024-03-25T11:50:21+01:00
New Revision: 13078cbc3eeb0ae91c370ce0f604f7165b26e0c8
URL: https://github.com/llvm/llvm-project/commit/13078cbc3eeb0ae91c370ce0f604f7165b26e0c8
DIFF: https://github.com/llvm/llvm-project/commit/13078cbc3eeb0ae91c370ce0f604f7165b26e0c8.diff
LOG: [clang-repl] Skip cross-JIT tests if specified target is not available (#84461)
Added:
Modified:
clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index 8bc429d9ec2d7d..1ba865a79ed778 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -19,6 +19,7 @@
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
+#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/Threading.h"
@@ -44,14 +45,23 @@ static bool HostSupportsJit() {
return false;
}
+// Some tests require a arm-registered-target
+static bool IsARMTargetRegistered() {
+ llvm::Triple TT;
+ TT.setArch(llvm::Triple::arm);
+ TT.setVendor(llvm::Triple::UnknownVendor);
+ TT.setOS(llvm::Triple::UnknownOS);
+
+ std::string UnusedErr;
+ return llvm::TargetRegistry::lookupTarget(TT.str(), UnusedErr);
+}
+
struct LLVMInitRAII {
LLVMInitRAII() {
- llvm::InitializeNativeTarget();
- llvm::InitializeNativeTargetAsmPrinter();
- LLVMInitializeARMTarget();
- LLVMInitializeARMTargetInfo();
- LLVMInitializeARMTargetMC();
- LLVMInitializeARMAsmPrinter();
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllTargetInfos();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllAsmPrinters();
}
~LLVMInitRAII() { llvm::llvm_shutdown(); }
} LLVMInit;
@@ -190,6 +200,9 @@ TEST(InterpreterExtensionsTest, DISABLED_DefaultCrossJIT) {
#else
TEST(InterpreterExtensionsTest, DefaultCrossJIT) {
#endif
+ if (!IsARMTargetRegistered())
+ GTEST_SKIP();
+
IncrementalCompilerBuilder CB;
CB.SetTargetTriple("armv6-none-eabi");
auto CI = cantFail(CB.CreateCpp());
@@ -204,6 +217,9 @@ TEST(InterpreterExtensionsTest, DISABLED_CustomCrossJIT) {
#else
TEST(InterpreterExtensionsTest, CustomCrossJIT) {
#endif
+ if (!IsARMTargetRegistered())
+ GTEST_SKIP();
+
std::string TargetTriple = "armv6-none-eabi";
IncrementalCompilerBuilder CB;
More information about the cfe-commits
mailing list