AMDMIGraphX icon indicating copy to clipboard operation
AMDMIGraphX copied to clipboard

[Issue]: Linker Error: mlir::TypeID symbol redefinition during migraphx_gpu.dll when build MIGraphX with MIOpen on Windows

Open menglcai opened this issue 4 months ago • 0 comments

Problem Description

When building the migraphx_gpu.dll target with MIOpen (develop or develop_deprecated branch) on Windows, the build fails during the linking stage with the following error:

[527/543] Linking CXX shared library bin\migraphx_gpu.dll
FAILED: [code=1] bin/migraphx_gpu.dll lib/migraphx_gpu.lib
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\opt\rocm\bin\clang++.exe -nostartfiles -nostdlib -O2 -DNDEBUG -g -Xclang -gcodeview -D_DLL -D_MT -Xclang --dependent-lib=msvcrt  -fuse-ld=lld-link -shared -o bin\migraphx_gpu.dll  -Xlinker /MANIFEST:EMBED -Xlinker /implib:lib\migraphx_gpu.lib -Xlinker /pdb:bin\migraphx_gpu.pdb -Xlinker /version:0.0 @CMakeFiles\migraphx_gpu.rsp  && cd ."
lld-link: error: protected: static class mlir::TypeID __cdecl mlir::detail::FallbackTypeIDResolver::registerImplicitTypeID(class llvm::StringRef) was replaced
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

This indicates that multiple definitions of the same static symbol (mlir::TypeID) are being pulled into the final DLL.

Removing LLVM_ALWAYS_EXPORT in rocMLIR and rebuild MIOpen/MIGraphX is a workaround to prevent the build error. https://github.com/ROCm/rocMLIR/commit/b4aa673b7a4f8fca19dec32b8d6a00568b245ba3

--- a/external/llvm-project/mlir/include/mlir/Support/TypeID.h
+++ b/external/llvm-project/mlir/include/mlir/Support/TypeID.h
@@ -164,7 +164,7 @@ namespace detail {
 class FallbackTypeIDResolver {
 protected:
   /// Register an implicit type ID for the given type name.
-  LLVM_ALWAYS_EXPORT static TypeID registerImplicitTypeID(StringRef name);
+  static TypeID registerImplicitTypeID(StringRef name);
 };

 template <typename T>
diff --git a/external/llvm-project/mlir/lib/Support/TypeID.cpp b/external/llvm-project/mlir/lib/Support/TypeID.cpp
index 01ad91011301..1ba4f524119d 100644
--- a/external/llvm-project/mlir/lib/Support/TypeID.cpp
+++ b/external/llvm-project/mlir/lib/Support/TypeID.cpp
@@ -80,7 +80,7 @@ struct ImplicitTypeIDRegistry {
 };
 } // end namespace

-LLVM_ALWAYS_EXPORT TypeID
+TypeID
 detail::FallbackTypeIDResolver::registerImplicitTypeID(StringRef name) {
   static ImplicitTypeIDRegistry registry;
   return registry.lookupOrInsert(name);

Operating System

Windows11 (26100.4946)

CPU

AMD Ryzen™ AI Max+ 395

GPU

Other

Other

Radeon 8060S Graphics

ROCm Version

ROCm 6.0.0

Steps to Reproduce

  1. Build rocMLIR (ff95d92) on Windows
  2. Build MIOpen (0697717) with the rocMLIR from step 1 on Windows .
  3. Build MIGraphX (5da1bdd) with the rocMLIR from step 1 on Windows. ---> Build error occurred in migraphx_gpu.dll

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

menglcai avatar Aug 21 '25 10:08 menglcai