dongling4383 2019-09-19 13:16 采纳率: 100%
浏览 279

有人可以建议为什么从源(1.4)进行Go构建会由于GCC编译错误而失败,即使CGO_ENABLED = 0

In the file make.bat found in go/src (after unzipping tar), there is a gcc compile command even before a check for CGO_ENABLED ever is used. This messes up the bootstrap tool build.

For security reasons I cannot install GCC on Windows via cygwin or ming. However, the compiles are for various .c files which makes me unsure about what to do next.

I've tinkered about with the source code and the environment variables, especially CGO_ENABLED, which should have been all I needed. However, the make.bat haas that irritating little c compile that seems to be throwing me off.

This is the make.bat file and the compile that's throwing me off:

:: CGO_ENABLED: Controls cgo usage during the build. Set it to 1
:: to include all cgo related files, .c and .go file with "cgo"
:: build directive, in the build. Set it to 0 to ignore them.

@echo off

:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal

set GOBUILDFAIL=0

if exist make.bat goto ok
echo Must run make.bat from Go src directory.
goto fail 
:ok

:: Clean old generated file that will cause problems in the build.
del /F ".\pkguntimeuntime_defs.go" 2>NUL

:: Grab default GOROOT_FINAL and set GOROOT for build.
:: The expression %VAR:\=\\% means to take %VAR%
:: and apply the substitution \ = \\, escaping the
:: backslashes.  Then we wrap that in quotes to create
:: a C string.
cd ..
set GOROOT=%CD%
cd src
if "x%GOROOT_FINAL%"=="x" set GOROOT_FINAL=%GOROOT%
set DEFGOROOT=-DGOROOT_FINAL="\"%GOROOT_FINAL:\=\\%\""

echo # Building C bootstrap tool.
echo cmd/dist/*.c
if not exist ..\bin\tool mkdir ..\bin\tool
:: Windows has no glob expansion, so spell out cmd/dist/*.c.
gcc -O2 -Wall -Werror -o cmd/dist/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildgo.c cmd/dist/buildruntime.c cmd/dist/main.c cmd/dist/windows.c cmd/dist/arm.c
if errorlevel 1 goto fail
.\cmd\dist\dist env -wp >env.bat
if errorlevel 1 goto fail
call env.bat
del env.bat
echo.

The final result is just a standard gcc error :

Building C bootstrap tool.

cmd/dist/*.c

"gcc" is not recognized as...

  • 写回答

1条回答 默认 最新

  • dqf2015 2019-09-19 13:19
    关注

    Go 1.4 is written in C, and therefore needs C to be compiled. CGO is completely unrelated to this.

    Go 1.5 was the first version not to require C to be built.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用