[gogf/gf]gf build编译多平台/架构失败

2024-07-09 908 views
0
环境:

go version go1.17.3 windows/amd64 gf-cli为最新版 已安装gcc

config.yaml:

gfcli:
  build:
    name:     "gf"
    arch:     "all"
    system:   "all"
    mod:      "none"
    cgo:      0
    pack:     ""
    version:  "v1.0.0"
    output:   "./bin"
    extra:    ""

gcc信息:

C:\Users\ifhov>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=F:/soft/gcc/bin/../libexec/gcc/x86_64-w64-mingw32/7.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-7.3.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64 --enable-shared --enable-static --enable-targets=all --enable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --enable-sjlj-exceptions --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=i686 --with-arch-64=nocona --with-tune-32=generic --with-tune-64=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw730/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw730/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw730/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw730/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-sjlj-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64/opt/include -I/c/mingw730/prerequisites/x86_64-zlib-static/include -I/c/mingw730/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64/opt/include -I/c/mingw730/prerequisites/x86_64-zlib-static/include -I/c/mingw730/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64/opt/include -I/c/mingw730/prerequisites/x86_64-zlib-static/include -I/c/mingw730/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw730/x86_64-730-posix-sjlj-rt_v5-rev0/mingw64/opt/lib -L/c/mingw730/prerequisites/x86_64-zlib-static/lib -L/c/mingw730/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 7.3.0 (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project)

完整的控制台信息:

C:\Users\ifhov\Desktop\test>gf build main.go -gf.debug=true
2022-02-27 15:14:41.572 [INTE] gres_resource.go:57 Add 151 files to resource manager
2022-02-27 15:14:41.597 [INTE] gres_resource.go:57 Add 217 files to resource manager
2022-02-27 15:14:41.609 [INTE] gbuild.go:37 no build variables
2022-02-27 15:14:41.610 [INTE] gcfg_adapter_file_path.go:137 AddPath:C:\Users\ifhov\Desktop\test
2022-02-27 15:14:41.610 [INTE] gcfg_adapter_file_path.go:137 AddPath:C:\Users\ifhov\go\pkg\mod\github.com\gogf\gf-cli\v2@v2.0.0-rc.0.20220124081946-70b9e927b027\gf
2022-02-27 15:14:41.611 [INTE] gcfg_adapter_file_path.go:137 AddPath:C:\Users\ifhov\go\bin
2022-02-27 15:14:41.615 [INTE] gfsnotify_watcher.go:100 watcher adds monitor for: C:\Users\ifhov\Desktop\test\manifest\config\config.yaml
2022-02-27 15:14:41.616 [INTE] gi18n_manager.go:70 New: &gi18n.Manager{mu:sync.RWMutex{w:sync.Mutex{state:0, sema:0x0}, writerSem:0x0, readerSem:0x0, readerCount:0, readerWait:0}, data:map[string]map[string]string(nil), pattern:"\\{#(\\w+)\\}", options:gi18n.Options{Path:"i18n", Language:"en", Delimiters:[]string{"{#", "}"}}}
2022-02-27 15:14:41.616 [DEBU] DEBUG: build input: {Meta:{} File:main.go Name:gf Version:v1.0.0 Arch:all System:all Output:./bin Path:./bin Extra: Mod:none Cgo:true VarMap:map[] Pack:}
2022-02-27 15:14:41.675 [DEBU] DEBUG: git log -1 --format="%cd %H" --date=format:"%Y-%m-%d %H:%M:%S"
2022-02-27 15:14:41.678 start building...
2022-02-27 15:14:41.679 [DEBU] DEBUG: go build -o ./bin/v1.0.0/ios_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:41.684 go build -o ./bin/v1.0.0/ios_amd64/gf main.go
2022-02-27 15:14:43.900 failed to build, os:ios, arch:amd64, error:
# runtime/cgo
gcc_darwin_amd64.c: In function '_cgo_sys_thread_start':
gcc_darwin_amd64.c:33:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_darwin_amd64.c:38:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_darwin_amd64.c:33:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
gcc_darwin_amd64.c: At top level:
cc1.exe: error: unrecognized command line option '-Wno-nullability-completeness' [-Werror]
cc1.exe: all warnings being treated as errors

2022-02-27 15:14:43.927 [DEBU] DEBUG: go build -o ./bin/v1.0.0/ios_arm64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:43.936 go build -o ./bin/v1.0.0/ios_arm64/gf main.go
2022-02-27 15:14:45.543 failed to build, os:ios, arch:arm64, error:
# runtime/cgo
gcc_darwin_arm64.c:16:10: fatal error: TargetConditionals.h: No such file or directory
 #include <TargetConditionals.h>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

2022-02-27 15:14:45.552 [DEBU] DEBUG: go build -o ./bin/v1.0.0/freebsd_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:45.561 go build -o ./bin/v1.0.0/freebsd_amd64/gf main.go
2022-02-27 15:14:47.217 failed to build, os:freebsd, arch:amd64, error:
# runtime/cgo
gcc_freebsd_amd64.c:7:10: fatal error: sys/signalvar.h: No such file or directory
 #include <sys/signalvar.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.

2022-02-27 15:14:47.227 [DEBU] DEBUG: go build -o ./bin/v1.0.0/freebsd_arm/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:47.234 go build -o ./bin/v1.0.0/freebsd_arm/gf main.go
2022-02-27 15:14:48.273 failed to build, os:freebsd, arch:arm, error:
# runtime/cgo
gcc: error: unrecognized command line option '-marm'; did you mean '-mabm'?

2022-02-27 15:14:48.278 [DEBU] DEBUG: go build -o ./bin/v1.0.0/freebsd_386/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:48.283 go build -o ./bin/v1.0.0/freebsd_386/gf main.go
2022-02-27 15:14:49.943 failed to build, os:freebsd, arch:386, error:
# runtime/cgo
gcc_freebsd_386.c:6:10: fatal error: sys/signalvar.h: No such file or directory
 #include <sys/signalvar.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.

2022-02-27 15:14:49.949 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_386/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:49.955 go build -o ./bin/v1.0.0/linux_386/gf main.go
2022-02-27 15:14:51.694 failed to build, os:linux, arch:386, error:
# runtime/cgo
gcc_linux_386.c: In function '_cgo_sys_thread_start':
gcc_linux_386.c:38:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_linux_386.c:43:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_linux_386.c:38:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:14:51.711 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:51.716 go build -o ./bin/v1.0.0/linux_amd64/gf main.go
2022-02-27 15:14:53.432 failed to build, os:linux, arch:amd64, error:
# runtime/cgo
gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:61:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_linux_amd64.c:66:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_linux_amd64.c:61:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:14:53.450 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_arm64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:53.455 go build -o ./bin/v1.0.0/linux_arm64/gf main.go
2022-02-27 15:14:55.172 failed to build, os:linux, arch:arm64, error:
# runtime/cgo
gcc_linux_arm64.c: In function '_cgo_sys_thread_start':
gcc_linux_arm64.c:22:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_linux_arm64.c:27:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_linux_arm64.c:22:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:14:55.190 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_ppc64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:55.197 go build -o ./bin/v1.0.0/linux_ppc64/gf main.go
2022-02-27 15:14:56.932 failed to build, os:linux, arch:ppc64, error:
# runtime/cgo
gcc_ppc64x.c: In function '_cgo_sys_thread_start':
gcc_ppc64x.c:35:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_ppc64x.c:40:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_ppc64x.c:35:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:14:56.946 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_mips/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:56.952 go build -o ./bin/v1.0.0/linux_mips/gf main.go
2022-02-27 15:14:58.093 failed to build, os:linux, arch:mips, error:
# runtime/cgo
gcc: error: unrecognized argument in option '-mabi=32'
gcc: note: valid arguments to '-mabi=' are: ms sysv
gcc: error: unrecognized command line option '-mfp32'; did you mean '-m32'?
gcc: error: unrecognized command line option '-mno-odd-spreg'; did you mean '-mno-red-zone'?

2022-02-27 15:14:58.101 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_mipsle/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:58.106 go build -o ./bin/v1.0.0/linux_mipsle/gf main.go
2022-02-27 15:14:59.608 failed to build, os:linux, arch:mipsle, error:
# runtime/cgo
gcc: error: unrecognized argument in option '-mabi=32'
gcc: note: valid arguments to '-mabi=' are: ms sysv
gcc: error: unrecognized command line option '-mfp32'; did you mean '-m32'?
gcc: error: unrecognized command line option '-mno-odd-spreg'; did you mean '-mno-red-zone'?

2022-02-27 15:14:59.616 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_mips64le/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:14:59.621 go build -o ./bin/v1.0.0/linux_mips64le/gf main.go
2022-02-27 15:15:01.144 failed to build, os:linux, arch:mips64le, error:
# runtime/cgo
gcc: error: unrecognized argument in option '-mabi=64'
gcc: note: valid arguments to '-mabi=' are: ms sysv

2022-02-27 15:15:01.150 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_arm/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:01.155 go build -o ./bin/v1.0.0/linux_arm/gf main.go
2022-02-27 15:15:02.676 failed to build, os:linux, arch:arm, error:
# runtime/cgo
gcc: error: unrecognized command line option '-marm'; did you mean '-mabm'?

2022-02-27 15:15:02.680 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_ppc64le/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:02.685 go build -o ./bin/v1.0.0/linux_ppc64le/gf main.go
2022-02-27 15:15:05.104 failed to build, os:linux, arch:ppc64le, error:
# runtime/cgo
gcc_mmap.c:10:10: fatal error: sys/mman.h: No such file or directory
 #include <sys/mman.h>
          ^~~~~~~~~~~~
compilation terminated.

2022-02-27 15:15:05.111 [DEBU] DEBUG: go build -o ./bin/v1.0.0/linux_mips64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:05.116 go build -o ./bin/v1.0.0/linux_mips64/gf main.go
2022-02-27 15:15:06.615 failed to build, os:linux, arch:mips64, error:
# runtime/cgo
gcc: error: unrecognized argument in option '-mabi=64'
gcc: note: valid arguments to '-mabi=' are: ms sysv

2022-02-27 15:15:06.621 [DEBU] DEBUG: go build -o ./bin/v1.0.0/netbsd_386/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:06.625 go build -o ./bin/v1.0.0/netbsd_386/gf main.go
2022-02-27 15:15:08.934 failed to build, os:netbsd, arch:386, error:
# runtime/cgo
gcc_netbsd_386.c: In function '_cgo_sys_thread_start':
gcc_netbsd_386.c:33:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_netbsd_386.c:38:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_netbsd_386.c:33:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
gcc_netbsd_386.c: In function 'threadentry':
gcc_netbsd_386.c:59:2: error: unknown type name 'stack_t'
  stack_t ss;
  ^~~~~~~
gcc_netbsd_386.c:77:4: error: request for member 'ss_flags' in something not a structure or union
  ss.ss_flags = SS_DISABLE;
    ^
gcc_netbsd_386.c:77:16: error: 'SS_DISABLE' undeclared (first use in this function)
  ss.ss_flags = SS_DISABLE;
                ^~~~~~~~~~
gcc_netbsd_386.c:77:16: note: each undeclared identifier is reported only once for each function it appears in
gcc_netbsd_386.c:78:2: error: implicit declaration of function 'sigaltstack' [-Werror=implicit-function-declaration]
  sigaltstack(&ss, nil);
  ^~~~~~~~~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:15:08.967 [DEBU] DEBUG: go build -o ./bin/v1.0.0/netbsd_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:08.973 go build -o ./bin/v1.0.0/netbsd_amd64/gf main.go
2022-02-27 15:15:11.335 failed to build, os:netbsd, arch:amd64, error:
# runtime/cgo
gcc_netbsd_amd64.c: In function '_cgo_sys_thread_start':
gcc_netbsd_amd64.c:33:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_netbsd_amd64.c:38:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_netbsd_amd64.c:33:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
gcc_netbsd_amd64.c: In function 'threadentry':
gcc_netbsd_amd64.c:60:2: error: unknown type name 'stack_t'
  stack_t ss;
  ^~~~~~~
gcc_netbsd_amd64.c:73:4: error: request for member 'ss_flags' in something not a structure or union
  ss.ss_flags = SS_DISABLE;
    ^
gcc_netbsd_amd64.c:73:16: error: 'SS_DISABLE' undeclared (first use in this function)
  ss.ss_flags = SS_DISABLE;
                ^~~~~~~~~~
gcc_netbsd_amd64.c:73:16: note: each undeclared identifier is reported only once for each function it appears in
gcc_netbsd_amd64.c:74:2: error: implicit declaration of function 'sigaltstack' [-Werror=implicit-function-declaration]
  sigaltstack(&ss, nil);
  ^~~~~~~~~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:15:11.366 [DEBU] DEBUG: go build -o ./bin/v1.0.0/netbsd_arm/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:11.371 go build -o ./bin/v1.0.0/netbsd_arm/gf main.go
2022-02-27 15:15:12.903 failed to build, os:netbsd, arch:arm, error:
# runtime/cgo
gcc: error: unrecognized command line option '-marm'; did you mean '-mabm'?

2022-02-27 15:15:12.907 [DEBU] DEBUG: go build -o ./bin/v1.0.0/windows_386/gf.exe -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:12.912 go build -o ./bin/v1.0.0/windows_386/gf.exe main.go
2022-02-27 15:15:15.035 [DEBU] DEBUG:
2022-02-27 15:15:15.037 [DEBU] DEBUG: go build -o ./bin/v1.0.0/windows_amd64/gf.exe -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:15.042 go build -o ./bin/v1.0.0/windows_amd64/gf.exe main.go
2022-02-27 15:15:17.227 [DEBU] DEBUG:
2022-02-27 15:15:17.229 [DEBU] DEBUG: go build -o ./bin/v1.0.0/plan9_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:17.234 go build -o ./bin/v1.0.0/plan9_amd64/gf main.go
2022-02-27 15:15:18.402 failed to build, os:plan9, arch:amd64, error:
package command-line-arguments
        imports test/internal/cmd
        imports github.com/gogf/gf/v2/frame/g
        imports github.com/gogf/gf/v2/database/gdb
        imports github.com/gogf/gf/v2/encoding/gjson
        imports github.com/gogf/gf/v2/os/gfile
        imports github.com/gogf/gf/v2/os/gfsnotify
        imports github.com/fsnotify/fsnotify: build constraints exclude all Go files in C:\Users\ifhov\go\pkg\mod\github.com\fsnotify\fsnotify@v1.5.1

2022-02-27 15:15:18.415 [DEBU] DEBUG: go build -o ./bin/v1.0.0/plan9_386/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:18.422 go build -o ./bin/v1.0.0/plan9_386/gf main.go
2022-02-27 15:15:19.559 failed to build, os:plan9, arch:386, error:
package command-line-arguments
        imports test/internal/cmd
        imports github.com/gogf/gf/v2/frame/g
        imports github.com/gogf/gf/v2/database/gdb
        imports github.com/gogf/gf/v2/encoding/gjson
        imports github.com/gogf/gf/v2/os/gfile
        imports github.com/gogf/gf/v2/os/gfsnotify
        imports github.com/fsnotify/fsnotify: build constraints exclude all Go files in C:\Users\ifhov\go\pkg\mod\github.com\fsnotify\fsnotify@v1.5.1

2022-02-27 15:15:19.572 [DEBU] DEBUG: go build -o ./bin/v1.0.0/darwin_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:19.579 go build -o ./bin/v1.0.0/darwin_amd64/gf main.go
2022-02-27 15:15:21.241 failed to build, os:darwin, arch:amd64, error:
# runtime/cgo
gcc: error: x86_64: No such file or directory
gcc: error: unrecognized command line option '-arch'; did you mean '-march='?

2022-02-27 15:15:21.248 [DEBU] DEBUG: go build -o ./bin/v1.0.0/darwin_arm64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:21.253 go build -o ./bin/v1.0.0/darwin_arm64/gf main.go
2022-02-27 15:15:22.800 failed to build, os:darwin, arch:arm64, error:
# runtime/cgo
gcc: error: arm64: No such file or directory
gcc: error: unrecognized command line option '-arch'; did you mean '-march='?

2022-02-27 15:15:22.806 [DEBU] DEBUG: go build -o ./bin/v1.0.0/openbsd_386/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:22.812 go build -o ./bin/v1.0.0/openbsd_386/gf main.go
2022-02-27 15:15:25.157 failed to build, os:openbsd, arch:386, error:
# runtime/cgo
gcc_openbsd_386.c: In function '_cgo_sys_thread_start':
gcc_openbsd_386.c:32:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_openbsd_386.c:37:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_openbsd_386.c:32:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:15:25.180 [DEBU] DEBUG: go build -o ./bin/v1.0.0/openbsd_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:25.186 go build -o ./bin/v1.0.0/openbsd_amd64/gf main.go
2022-02-27 15:15:27.579 failed to build, os:openbsd, arch:amd64, error:
# runtime/cgo
gcc_openbsd_amd64.c: In function '_cgo_sys_thread_start':
gcc_openbsd_amd64.c:32:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
  sigset_t ign, oset;
  ^~~~~~~~
  _sigset_t
gcc_openbsd_amd64.c:37:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
  sigfillset(&ign);
  ^~~~~~~~~~
gcc_openbsd_amd64.c:32:16: error: unused variable 'oset' [-Werror=unused-variable]
  sigset_t ign, oset;
                ^~~~
cc1.exe: all warnings being treated as errors

2022-02-27 15:15:27.597 [DEBU] DEBUG: go build -o ./bin/v1.0.0/openbsd_arm/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:27.602 go build -o ./bin/v1.0.0/openbsd_arm/gf main.go
2022-02-27 15:15:29.155 failed to build, os:openbsd, arch:arm, error:
# runtime/cgo
gcc: error: unrecognized command line option '-marm'; did you mean '-mabm'?

2022-02-27 15:15:29.160 [DEBU] DEBUG: go build -o ./bin/v1.0.0/android_arm/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:29.166 go build -o ./bin/v1.0.0/android_arm/gf main.go
2022-02-27 15:15:30.716 failed to build, os:android, arch:arm, error:
# runtime/cgo
gcc: error: unrecognized command line option '-marm'; did you mean '-mabm'?

2022-02-27 15:15:30.720 [DEBU] DEBUG: go build -o ./bin/v1.0.0/dragonfly_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:30.726 go build -o ./bin/v1.0.0/dragonfly_amd64/gf main.go
2022-02-27 15:15:32.928 failed to build, os:dragonfly, arch:amd64, error:
# runtime/cgo
gcc_dragonfly_amd64.c:6:10: fatal error: sys/signalvar.h: No such file or directory
 #include <sys/signalvar.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.

2022-02-27 15:15:32.935 [DEBU] DEBUG: go build -o ./bin/v1.0.0/solaris_amd64/gf -ldflags "-X 'github.com/gogf/gf/v2/os/gbuild.builtInVarStr=eyJidWlsdEdpdCI6IiIsImJ1aWx0VGltZSI6IjIwMjItMDItMjcgMTU6MTQ6NDEifQ=='" main.go
2022-02-27 15:15:32.940 go build -o ./bin/v1.0.0/solaris_amd64/gf main.go
2022-02-27 15:15:35.347 failed to build, os:solaris, arch:amd64, error:
# runtime/cgo
gcc_setenv.c: In function 'x_cgo_setenv':
gcc_setenv.c:17:2: error: implicit declaration of function 'setenv'; did you mean 'getenv'? [-Werror=implicit-function-declaration]
  setenv(arg[0], arg[1], 1);
  ^~~~~~
  getenv
gcc_setenv.c: In function 'x_cgo_unsetenv':
gcc_setenv.c:26:2: error: implicit declaration of function 'unsetenv'; did you mean '_wgetenv'? [-Werror=implicit-function-declaration]
  unsetenv(arg[0]);
  ^~~~~~~~
  _wgetenv
cc1.exe: all warnings being treated as errors

2022-02-27 15:15:35.364 done!

最终./bin目录只编译出了windows_386和windows_amd64版本

QQ截图20220227152556

回答

6

@sudden3 你编译的程序是否依赖了需要CGO的包?

6

我也遇到了一模一样的问题,操作系统是win11

4

你把配置文件中 cgo: 0 这条删掉,再编译下 估计就成了

8

@gqcn 是用gf init创建的项目,只改动了config.yaml文件,用 @code-cutter 所说的方法后就可以正常编译了; 不是很理解,因为看文档中说gfcli.build.cgo的默认值就是0 ,我这边写0或不写cgo,都应该是一样的结果呀

6

@sudden3 @code-cutter 是的,这是cli的一个bug,已经修复下一版本发布,目前临时解决方案就是把cgo的配置项删除即可。