Skip to content

Reland [mlir] Workaround for export lib generation on Windows for mlir_arm_sme_abi_stubs #73147 #73238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions mlir/lib/ExecutionEngine/ArmSMEStubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
#include <cstdint>
#include <iostream>

#if (defined(_WIN32) || defined(__CYGWIN__))
#ifndef MLIR_ARMSMEABISTUBS_EXPORTED
#ifdef mlir_arm_sme_abi_stubs_EXPORTS
// We are building this library
#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllexport)
#else
// We are using this library
#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllimport)
#endif // mlir_arm_sme_abi_stubs_EXPORTS
#endif // MLIR_ARMSMEABISTUBS_EXPORTED
#else
#define MLIR_ARMSMEABISTUBS_EXPORTED \
__attribute__((visibility("default"))) LLVM_ATTRIBUTE_WEAK
#endif // (defined(_WIN32) || defined(__CYGWIN__))

// The actual implementation of these routines is in:
// compiler-rt/lib/builtins/aarch64/sme-abi.S. These stubs allow the current
// ArmSME tests to run without depending on compiler-rt. This works as we don't
Expand All @@ -19,7 +34,7 @@

extern "C" {

bool LLVM_ATTRIBUTE_WEAK __aarch64_sme_accessible() {
bool MLIR_ARMSMEABISTUBS_EXPORTED __aarch64_sme_accessible() {
// The ArmSME tests are run within an emulator so we assume SME is available.
return true;
}
Expand All @@ -29,20 +44,20 @@ struct sme_state {
int64_t x1;
};

sme_state LLVM_ATTRIBUTE_WEAK __arm_sme_state() {
sme_state MLIR_ARMSMEABISTUBS_EXPORTED __arm_sme_state() {
std::cerr << "[warning] __arm_sme_state() stubbed!\n";
return sme_state{};
}

void LLVM_ATTRIBUTE_WEAK __arm_tpidr2_restore() {
void MLIR_ARMSMEABISTUBS_EXPORTED __arm_tpidr2_restore() {
std::cerr << "[warning] __arm_tpidr2_restore() stubbed!\n";
}

void LLVM_ATTRIBUTE_WEAK __arm_tpidr2_save() {
void MLIR_ARMSMEABISTUBS_EXPORTED __arm_tpidr2_save() {
std::cerr << "[warning] __arm_tpidr2_save() stubbed!\n";
}

void LLVM_ATTRIBUTE_WEAK __arm_za_disable() {
void MLIR_ARMSMEABISTUBS_EXPORTED __arm_za_disable() {
std::cerr << "[warning] __arm_za_disable() stubbed!\n";
}
}
1 change: 1 addition & 0 deletions mlir/lib/ExecutionEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ if(LLVM_ENABLE_PIC)
add_mlir_library(mlir_arm_sme_abi_stubs
SHARED
ArmSMEStubs.cpp)
target_compile_definitions(mlir_arm_sme_abi_stubs PRIVATE mlir_arm_sme_abi_stubs_EXPORTS)

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