如何解决在Mac M1上运行GCC失败,退出状态为1?

huangapple go评论94阅读模式
英文:

how to solve running gcc failed exist status 1 in mac m1?

问题

我已经安装了mingw-w64。当我检查版本时,它是存在的。

gcc --version:
gcc (Homebrew GCC 11.2.0_3) 11.2.0.

g++ --version:
g++ (Homebrew GCC 11.2.0_3) 11.2.0

我还运行了which gcc:
/opt/homebrew/bin/gcc

然后我使用golang:latest镜像运行了我的docker-compose。目前没有错误。

up to date, audited 370 packages in 10m

9 packages are looking for funding
  run `npm fund` for details

6 high severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
Unlinking stale socket /tmp/supervisor.sock
[15:30:39] Using gulpfile /go/src/github.com/projectname/src/api/gulpfile.js
[15:30:39] Starting 'default'...
[15:30:39] Starting 'watch'...

当我保存一个.go文件时,它会下载所有的模块,并出现以下错误:

# github.com/projectname/api
/usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
collect2: fatal error: cannot find 'ld'
compilation terminated.

[15:46:23] 'build-binary' errored after 1.98 s
[15:46:23] Error in plugin "gulp-shell"
Message:
    Command `go build` failed with exit code 2

这是我的Dockerfile

FROM golang:1.17.0-alpine3.14 AS builder

RUN apk update && apk add gcc make git libc-dev binutils-gold

# Install dependencies
RUN apk add --update tzdata \
    --no-cache ca-certificates git wget \
    nodejs npm \
    g++ \
    supervisor \
    && update-ca-certificates \
    && npm install -g gulp gulp-shell
RUN npm install -g yarn


COPY ops/api/local/supervisor /etc
ENV PATH $PATH:/go/bin
WORKDIR /go/src/github.com/projectname/src/api
英文:

I have already brew install mingw-w64.
When i check the versions its there.

gcc --version:
gcc (Homebrew GCC 11.2.0_3) 11.2.0.

g++ --version:
g++ (Homebrew GCC 11.2.0_3) 11.2.0

I also run which gcc:
/opt/homebrew/bin/gcc

Then I run my docker-compose with image golang:latest. No errors yet

up to date, audited 370 packages in 10m

9 packages are looking for funding
  run `npm fund` for details

6 high severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
Unlinking stale socket /tmp/supervisor.sock
[15:30:39] Using gulpfile /go/src/github.com/projectname/src/api/gulpfile.js
[15:30:39] Starting 'default'...
[15:30:39] Starting 'watch'...

When I save a .go file it downloads all mods and this is the error:

 # github.com/projectname/api
 /usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
 collect2: fatal error: cannot find 'ld'
 compilation terminated.

 [15:46:23] 'build-binary' errored after 1.98 s
 [15:46:23] Error in plugin "gulp-shell"
 Message:
     Command `go build` failed with exit code 2

This is my Dockerfile:

FROM golang:1.17.0-alpine3.14 AS builder
    
RUN apk update && apk add gcc make git libc-dev binutils-gold

# Install dependencies
RUN apk add --update tzdata \
    --no-cache ca-certificates git wget \
    nodejs npm \
    g++ \
    supervisor \
    && update-ca-certificates \
    && npm install -g gulp gulp-shell
RUN npm install -g yarn


COPY ops/api/local/supervisor /etc
ENV PATH $PATH:/go/bin
WORKDIR /go/src/github.com/projectname/src/api

答案1

得分: 2

尝试并检查一下,根据这个Dockerfile,添加binutils-gold是否能让你使用ld

RUN apk update && apk add gcc make git libc-dev binutils-gold

(首次见于nodejs/node问题4212

英文:

Try and check if, as in this Dockerfile, adding binutils-gold would allow you to use ld.

RUN apk update && apk add gcc make git libc-dev binutils-gold

(First seen in nodejs/node issue 4212)

huangapple
  • 本文由 发表于 2022年4月2日 23:14:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/71718772.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定