Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: clang on windows fatal error LNK1104: cannot open file 'mingwex.lib' #60202

Closed
voltagex opened this issue May 15, 2023 · 6 comments
Closed
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@voltagex
Copy link

Seems to be similar to #16932

What version of Go are you using (go version)?

$ go version
go version go1.20.4 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
```
```
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Adam\AppData\Local\go-build
set GOENV=C:\Users\Adam\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Adam\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Adam\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.4
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=clang
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\git\golinkerbug\go.mod
set GOWORK=
set CGO_CFLAGS=-fuse-ld=lld
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Adam\AppData\Local\Temp\go-build290096245=/tmp/go-build -gno-record-gcc-switches

What did you do?

package main

import (
	"database/sql"
	"fmt"

	_ "github.com/mattn/go-sqlite3"
)

func main() {
	db, err := sql.Open("sqlite3", "./foo.db")
	if err != nil {
		panic(err)
	}

	fmt.Printf("%v+", db)
}

  1. Installed clang via the Visual Studio 2022 installer
  2. Opened a VS 2022 Developer Powershell
  3. $env:CGO_ENABLED=1
  4. $env:CC="clang"
  5. go build

(I also tried $env:CGO_CFLAGS="-fuse-ld=lld" and $env:CFLAGS="-fuse-ld=lld" with the same result)

What did you expect to see?

Program built successfully.

What did you see instead?

PS C:\git\golinkerbug> go build
# golinkerbug
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running clang failed: exit status 1104
LINK : warning LNK4044: unrecognized option '/-tsaware'; ignored
LINK : warning LNK4044: unrecognized option '/-nxcompat'; ignored
LINK : warning LNK4044: unrecognized option '/-major-os-version=6'; ignored
LINK : warning LNK4044: unrecognized option '/-minor-os-version=1'; ignored
LINK : warning LNK4044: unrecognized option '/-major-subsystem-version=6'; ignored
LINK : warning LNK4044: unrecognized option '/-minor-subsystem-version=1'; ignored
LINK : warning LNK4044: unrecognized option '/-dynamicbase'; ignored
LINK : warning LNK4044: unrecognized option '/-high-entropy-va'; ignored
LINK : warning LNK4044: unrecognized option '/T'; ignored
LINK : warning LNK4044: unrecognized option '/-start-group'; ignored
LINK : warning LNK4044: unrecognized option '/-end-group'; ignored
LINK : fatal error LNK1104: cannot open file 'mingwex.lib'
clang: error: linker command failed with exit code 1104 (use -v to see invocation)
@bcmills bcmills added compiler/runtime Issues related to the Go compiler and/or runtime. OS-Windows labels May 15, 2023
@bcmills
Copy link
Contributor

bcmills commented May 15, 2023

What version of Clang are you using?
(CC @golang/windows)

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 15, 2023
@voltagex
Copy link
Author

@bcmills

clang -v
clang version 15.0.1
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin

@seankhliao seankhliao changed the title cgo: Fails to link when using clang on Windows cmd/link: clang on windows fatal error LNK1104: cannot open file 'mingwex.lib' May 15, 2023
@voltagex
Copy link
Author

Unfortunately this looks like a dupe of #17014

@qmuntal
Copy link
Contributor

qmuntal commented May 16, 2023

Unfortunately this looks like a dupe of #17014

It is. Direct use of clang is not supported yet, although that can bridge this gap, i.e. https://github.com/mstorsjo/llvm-mingw. In fact that toolchain is being used by the windows/arm64 builders right now.

@qmuntal qmuntal closed this as completed May 16, 2023
@voltagex
Copy link
Author

@qmuntal is clang/msvc support planned at all?

@qmuntal
Copy link
Contributor

qmuntal commented May 16, 2023

@qmuntal is clang/msvc support planned at all?

I'll love that to happen. #17014 is labeled as help wanted and needs fix, so Go will support clang on Windows when someone has the time to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants