Skip to content

Commit 0bda20b

Browse files
authored
Reland [mlir] Workaround for export lib generation on Windows for mlir_arm_sme_abi_stubs #73147 (#73238)
#73147 Fixed the visibility macro
1 parent c50972d commit 0bda20b

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

mlir/lib/ExecutionEngine/ArmSMEStubs.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010
#include <cstdint>
1111
#include <iostream>
1212

13+
#if (defined(_WIN32) || defined(__CYGWIN__))
14+
#ifndef MLIR_ARMSMEABISTUBS_EXPORTED
15+
#ifdef mlir_arm_sme_abi_stubs_EXPORTS
16+
// We are building this library
17+
#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllexport)
18+
#else
19+
// We are using this library
20+
#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllimport)
21+
#endif // mlir_arm_sme_abi_stubs_EXPORTS
22+
#endif // MLIR_ARMSMEABISTUBS_EXPORTED
23+
#else
24+
#define MLIR_ARMSMEABISTUBS_EXPORTED \
25+
__attribute__((visibility("default"))) LLVM_ATTRIBUTE_WEAK
26+
#endif // (defined(_WIN32) || defined(__CYGWIN__))
27+
1328
// The actual implementation of these routines is in:
1429
// compiler-rt/lib/builtins/aarch64/sme-abi.S. These stubs allow the current
1530
// ArmSME tests to run without depending on compiler-rt. This works as we don't
@@ -19,7 +34,7 @@
1934

2035
extern "C" {
2136

22-
bool LLVM_ATTRIBUTE_WEAK __aarch64_sme_accessible() {
37+
bool MLIR_ARMSMEABISTUBS_EXPORTED __aarch64_sme_accessible() {
2338
// The ArmSME tests are run within an emulator so we assume SME is available.
2439
return true;
2540
}
@@ -29,20 +44,20 @@ struct sme_state {
2944
int64_t x1;
3045
};
3146

32-
sme_state LLVM_ATTRIBUTE_WEAK __arm_sme_state() {
47+
sme_state MLIR_ARMSMEABISTUBS_EXPORTED __arm_sme_state() {
3348
std::cerr << "[warning] __arm_sme_state() stubbed!\n";
3449
return sme_state{};
3550
}
3651

37-
void LLVM_ATTRIBUTE_WEAK __arm_tpidr2_restore() {
52+
void MLIR_ARMSMEABISTUBS_EXPORTED __arm_tpidr2_restore() {
3853
std::cerr << "[warning] __arm_tpidr2_restore() stubbed!\n";
3954
}
4055

41-
void LLVM_ATTRIBUTE_WEAK __arm_tpidr2_save() {
56+
void MLIR_ARMSMEABISTUBS_EXPORTED __arm_tpidr2_save() {
4257
std::cerr << "[warning] __arm_tpidr2_save() stubbed!\n";
4358
}
4459

45-
void LLVM_ATTRIBUTE_WEAK __arm_za_disable() {
60+
void MLIR_ARMSMEABISTUBS_EXPORTED __arm_za_disable() {
4661
std::cerr << "[warning] __arm_za_disable() stubbed!\n";
4762
}
4863
}

mlir/lib/ExecutionEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ if(LLVM_ENABLE_PIC)
181181
add_mlir_library(mlir_arm_sme_abi_stubs
182182
SHARED
183183
ArmSMEStubs.cpp)
184+
target_compile_definitions(mlir_arm_sme_abi_stubs PRIVATE mlir_arm_sme_abi_stubs_EXPORTS)
184185

185186
if(MLIR_ENABLE_CUDA_RUNNER)
186187
# Configure CUDA support. Using check_language first allows us to give a

0 commit comments

Comments
 (0)