Hi Jeremy,

On Tue, 22 Apr 2025 15:50:52 +0900
Takashi Yano wrote:
> > but it is not worked around by defining the macro.  There should also be a
> > big red warning that, due to the macro being defined, clang++ and g++
> > compiled objects might not be able to link to each other if they try to
> > pass std::strings (or possibly other stl objects) between them.
> 
> Ah, that might be. This probelm may also happen when dll is called from
> the app compiled by g++ if the dll is built with clang++. This is more
> likely to happen.

To avoid this incompatibility, I tried to build llvm/clang without
both 0005-use_cxx11_abi.patch and 0110-use_cxx11_abi.patch, and add
-DCMAKE_CXX_STANDARD=20
instead. It makes llvm/clang be built successfully.

Then, the linkage between objects compiled by g++ and clang++ succeeded.
$ g++ -c b.cc -o b.o
$ clang++ -std=c++14 -c a.cc -o a.o
$ clang++ a.o b.o
$ ./a.exe
Received string: Processed: Hello, World!
$

Without -std=c++14, an error occurs in linking.

I also tested dll like:
$ g++ -shared b.cc -o b.dll
$ clang++ -c a.cc -o a.o
$ clang++ a.o b.dll
$ ./a.exe
Received string: Processed: Hello, World!
$
and it scceeded as well.

Isn't this better than mixed ABI problem, is it?

I'm still not sure why the llvm-min-tblgen.exe crashes, so
there may be still have problems even with this hack.

-- 
Takashi Yano <takashi.y...@nifty.ne.jp>
#include <iostream>
#include <string>

extern std::string processString(const std::string& input);
void displayString(const std::string& str) {
    std::cout << "Received string: " << str << std::endl;
}

int main() {
    std::string originalString = "Hello, World!";
    std::string modifiedString = processString(originalString);
    displayString(modifiedString);

    return 0;
}
#include <string>
std::string processString(const std::string& input) {
    return "Processed: " + input;
}

Reply via email to