Clarification on Runtime Shared Library and Plugin Support for Go 1.5

417 views
Skip to first unread message

chad...@gmail.com

unread,
Jul 9, 2015, 7:36:03 PM7/9/15
to golan...@googlegroups.com
There is some confusion around shared library support in the upcoming 1.5 release. The HN thread at https://news.ycombinator.com/item?id=9852571 summarizes them, but basically the design doc mentioned a plugin package (which can't be seen on tip or in release notes), the beta release notes mention -dynlink flags during compilation but I am unable to find how one might leverage this? Is the plan only to support static linking in 1.5 and move the runtime library loading to a future version?

Michael Hudson-Doyle

unread,
Jul 9, 2015, 9:55:04 PM7/9/15
to chad...@gmail.com, golang-nuts
1.5 implements support for *some* of the buildmode arguments from the "go execution modes" document:

mwhudson@glamdring:src$ go help buildmode
The 'go build' and 'go install' commands take a -buildmode argument which
indicates which kind of object file is to be built. Currently supported values
are:

        -buildmode=archive
                Build the listed non-main packages into .a files. Packages named
                main are ignored.

        -buildmode=c-archive
                Build the listed main package, plus all packages it imports,
                into a C archive file. The only callable symbols will be those
                functions marked as exported. Requires exactly one main package
                to be listed.

        -buildmode=c-shared
                Build the listed main packages, plus all packages that they
                import, into C shared libraries. The only callable symbols will
                be those functions marked as exported. Non-main packages are
                ignored.

        -buildmode=default
                Listed main packages are built into executables and listed
                non-main packages are built into .a files (the default
                behavior).

        -buildmode=shared
                Combine all the listed non-main packages into a single shared
                library that will be used when building with the -linkshared
                option. Packages named main are ignored.

        -buildmode=exe
                Build the listed main packages and everything they import into
                executables. Packages not named main are ignored.

As you can see, plugin is not there (nor is pie, but that would probably be fairly easy now).

The work I did for -buildmode=shared was inspired by distributions' use cases (check my email address), so I haven't been directly working on plugin stuff, although some of the work is clearly related. There are design and technical issues for plugins -- How does this 'plugin' package actually work? How do you handle the case where a type has been created through reflection and then a package that statically refers to this type is loaded? And, if you want to be able to dlopen a plugin in a non-Go host program, we probably need to stop storing g in tls on intel.

I'll be working on polishing the buildmode=shared support and porting it to other architectures (on linux) in the 1.6 timeframe. I'm not expecting to work on plugins or porting it to non-Linux operating systems (although other ELF operating systems should really be pretty easy).

HTH.

Cheers,
mwh
Reply all
Reply to author
Forward
0 new messages