From 0b5bcf53ee4af0e244ba1991069741774bf4f164 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Thu, 10 Sep 2015 02:32:12 -0400 Subject: runtime/cgo: explicitly link msvcrt on windows It's because runtime links to ntdll, and ntdll exports a couple incompatible libc functions. We must link to msvcrt first and then try ntdll. Fixes #12030. Change-Id: I0105417bada108da55f5ae4482c2423ac7a92957 Reviewed-on: https://go-review.googlesource.com/14472 Reviewed-by: Alex Brainman Run-TryBot: Minux Ma TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/runtime/cgo/cgo.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/runtime/cgo/cgo.go b/src/runtime/cgo/cgo.go index cb24678bf0..8f3e66fa4d 100644 --- a/src/runtime/cgo/cgo.go +++ b/src/runtime/cgo/cgo.go @@ -20,7 +20,9 @@ package cgo #cgo !android,linux LDFLAGS: -lpthread #cgo netbsd LDFLAGS: -lpthread #cgo openbsd LDFLAGS: -lpthread -#cgo windows LDFLAGS: -lm -mthreads +// we must explicitly link msvcrt, because runtime needs ntdll, and ntdll +// exports some incompatible libc functions. See golang.org/issue/12030. +#cgo windows LDFLAGS: -lmsvcrt -lm -mthreads #cgo CFLAGS: -Wall -Werror -- cgit v1.3-5-g9baa