Re: [go-nuts] Why was islibrary not set correctly when using -buildmode=c-shared with gccgo compiler

94 views
Skip to first unread message

Ian Lance Taylor

unread,
Aug 18, 2020, 7:52:48 PM8/18/20
to Yonatan Gizachew, golang-nuts
On Mon, Aug 17, 2020 at 10:42 PM Yonatan Gizachew <eme...@gmail.com> wrote:
>
> Sorry I couldn't provide code to reproduce the case, but I just wanted to know if there are known cases for my issue.
> From the golang source code, in the runtime library proc.go file there is this code snippet
> https://github.com/golang/go/blob/a745171e6b30394b661a040d04e8807b4bd0c7da/src/runtime/proc.go#L199
> In my case, I build my go program with -buildmode=c-shared mode and I loaded it dynamically to my program written in C. So as to load the runtime go libraries dynamically, I preferred to use the gccgo compiler instead of gc compiler. Here is how I built my go code.
>
> $ go build -o libgotest.so -buildmode=c-shared -compiler=gccgo test.go
>
> I was hoping the linker would set the islibrary flag to True and as a result the main function in proc.go would return at line 202. But it wasn't the case.
>
> I was wondering why islibrary was set false.

Note that gccgo uses a different runtime package. Your link is to the
gc runtime package, not the gccgo runtime package.

gccgo sets isarchive for both c-archive and c-shared. As this is an
internal runtime variable, it shouldn't make any difference. Does it
ever make a difference to your code that gccgo sets isarchive rather
than islibrary?

Ian

Yonatan Gizachew

unread,
Aug 18, 2020, 9:19:43 PM8/18/20
to golang-nuts
Oh, thanks for clarification. For your question, not for now.

Yonatan Gizachew

unread,
Aug 18, 2020, 9:20:15 PM8/18/20
to golang-nuts
But may I know what gccgo's runtime package?

On Wednesday, August 19, 2020 at 8:52:48 AM UTC+9 Ian Lance Taylor wrote:

Ian Lance Taylor

unread,
Aug 18, 2020, 11:49:01 PM8/18/20
to Yonatan Gizachew, golang-nuts
On Tue, Aug 18, 2020 at 6:20 PM Yonatan Gizachew <eme...@gmail.com> wrote:
>
> But may I know what gccgo's runtime package?

https://go.googlesource.com/gofrontend/+/refs/heads/master/libgo/go/runtime/
https://go.googlesource.com/gofrontend/+/refs/heads/master/libgo/runtime/

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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/39b98200-4b70-4c1e-8604-b98e2cad43f4n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages