plentico / osxcross-target

Provides darwin (Mac) binary support on Linux when cross-compiling Go apps that have CGO dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with `ld` flags being generated

deepjyoti30 opened this issue · comments

Hi there, this is a great project and I just stumbled across it while I was looking into a goreleaser issue (this one).

I have a similar use-case like you had, I want to build darwin binaries on a linux machine.

I have setup a separate goreleaser config for darwin builds and I am running into the following issue:

⨯ release failed after 8s                  error=failed to build for darwin_arm64: exit status 2: # command-line-arguments
/usr/lib/go/pkg/tool/linux_amd64/link: running /home/deepjyoti30/git/osxcross-target/bin/o64-clang failed: exit status 1
/usr/bin/ld: unrecognized option '-dynamic'
/usr/bin/ld: use the --help option for usage information
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

As it seems, the -dynamic flag is not supported by ld anymore. I am assuming that the cause here is that a flag is being generated by osxcross that is not supported anymore by ld.

Following are the versions of ld, clang and gcc that I have:

GNU ld (GNU Binutils) 2.39.0
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
gcc (GCC) 12.2.0
Copyright (C) 2022 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.

Can you shed some light on this and let me know if I am missing something here? I am trying to run the build on an amd64 machine and my OS is Arch Linux.