On Mon, Nov 1, 2021 at 9:44 AM Manoj Chauhan <chauhan.gurg...@gmail.com> wrote:
> Hi Brian, > > greeter.go calls plugin.open and it will be work only for one sub version > of go. If plugin and binary are made in different sub versions of go1.15 > then plugin.open will not work. > It sounds like you want to ignore a major warning on the use of plugins. It's my understanding that go plugins' limitations on requiring that both the plugin and the main binary to be built with identical toolchains (same go version) comes from the lack of a stable internal ABI within Go binaries across versions. (also the possibility of runtime changes across versions). Using LD_PRELOAD does not seem advisable as a way to bypass that limitation. (unfortunately, I don't have a better option other than to more tightly constrain your build system so both the original binary and the plugin are built with the same toolchain) > > On Monday, November 1, 2021 at 6:55:02 PM UTC+5:30 Brian Candler wrote: > >> > My question was how to load plugin address in go runtime using >> LD_PRELOAD. I am using LD_PRELOAD because plug.open is failed. Is there any >> other solution? >> >> When I tried it, I didn't need to set any environment variables (and >> certainly no LD_XXX variables). Follow this tutorial: >> >> https://medium.com/learning-the-go-programming-language/writing-modular-go-programs-with-plugins-ec46381ee1a9 >> >> It works fine for me: >> >> ubuntu@builder:~/go-plugin-example$ *cat /etc/lsb-release* >> DISTRIB_ID=Ubuntu >> DISTRIB_RELEASE=18.04 >> DISTRIB_CODENAME=bionic >> DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS" >> ubuntu@builder:~/go-plugin-example$ *ls* >> LICENSE README.md chi eng greeter.go swe >> ubuntu@builder:~/go-plugin-example$ *go version* >> go version go1.16.6 linux/amd64 >> ubuntu@builder:~/go-plugin-example$ *go build -buildmode=plugin -o >> eng/eng.so eng/greeter.go* >> ubuntu@builder:~/go-plugin-example$ *go run greeter.go english* >> Hello Universe >> ubuntu@builder:~/go-plugin-example$ >> >> If you're still using Ubuntu 16, note that it went obsolete nearly a year >> ago (unless you're paying for extended maintenance). >> > -- > 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/42e3d250-cb69-43b6-a297-7a56fcbe688en%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/42e3d250-cb69-43b6-a297-7a56fcbe688en%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CANrC0BiRTDZpQ5SiAxk2%2BDT5hV1vYzZRiJgtpsUSPkdsbiC%2B%3DQ%40mail.gmail.com.