Issue 134725
Summary LTO build of rpcs3 fails on Windows
Labels new issue
Assignees
Reporter oltolm
    Hello I use clang 19.1.7 from MSYS2 clang64. Recently https://github.com/RPCS3/rpcs3 has enabled LTO. Now the release build is failing with

```
[build] ld.lld: error: undefined symbol: thread-local initialization routine for perf_stat<19226358023673171ull>::g_tls_perf_stat
[build] >>> referenced by C:/src/rpcs3/rpcs3/Emu/CPU/CPUThread.cpp
[build] >>> librpcs3_emu.a(CPUThread.cpp.obj)
[build] >>> referenced by C:/src/rpcs3/rpcs3/Emu/Memory/vm.cpp
[build] >>> librpcs3_emu.a(vm.cpp.obj)
[build] 
```
I reduced it

`CMakeListsts.txt`

```cmake
cmake_minimum_required(VERSION 3.21)
project(lto VERSION 0.0.1 LANGUAGES C CXX)

add_executable(myexe src/myexe.cpp)
target_compile_features(myexe PRIVATE cxx_std_20)
target_link_options(myexe PRIVATE -municode)

set_property(TARGET myexe PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
```

`myexe.cpp`

```c++
#include "perf_meter.hpp"

int wmain(int argc, wchar_t** argv)
{
    perf_meter<"DMA"_u32> perf_;
 return 0;
}
```

`perf_meter.hpp`

```c++
template <auto ShortName> class perf_stat final {
    static inline thread_local struct perf_stat_local {
        // Local non-atomic values for increments
 unsigned m_log[66]{};

        perf_stat_local() noexcept {}

 ~perf_stat_local() {}

    } g_tls_perf_stat;

  public:
    static void push(unsigned start_time) noexcept { (void)g_tls_perf_stat; }
};

template <auto ShortName, auto... SubEvents> class perf_meter {
  public:
 ~perf_meter() { perf_stat<ShortName>::push(0); }
};

constexpr unsigned operator""_u32(const char* s, unsigned long long /*length*/)
{
    return 0;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to