On Sat, Oct 17, 2020 at 12:25 PM Thierry Fournier
<thierry.f...@gmail.com> wrote:
>
> I need to build go with an archive file which requires to be linked with the 
> option "-Wl,--whole-archive" on linux or "-Wl,-all_load" on macos.
>
> My go file contains this code:
>
> /*
>
> #cgo darwin LDFLAGS: -L.. -Wl,-all_load -lmy_lib
> #cgo linux LDFLAGS: -L.. -Wl,--whole-archive -lmy_lib
>
> */
> import "C"
>
> When I try to compile on Linux or Mac, this doesn't work. I read these errors:
>
> Mac:
>
> go build _/Users/thierryfournier/git/my-lib/my_lib: invalid flag in #cgo 
> LDFLAGS: -Wl,-all_load
>
> Linux:
>
> go build _/home/thierry/my_lib/my_lib: invalid flag in #cgo LDFLAGS: 
> -Wl,--whole-archive
>
> I test the local link on both OS, and the option exists and works for c.
>
> So, i don’t found any way to embed the whole library.
>
> I don’t find a way to understand how the linker is called
> I don’t find documentation about supported flag.
>
> If anyone has a solution or a clue, it will be welcome

Add these flags to the CGO_LDFLAGS_ALLOW environment variable.

You may want to file an issue to get them added to the list of permitted flags.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUf1LRxo5M4HbrarA8TuwA1VV7Lbeaac5bUsWG96N%3Deqw%40mail.gmail.com.

Reply via email to