golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.26k stars 17.57k forks source link

x/mobile: IOS static libaray build by go mobile make clang++ crashed with ldflags "-Wl,-fixup_chains" #67870

Open liudikang opened 3 months ago

liudikang commented 3 months ago

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

go version go1.22.1 darwin/arm64

What did you do?

First we build a go project with gomobile (https://github.com/xxf098/go-tun2socks-build) as a static library, then linker this static library into our IOS project.

What did you see happen?

lld crashed.

I found crash position of lld:

SymtabSectionImpl<LP>::writeTo of file lld/MachO/SyntheticSections.cpp Crashed on this line: nList->n_sect = defined->isec()->parent->index;

I debug llvm found crash symbol is arm64_ios_lib.ptr

After we remove ldflags "-Wl,-fixup_chains" ,or modify llvm code crash not happed.

What did you expect to see?

The ios static library compiled by gomobile works fine with clang link parameter "-Wl,-fixup_chains".

gabyhelp commented 3 months ago

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)