Re: [go-nuts] how to link cgo libraries in go1.9.4 ?
On Saturday, February 10, 2018 at 2:18:23 AM UTC+7, andrey mirtchovski wrote: > > If you mix dynamic libraries with static ones in the same folder the > -L -l trick won't work. a workaround is to softlink the .a files to a > separate folder so that the linker doesn't see the .so/.dylib files. > I found that while -L -l may *appear* to work, the linker may have actually found a library with a similar -l name in a system path (e.g. /usr/local/lib) and decided to dynamically link against that version instead of the required one in the -L path. This may result in build success but runtime failure. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] how to link cgo libraries in go1.9.4 ?
If you mix dynamic libraries with static ones in the same folder the -L -l trick won't work. a workaround is to softlink the .a files to a separate folder so that the linker doesn't see the .so/.dylib files. On Fri, Feb 9, 2018 at 12:11 PM, Jason E. Aten wrote: >> Note that the _ALLOW environment variables hold a regular expression, >> so you could also write CGO_LDFLAGS_ALLOW='.*\.a'. > > > Thank you, Ian. That's much more palatable. > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] how to link cgo libraries in go1.9.4 ?
> > Note that the _ALLOW environment variables hold a regular expression, > so you could also write CGO_LDFLAGS_ALLOW='.*\.a'. > Thank you, Ian. That's much more palatable. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] how to link cgo libraries in go1.9.4 ?
On Fri, Feb 9, 2018 at 10:05 AM, Jason E. Aten wrote: > Yay. I found a workaround--or rather, finally understood one of the > suggestions. > > Adding the following CGO_LDFLAGS_ALLOW hack in the Makefiles allows linking > against the named .a file. > > export > CGO_LDFLAGS_ALLOW="${GOPATH}/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a"; Note that the _ALLOW environment variables hold a regular expression, so you could also write CGO_LDFLAGS_ALLOW='.*\.a'. 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] how to link cgo libraries in go1.9.4 ?
Yay. I found a workaround--or rather, finally understood one of the suggestions. Adding the following CGO_LDFLAGS_ALLOW hack in the Makefiles allows linking against the named .a file. export CGO_LDFLAGS_ALLOW="${GOPATH}/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a"; -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] how to link cgo libraries in go1.9.4 ?
I added comments on #23749, but sadly the -L -l suggested workaround just makes a bad situation worse. It converts a linktime error into a runtime error. Details in the 23749 comment. It appears that this CL, that adds the forgotten support for linking against .a files, is what is needed: https://go-review.googlesource.com/c/go/+/92855/1/src/cmd/go/internal/work/security.go But it appears that team is delaying a fix in order to collect a more complete list of flags that should be whitelisted. So for now, it appears that certain CGO projects may well just have to declare go1.9.4 an unsupportable release. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] how to link cgo libraries in go1.9.4 ?
Please add your comments to this issue: https://github.com/golang/go/issues/23749 There are already a couple of reports for that particular usage pattern, one of which is mine. For now you have the option to do: #cgo LDFLAGS: -L${SRCDIR}/../../../LuaJIT/LuaJIT/src -lluajit -lm -ldl There are other options discussed in that thread. On Fri, Feb 9, 2018 at 9:11 AM, Jason E. Aten wrote: > on OSX, with the newly minted go1.9.4 with its cgo flag restrictions, I am > telling the linker what libraries to link against: (here > https://github.com/gijit/gi/blob/master/vendor/github.com/glycerine/golua/lua/lua.go#L10 > ) > > ~~~ > #cgo LDFLAGS: ${SRCDIR}/../../../LuaJIT/LuaJIT/src/libluajit.a -lm -ldl > ~~~ > > produces on attempt to build: > > ~~~ > make build > go build -ldflags "-X > main.LastGitCommitHash=30259813c10c0f6b63768b4f35358828e2e29f0b -X > main.BuildTimeStamp=2018-02-09T22:49:48+0700 -X main.GitBranch=master -X > main.NearestGitTag=v0.9.6 -X > main.GoVersion=go_version_go1.9.4_darwin/amd64" -o gi > go build github.com/gijit/gi/vendor/github.com/glycerine/golua/lua: invalid > flag in #cgo LDFLAGS: > /Users/jaten/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a > make[2]: *** [build] Error 1 > make[1]: *** [install] Error 2 > make: *** [install] Error 2 > jaten@jatens-MacBook-Pro ~/go/src/github.com/gijit/gi (master) $ > ~~~ > > So how do I tell cgo to link against these libraries in 1.9.4? > > Going down the path of crazy, I tried setting > CGO_CFLAGS_ALLOW="$(GOPATH)/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a", > but even so I still get: > ~~~ > go build -ldflags "-X > main.LastGitCommitHash=30259813c10c0f6b63768b4f35358828e2e29f0b -X > main.BuildTimeStamp=2018-02-09T23:08:10+0700 -X main.GitBranch=master -X > main.NearestGitTag=v0.9.6 -X > main.GoVersion=go_version_go1.9.4_darwin/amd64" -o gi > go build github.com/gijit/gi/vendor/github.com/glycerine/golua/lua: invalid > flag in #cgo LDFLAGS: > /Users/jaten/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a > make[2]: *** [build] Error 1 > make[1]: *** [install] Error 2 > make: *** [minimal] Error 2 > jaten@jatens-MacBook-Pro ~/go/src/github.com/gijit/gi (master) $ > ~~~ > > -- > 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. > For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] how to link cgo libraries in go1.9.4 ?
on OSX, with the newly minted go1.9.4 with its cgo flag restrictions, I am telling the linker what libraries to link against: (here https://github.com/gijit/gi/blob/master/vendor/github.com/glycerine/golua/lua/lua.go#L10 ) ~~~ #cgo LDFLAGS: ${SRCDIR}/../../../LuaJIT/LuaJIT/src/libluajit.a -lm -ldl ~~~ produces on attempt to build: ~~~ make build go build -ldflags "-X main.LastGitCommitHash=30259813c10c0f6b63768b4f35358828e2e29f0b -X main.BuildTimeStamp=2018-02-09T22:49:48+0700 -X main.GitBranch=master -X main.NearestGitTag=v0.9.6 -X main.GoVersion=go_version_go1.9.4_darwin/amd64" -o gi go build github.com/gijit/gi/vendor/github.com/glycerine/golua/lua: invalid flag in #cgo LDFLAGS: /Users/jaten/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a make[2]: *** [build] Error 1 make[1]: *** [install] Error 2 make: *** [install] Error 2 jaten@jatens-MacBook-Pro ~/go/src/github.com/gijit/gi (master) $ ~~~ So how do I tell cgo to link against these libraries in 1.9.4? Going down the path of crazy, I tried setting CGO_CFLAGS_ALLOW="$(GOPATH)/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a", but even so I still get: ~~~ go build -ldflags "-X main.LastGitCommitHash=30259813c10c0f6b63768b4f35358828e2e29f0b -X main.BuildTimeStamp=2018-02-09T23:08:10+0700 -X main.GitBranch=master -X main.NearestGitTag=v0.9.6 -X main.GoVersion=go_version_go1.9.4_darwin/amd64" -o gi go build github.com/gijit/gi/vendor/github.com/glycerine/golua/lua: invalid flag in #cgo LDFLAGS: /Users/jaten/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/../../../LuaJIT/LuaJIT/src/libluajit.a make[2]: *** [build] Error 1 make[1]: *** [install] Error 2 make: *** [minimal] Error 2 jaten@jatens-MacBook-Pro ~/go/src/github.com/gijit/gi (master) $ ~~~ -- 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. For more options, visit https://groups.google.com/d/optout.