From: qmuntal Date: Thu, 14 Nov 2024 12:06:55 +0000 (+0100) Subject: runtime/cgo: report a meaningful error message when using Cygwin X-Git-Tag: go1.24rc1~396 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3f0b293e70f8e29865ea5893fd1be97f2d75521a;p=gostls13.git runtime/cgo: report a meaningful error message when using Cygwin Go has never supported Cygwin as a C compiler, but users get the following cryptic error message when they try to use it: implicit declaration of function '_beginthread' This is because Cygwin doesn't implement _beginthread. Note that this is not the only problem with Cygwin, but it's the one that users are most likely to run into first. This CL improves the error message to make it clear that Cygwin is not supported, and suggests using MinGW instead. Fixes #59490 Fixes #36691 Change-Id: Ifeec7a2cb38d7c5f50d6362c95504f72818c6a76 Reviewed-on: https://go-review.googlesource.com/c/go/+/627935 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui --- diff --git a/src/runtime/cgo/gcc_libinit_windows.c b/src/runtime/cgo/gcc_libinit_windows.c index 9a8c65ea29..ddc0ad7010 100644 --- a/src/runtime/cgo/gcc_libinit_windows.c +++ b/src/runtime/cgo/gcc_libinit_windows.c @@ -2,6 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +# ifdef __CYGWIN__ +#error "don't use the cygwin compiler to build native Windows programs; use MinGW instead" +#else +// Exclude the following code from Cygwin builds. +// Cygwin doesn't implement process.h nor does it support _beginthread. + #define WIN32_LEAN_AND_MEAN #include #include @@ -156,3 +162,5 @@ void _cgo_beginthread(void (*func)(void*), void* arg) { fprintf(stderr, "runtime: failed to create new OS thread (%d)\n", errno); abort(); } + +#endif // __CYGWIN__ \ No newline at end of file