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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
// 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 <windows.h>
#include <process.h>
fprintf(stderr, "runtime: failed to create new OS thread (%d)\n", errno);
abort();
}
+
+#endif // __CYGWIN__
\ No newline at end of file