macos - 如何解决在 mac m1 中运行 gcc 失败退出状态 1?

标签 macos go homebrew apple-m1

我已经安装了 mingw-w64。 当我检查版本时,它就在那里。

gcc --版本:
gcc (Homebrew GCC 11.2.0_3) 11.2.0 .

g++ --版本:
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 文件时,它会下载所有 mod,这就是错误:

 # 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

最佳答案

尝试检查是否如 in this Dockerfile ,添加 binutils-gold 将允许您使用 ld

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

(首次出现于 nodejs/node issue 4212 )

关于macos - 如何解决在 mac m1 中运行 gcc 失败退出状态 1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71718772/

相关文章:

bash - Go migrate 不会安装在 MacOS 上

xcode - 使用 Swift 将本地文件夹挂载为卷

mysql - UPDATE SQL 命令不适用于 GO 语言

ruby - 使用 Homebrew 程序安装 msgpack (0.5.8) mac OSX 错误

memcached - 使用 Homebrew 程序即服务启动时查找 Memcache 端口号

objective-c - 如果框架从应用程序中删除,会发生什么情况?

ios - 暂时禁用通用剪贴板

go - 使用反射获取指向值的指针

go - 如何不舍入持续时间

ruby-on-rails - 尝试运行 bundle 安装时出现“安全策略”错误