llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.82k stars 11.91k forks source link

[C++20] [Modules] Clang does not implement strong ownership model when targeting MSVC ABI #89781

Open huangqinjin opened 6 months ago

huangqinjin commented 6 months ago

hello.cppm

export module hello;
export void greeting() {}

MSVC

> cl /std:c++20 /TP /interface /c hello.cppm
> dumpbin /symbols hello.obj | findstr greeting
009 00000000 SECT3  notype ()    External     | ?greeting@@YAXXZ::<!hello> (void __cdecl greeting(void))

Clang MSVC ABI

> clang --target=x86_64-windows-msvc -std=c++20 -c hello.cppm
> dumpbin /symbols hello.o | findstr greeting
00B 00000000 SECT1  notype ()    External     | ?greeting@@YAXXZ (void __cdecl greeting(void))

Clang GNU ABI

> clang --target=x86_64-windows-gnu -std=c++20 -c hello.cppm
> dumpbin /symbols hello.o | findstr greeting
00D 00000000 SECT1  notype ()    External     | _ZW5hello8greetingv

The symbol mangling includes the module name for GNU ABI but not for MSVC ABI.

llvmbot commented 6 months ago

@llvm/issue-subscribers-clang-modules

Author: None (huangqinjin)

#### `hello.cppm` ```c++ export module hello; export void greeting() {} ``` #### MSVC ```shell >cl /std:c++20 /TP /interface /c hello.cppm >dumpbin /symbols hello.obj | findstr greeting 009 00000000 SECT3 notype () External | ?greeting@@YAXXZ::<!hello> (void __cdecl greeting(void)) ``` #### Clang MSVC ABI ```shell >clang --target=x86_64-windows-msvc -std=c++20 -c hello.cppm >dumpbin /symbols hello.o | findstr greeting 00B 00000000 SECT1 notype () External | ?greeting@@YAXXZ (void __cdecl greeting(void)) ``` #### Clang GNU ABI ```shell >clang --target=x86_64-windows-gnu -std=c++20 -c hello.cppm >>dumpbin /symbols hello.o | findstr greeting 00D 00000000 SECT1 notype () External | _ZW5hello8greetingv ``` The symbol mangling includes the module name for GNU ABI but not for MSVC ABI.
ChuanqiXu9 commented 6 months ago

This is a known issue but we lack developers on windows : (