ROCm / ROCm/AMDMIGraphX

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

Open
#4,252 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
333
Forks
150
Avg merge
4d 19h
Merged PRs (30d)
54

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with external/llvm-project/mlir/include/mlir/Support/TypeID.h and external/llvm-project/mlir/lib/Support/TypeID.cpp, then review the rocMLIR, MIOpen, and MIGraphX Windows build sequence described in the issue. Reproduce the migraphx_gpu.dll link step and verify that the TypeID symbol redefinition is resolved without the workaround remaining necessary.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.