On Tue, 3 Sep 2019, Martin Storsjö wrote:

On Tue, 3 Sep 2019, Liu Hao wrote:

在 2019/9/3 14:39, Martin Storsjö 写道:
In C++ mode, __mingw_ovr is a plain "inline" without "static".

Clang emits a standalone copy of functions in C++ for the combination
of non-static inline and __gnu_inline__, leading to multiple definitions
of symbols.

Signed-off-by: Martin Storsjö <mar...@martin.st>
 mingw-w64-headers/crt/_mingw_mac.h | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

I understand what happened with clang but... isn't this clang's bug? It
is as expected that a out-of-line definition is emitted because inline
functions have external linkage in C++, which however should be
specified as `.weak` (on Linux etc.) and `.linkonce discard` on Windows.
So I am a bit curious how the multiple definition error could happen.

In this case, it doesn't get emitted as .linkonce discard - I'm not sure exactly what's going on in this combination, whether it's contradicting itself in C++ mode, or if it's just a bug.

I could take it up to try to fix it in clang, but so far, we've managed to avoid inline + gnu_inline in C++ in our headers, so I would appreciate if we could avoid this here as well, to work with contemporary clang versions as well.

For the record, clang has had this behaviour wrt C++ since it got support for gnu_inline in 2009, but it doesn't necessarily seem to be intentional. I sent a patch for it at https://reviews.llvm.org/D67414, let's see how it fares.

Regardless, as long as we want to support contempory versions of clang, we need to avoid gnu_inline used without extern.

// Martin

Mingw-w64-public mailing list

Reply via email to