Skip to content

Commit 3f0b293

Browse files
committed
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 8e71428 commit 3f0b293

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/runtime/cgo/gcc_libinit_windows.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
# ifdef __CYGWIN__
6+
#error "don't use the cygwin compiler to build native Windows programs; use MinGW instead"
7+
#else
8+
// Exclude the following code from Cygwin builds.
9+
// Cygwin doesn't implement process.h nor does it support _beginthread.
10+
511
#define WIN32_LEAN_AND_MEAN
612
#include <windows.h>
713
#include <process.h>
@@ -156,3 +162,5 @@ void _cgo_beginthread(void (*func)(void*), void* arg) {
156162
fprintf(stderr, "runtime: failed to create new OS thread (%d)\n", errno);
157163
abort();
158164
}
165+
166+
#endif // __CYGWIN__

0 commit comments

Comments
 (0)