1

When I build source on Golang, I saw the warning message, but I couldn't find answer about it.

$ go build --mod=mod -o main main.go
# command-line-arguments
ld: warning: -no_pie is deprecated when targeting new OS versions
  • specs version : go version go1.18 darwin/amd64 os : Monterey 12.6 build command : go build --mod=mod -o [binary name] main.go
user2491067
  • 21
  • 1
  • 6
  • If you're asking what that specific flag is, you can find the answer here: https://stackoverflow.com/a/50615370/9335036 – Z. Kosanovic Sep 25 '22 at 23:26

2 Answers2

1

This seems to be a known issue. See Github for more information.

As a workaround you can pass the -buildmode=pie flag to your go build command.

prolink007
  • 33,872
  • 24
  • 117
  • 185
faschulze
  • 75
  • 4
  • 14
1

From GitHub: link

There are a few options:

- wait for the next Go 1.19.x and 1.18.x releases, probably early next month
- build Go from the master branch
- pass -buildmode=pie flag to go build and go test for a workaround
- use older version of the system linker
twiny
  • 284
  • 5
  • 11