通过ssh在64位主机上进行32位构建:对象为386,预期为amd64

时间:2018-11-01 13:05:23

标签: go cygwin

转到环境:

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\IEUser\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\IEUser\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\cygwin64\tmp\go-build115470254=/tmp/go-build -gno-record-gcc-switches

在我的构建脚本中:

$env:CGO_ENABLED = "1"
$env:GOOS = "windows"
$env:GOARCH = "386"
$env:CC = "C:\Qt\Qt5.11.1\Tools\mingw530_32\bin\gcc.exe"

如果我直接在Windows上运行该PowerShell脚本,效果很好:

powershell.exe : WORK=C:\Users\IEUser\AppData\Local\Temp\go-build363199970

"C:\\Go\\pkg\\tool\\windows_amd64\\link.exe" -o "C:\\Users\\IEUser\\AppData\\Local\\Temp\\go-build363199970\\b001\\exe\\a.out.exe" -importcfg
"C:\\Users\\IEUser\\AppData\\Local\\Temp\\go-build363199970\\b001\\importcfg.link" -buildmode=exe
-buildid=_Pna6rQZInvPOTo6ovpT/eNgRkOxfyIfNEc923MEh/LM048ylaWCky7xp48PwR/_Pna6rQZInvPOTo6ovpT -X ... "-extld=C:\\Qt\\Qt5.11.1\\Tools\\mingw530_32\\bin\\gcc.exe"
"C:\\Users\\IEUser\\AppData\\Local\\go-build\\07\\07d3feb4ac36b40e45669e164e0565963f209a2510b6f11f5237d6d554c024e3-d"

"C:\\Go\\pkg\\tool\\windows_amd64\\buildid.exe" -w "C:\\Users\\IEUser\\AppData\\Local\\Temp\\go-build363199970\\b001\\exe\\a.out.exe" # internal

mkdir -p C:\Users\IEUser\drone-workspace\

cp $WORK\b001\exe\a.out.exe C:\Users\IEUser\drone-workspace\xx.exe

但是如果我通过ssh(使用Cygwin)运行它,那么我得到了:

WORK=C:\cygwin64\tmp\go-build635580042

"C:\\Go\\pkg\\tool\\windows_amd64\\link.exe" -o "C:\\cygwin64\\tmp\\go-build635580042\\b001\\exe\\a.out.exe" -importcfg "C:\\cygwin64\\tmp\\go-build635580042\\b001\\importcfg.link" -buildmode=exe -buildid=_Pna6rQZInvPOTo6ovpT/eNgRkOxfyIfNEc923MEh/LM048ylaWCky7xp48PwR/_Pna6rQZInvPOTo6ovpT -X ... "-extld=C:\\Qt\\Qt5.11.1\\Tools\\mingw530_32\\bin\\gcc.exe" "C:\\Users\\IEUser\\AppData\\Local\\go-build\\07\\07d3feb4ac36b40e45669e164e0565963f209a2510b6f11f5237d6d554c024e3-d"
C:\Go\pkg\tool\windows_amd64\link.exe: running C:\Qt\Qt5.11.1\Tools\mingw530_32\bin\gcc.exe failed: exit status 1

使用go build -work并重新运行命令:

  

C:\ Users \ IEUser \ AppData \ Local \ go-build \ 2c \ 2c0ce927bab57cfa9fdde5b6dde060141e23f7a5698ed2fcd22b30a961d1701a-d( go .o):对象为[windows 386 go1.11.1 X:framepointer] Windows amd64 go1.11.1]

     

C:\ Go \ pkg \ tool \ windows_amd64 \ link.exe:C:\ Users \ IEUser \ AppData \ Local \ go-build \ 2c \ 2c0ce927bab57cfa9fdde5b6dde060141e23f7a5698ed2fcd22b30a961d1701a-d:不是程序包主要

为什么?


2018年11月1日星期四22:23:58 +07

因此,如果通过ssh运行,此命令将不起作用:

  

“ C:\ Go \ pkg \ tool \ windows_amd64 \ link.exe” -o“ C:\ cygwin64 \ tmp \ go-build635580042 \ b001 \ exe \ a.out.exe” -importcfg“ C:\ cygwin64 \ tmp \ go-build635580042 \ b001 \ importcfg.link“ -buildmode = exe -buildid = _Pna6rQZInvPOTo6ovpT / eNgRkOxfyIfNEc923MEh / LM048ylaWCky7xp48PwR / _Pna6rQZInvPOTo_ov_t \ bin \ t \ exe_t \ bin_t \ exe \ t \ bin_t \ exe_5.1 \ C#\ t \ bin_t \ exe \ 5.1 \ c \ t \ bin_t \ exe \\ bin \ t \ exe_5.1 \ c \ t \ bin \ t \ exe_5.1 “ C:\ Users \ IEUser \ AppData \ Local \ go-build \ 07 \ 07d3feb4ac36b40e45669e164e0565963f209a2510b6f11f5237d6d554c024e3-d”

如果我直接运行它,则会创建a.out.exe

    Directory: C:\cygwin64\tmp\go-build635580042\b001\exe


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        11/1/2018   8:32 AM       28085202 a.out.exe

通过Cygwin运行时,它可能与GOARCH有关,因为如果我将GOARCH设置为386,那么我只会得到:

IEUser@MSEDGEWIN10 /cygdrive/c/Users/IEUser/drone-workspace
$ go env GOARCH
amd64

IEUser@MSEDGEWIN10 /cygdrive/c/Users/IEUser/drone-workspace
$ export GOARCH=386

IEUser@MSEDGEWIN10 /cygdrive/c/Users/IEUser/drone-workspace
$ cmd.exe /C "C:\\Go\\pkg\\tool\\windows_amd64\\link.exe" -o "C:\\cygwin64\\tmp\\go-build635580042\\b001\\exe\\a.out.exe" -importcfg "C:\\cygwin64\\tmp\\go-build635580042\\b001\\importcfg.link" -buildmode=exe -buildid=_Pna6rQZInvPOTo6ovpT/eNgRkOxfyIfNEc923MEh/LM048ylaWCky7xp48PwR/_Pna6rQZInvPOTo6ovpT "-extld=C:\\Qt\\Qt5.11.1\\Tools\\mingw530_32\\bin\\gcc.exe" "C:\\Users\\IEUser\\AppData\\Local\\go-build\\07\\07d3feb4ac36b40e45669e164e0565963f209a2510b6f11f5237d6d554c024e3-d"
C:\Go\pkg\tool\windows_amd64\link.exe: running C:\Qt\Qt5.11.1\Tools\mingw530_32\bin\gcc.exe failed: exit status 1

如何继续调试?


2018年11月2日星期五00:03:07 +07

通过将-c(转储调用图)和-v(打印链接跟踪)添加到link.exe

  

58.41主机链接:“ C:\ Qt \ Qt5.11.1 \ Tools \ mingw530_32 \ bin \ gcc.exe”“ -m32”“ -mconsole”“ -o”“ C:\ cygwin64 \ tmp \ go-build635580042 \ b001 \ exe \ a.out.exe“” C:\ cygwin64 \ tmp \ go-link-125134263 \ go.o“” C:\ cygwin64 \ tmp \ go-link-125134263 \ 000000.o“” C: \ cygwin64 \ tmp \ go-link-125134263 \ 000001.o“” C:\ cygwin64 \ tmp \ go-link-125134263 \ 000002.o“”“ C:\ cygwin64 \ tmp \ go-link-125134263 \ 000003.o “” C:\ cygwin64 \ tmp \ go-link-125134263 \ 000004.o“”“ C:\ cygwin64 \ tmp \ go-link-125134263 \ 000005.o”“” C:\ cygwin64 \ tmp \ go-link-125134263 \ 000006.o“” C:\ cygwin64 \ tmp \ go-link-125134263 \ 000007.o“” C:\ cygwin64 \ tmp \ go-link-125134263 \ 000008.o“” C:\ cygwin64 \ tmp \ go -link-125134263 \ 000009.o“” C:\ cygwin64 \ tmp \ go-link-125134263 \ 000010.o“” -g“” -O2“” -lrasapi32“” -g“” -O2“” -Wl ,-T,C:\ cygwin64 \ tmp \ go-link-125134263 \ fix_debug_gdb_scripts.ld“” -Wl,-start-group“” -lmingwex“” -lmingw32“” -Wl,-end-group“” -lwinmm“” -lws2_32“” -lkernel32“

     

C:\ Go \ pkg \ tool \ windows_amd64 \ link.exe:运行C:\ Qt \ Qt5.11.1 \ Tools \ mingw530_32 \ bin \ gcc.exe失败:退出状态1

如何保留所有*.o文件,所以我可以重新运行该命令以查看其为什么失败?

$ /cygdrive/c/Qt/Qt5.11.1/Tools/mingw530_32/bin/gcc.exe "-m32" "-mconsole" "-o" "C:\\cygwin64\\tmp\\go-build635580042\\b001\\exe\\a.out.exe" "C:\\cygwin64\\tmp\\go-link-125134263\\go.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000000.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000001.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000002.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000003.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000004.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000005.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000006.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000007.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000008.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000009.o" "C:\\cygwin64\\tmp\\go-link-125134263\\000010.o" "-g" "-O2" "-lrasapi32" "-g" "-O2" "-Wl,-T,C:\\cygwin64\\tmp\\go-link-125134263\\fix_debug_gdb_scripts.ld" "-Wl,--start-group" "-lmingwex" "-lmingw32" "-Wl,--end-group" "-lwinmm" "-lws2_32" "-lkernel32"
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\go.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000000.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000001.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000002.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000003.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000004.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000005.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000006.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000007.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000008.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000009.o: No such file or directory
gcc.exe: error: C:\cygwin64\tmp\go-link-125134263\000010.o: No such file or directory

2018年11月2日星期五10:54:26 +07

看起来与Cygwin相关,因为通过bash(WSL)运行可以正常工作:

"C:\\Go\\pkg\\tool\\windows_amd64\\link.exe" -o "C:\\Users\\IEUser\\AppData\\Local\\Temp\\go-build132204662\\b001\\exe\\a.out.exe" -importcfg "C:\\Users\\IEUser\\AppData\\Local\\Temp\\go-build132204662\\b001\\importcfg.link" -buildmode=exe -buildid=_Pna6rQZInvPOTo6ovpT/eNgRkOxfyIfNEc923MEh/LM048ylaWCky7xp48PwR/_Pna6rQZInvPOTo6ovpT -X ... "-extld=C:\\Qt\\Qt5.11.1\\Tools\\mingw530_32\\bin\\gcc.exe" "C:\\Users\\IEUser\\AppData\\Local\\go-build\\07\\07d3feb4ac36b40e45669e164e0565963f209a2510b6f11f5237d6d554c024e3-d"
"C:\\Go\\pkg\\tool\\windows_amd64\\buildid.exe" -w "C:\\Users\\IEUser\\AppData\\Local\\Temp\\go-build132204662\\b001\\exe\\a.out.exe" # internal
mkdir -p C:\Users\IEUser\drone-workspace\
cp $WORK\b001\exe\a.out.exe C:\Users\IEUser\drone-workspace\xx.exe

问题是:https://github.com/Microsoft/WSL/issues/2138 这就是为什么我必须尝试Cygwin的原因。

0 个答案:

没有答案