Description
What version of Go are you using (go version
)?
go version go1.7 windows/amd64
What operating system and processor architecture are you using (go env
)?
Windows Server 2012 R2 / AMD64
What did you do?
I used CGO with Clang for Windows 3.8.1 (http://llvm.org/releases/3.8.1/LLVM-3.8.1-win64.exe) like this:
set CC=clang
set CGO_CFLAGS="-m64 -Ipath/to/my/includes"
set CGO_LDFLAGS = "-v -Xlinker -libpath:path/to/libs -lwldap32 -ladvapi32 -lws2_32 -ldbghelp -luser32"
go build
What did you expect to see?
Expected to see nothing (ie, successful compile)
What did you see instead?
clang version 3.8.1 (branches/release_38)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\llvm\bin
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe" "-out:C:\\Users\\USAWTB~1\\AppData\\Local\\Temp\\2\\go-build808013706\\editor
\\dom\\_obj\\_all.o" "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\lib\\amd64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\
10.0.10586.0\\ucrt\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Li
b\\10.0.10586.0\\um\\x64" -nologo "C:\\Users\\USAWTB~1\\AppData\\Local\\Temp\\2\
\go-build808013706\\editor\\dom\\_obj\\_cgo_export.o" "C:\\Users\\USAWTB~1\\AppD
ata\\Local\\Temp\\2\\go-build808013706\\editor\\dom\\_obj\\binding.cgo2.o" -Xlin
ker -r --start-group mingwex.lib mingw32.lib --end-group
LINK : warning LNK4044: unrecognized option '/Xlinker'; ignored
LINK : warning LNK4044: unrecognized option '/r'; ignored
LINK : warning LNK4044: unrecognized option '/-start-group'; ignored
LINK : warning LNK4044: unrecognized option '/-end-group'; ignored
LINK : fatal error LNK1181: cannot open input file 'mingwex.lib'
clang.exe: error: linker command failed with exit code 1181 (use -v to see invocation)
I believe the basic problem is the -Xlinker -r --start-group mingwex.lib mingw32.lib --end-group at the end. This is added in cmd/go/build.go, line 3427.
Perhaps the go build command could check the version of the compiler, since:
$ clang -v
clang version 3.8.1 (branches/release_38)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\llvm\bin
The "msvc" tag would be a good indication not to use mingw.