golang/go

cmd/go: error: unrecognized command line option '-rdynamic' when cross-compiling to ARM with -pie

开放

#36,633 创建于 2020年1月18日

 (18 条评论) (0 个反应) (0 位负责人)Go (19,008 个派生)batch import
GoCommandNeedsInvestigationhelp wanted

仓库指标

星标
 (133,883 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

I'm not sure if this is supposed to work, i.e -buildmode pie for ARM, but nothing seems to suggest it shouldn't.

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

What did you do?

main.go:

package main

func main() {
        print("hello")
}
$ env GOOS=linux env GOARCH=arm go build -o test -buildmode pie

What did you expect to see?

No error, and a resulting test binary.

What did you see instead?

/home/daenney/Applications/asdf/installs/golang/1.13.6/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
gcc: error: unrecognized command line option ‘-marm’; did you mean ‘-mabm’?

The error also occurs if I add GOARM=7. It triggers on a combination of -buildmode pie and GOARCH=arm. Dropping -buildmode pie the build succeeds.

$ gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ uname -a
Linux monoceros 5.4.8-arch1-1 #1 SMP PREEMPT Sat, 04 Jan 2020 23:46:18 +0000 x86_64 GNU/Linux
$ pacman -Qq | grep gcc
arm-none-eabi-gcc
gcc
gcc-libs

贡献者指南