Issue 171548
Summary definition with same mangled name when using c++20 modules, templates and libstdc++
Labels new issue
Assignees
Reporter TroyKomodo
    `main.cpp`
```cxx
import pollcoro;
import helper;

int main() {
 pollcoro::block_on(helper::async(0));
}

```

This fails to compile with the following:

```sh
/nix/store/90lsdrdffwgf3kjd4sdxjchchg44cr02-clang-wrapper-20.1.8/bin/clang++ -O3 -O3 -DNDEBUG -std=c++20 -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT CMakeFiles/thing.dir/src/main.cpp.o -MF CMakeFiles/thing.dir/src/main.cpp.o.d @CMakeFiles/thing.dir/src/main.cpp.o.modmap -o CMakeFiles/thing.dir/src/main.cpp.o -c /home/troy/github/paravision/tmp/src/main.cpp
In module 'pollcoro' imported from /home/troy/github/paravision/tmp/src/main.cpp:8:
In module 'pollcoro:mutex' imported from /home/troy/github/paravision/tmp/build/_deps/pollcoro-src/src/pollcoro.cppm:46:
/nix/store/y28c83zz73yr4vwz1fsl4nsrn6yz5fj0-gcc-14.3.0/include/c++/14.3.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:313:1: error: definition with same mangled name '_ZL18__gthread_active_pv' as another definition
  313 | __gthread_active_p (void)
      | ^
/nix/store/y28c83zz73yr4vwz1fsl4nsrn6yz5fj0-gcc-14.3.0/include/c++/14.3.0/x86_64-unknown-linux-gnu/bits/gthr-default.h:313:1: note: previous definition is here
  313 | __gthread_active_p (void)
      | ^
1 error generated.
ninja: build stopped: subcommand failed.
error: Recipe `build` failed on line 2 with exit code 1
```

`helper.cppm`
```cxx
module;

#include <utility>

export module helper;

import pollcoro;

export namespace helper {
template<typename T>
auto async(T value) {
    auto [awaitable, setter] = pollcoro::single_event<T>();

    setter.set(std::move(value));

 return std::move(awaitable);
}

} // helper
```

`pollcoro` is https://github.com/troyKomodo/pollcoro

The following 2 fix the error:

- adding `#include <thread>` to `main.cpp`
- removing the template on `helper` in `helper.cppm`

Reproducible repo: https://github.com/TroyKomodo/cxx-compiler-bug

Possibly related:
https://github.com/llvm/llvm-project/issues/137533


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to