2026年1月15日 21:53:21 (+09:00) で、Takashi Yano via Cygwin さんが書きました:
> I have just uploaded libcxx, compiler-rt, and libunwind packages.
> However, you cannot use them with -stdlib=libc++, -rtlib=compiler-rt,
> and -unwindlib=libunwind. This is because clang package has incomplete
> cygwin driver.
>
> You can link them to, for example hello.cc, with:
> clang++ -stdlib=libc++ -isystem /usr/include/c++/v1 hello.cc -lc++ $(clang
> --print-resource-dir)/lib/cygwin/libclang_rt.builtins-x86_64.a -lunwind
>
> The resulted a.exe will be free from libgcc_s. Please try.
>
Using compiler-rt instead of libgcc_s requires extra attention in Cygwin,
because the emulated TLS functionality implemented in compiler-rt can't
share the storage across DLL boundaries.
Particularly, LLVM itself isn't compatible with compiler-rt in an emulated
TLS environment; it exposes thread_local variables directly.
Reproducers (with 21.x packages):
---------- emutlstest.cc ----------
#include <thread>
#include <stdio.h>
extern thread_local int g_tls;
int *get_var();
#ifdef DLL
thread_local int g_tls = 3;
int *get_var() { return &g_tls; }
#endif
#ifdef EXE
void f() {
void *exe = &g_tls;
void *dll = get_var();
printf("%d %p %p\n", exe == dll, exe, dll);
}
int main() {
f();
std::thread(f).join();
}
#endif
--------------------
libstdc++/libgcc_s case:
$ clang++ emutlstest.cc -o emudll.dll -DDLL=1 -shared && clang++ emutlstest.cc
-o emuexe.exe -DEXE=1 emudll.dll && ./emuexe.exe
1 0xa000004c8 0xa000004c8
1 0xa00026958 0xa00026958
libstdc++/compiler-rt case:
$ clang++ -unwindlib=libunwind -rtlib=compiler-rt emutlstest.cc -o emudll.dll
-DDLL=1 -shared && clang++ -unwindlib=libunwind -rtlib=compiler-rt
emutlstest.cc -o emuexe.exe -DEXE=1 emudll.dll && ./emuexe.exe
0 0xa000004c8 0xa000004e8
0 0xa000268f8 0xa000269a8
libc++/compiler-rt case:
$ clang++ -stdlib=libc++ -unwindlib=libunwind -rtlib=compiler-rt emutlstest.cc
-o emudll.dll -DDLL=1 -shared && clang++ -stdlib=libc++ -unwindlib=libunwind
-rtlib=compiler-rt emutlstest.cc -o emuexe.exe -DEXE=1 emudll.dll &&
./emuexe.exe
0 0xa000004c8 0xa000004e8
0 0xa00010a18 0xa00010ac8
just using libc++ case:
$ clang++ -stdlib=libc++ emutlstest.cc -o emudll.dll -DDLL=1 -shared && clang++
-stdlib=libc++ emutlstest.cc -o emuexe.exe -DEXE=1 emudll.dll && ./emuexe.exe
1 0xa000004c8 0xa000004c8
1 0xa00010a78 0xa00010a78
link to a libgcc_s-ed DLL case:
$ clang++ emutlstest.cc -o emudll.dll -DDLL=1 -shared && clang++ -stdlib=libc++
-unwindlib=libunwind -rtlib=compiler-rt emutlstest.cc -o emuexe.exe -DEXE=1
emudll.dll && ./emuexe.exe
0 0xa000004c8 0xa000004e8
0 0xa00010aa8 0xa00010be8
using a compiler-rt-ed DLL case:
$ clang++ -stdlib=libc++ -unwindlib=libunwind -rtlib=compiler-rt emutlstest.cc
-o emudll.dll -DDLL=1 -shared && clang++ emutlstest.cc -o emuexe.exe -DEXE=1
emudll.dll && ./emuexe.exe
0 0xa000004c8 0xa000004e8
0 0xa00026a18 0xa00026ac8
--
Tomohiro Kashiwada (@kikairoya)
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple