Discussion:
[Swig-devel] SWIG minimum Go versions and -cgo
William S Fulton
2016-05-28 13:44:08 UTC
Permalink
an
From the SWIG docs http://swig.org/Doc3.0/Go.html#Go_running_swig, it
appears -cgo requires Go 1.5 and later, so I presume this is why the
examples and test-suite use -cgo now. The examples and test-suite
don't work with -cgo though for Go 1.1.2 with numerous linker errors,
such as:

~/swig/github/swig/Examples/go/class> make -s clean check
# example
/tmp/go-build090199946/example/_obj/example.cgo2.o: In function
`_cgo_1eccd28dce62_Cfunc__wrap_Circle_area_example_ce26c1f9f9997e3a':
./example.go:91: undefined reference to
`_wrap_Circle_area_example_ce26c1f9f9997e3a'


Is this easily fixed for Go 1.1 using the 'go build' approach used in
the go_cpp Examples/Makefile target? If not, it feels like we need to
modify configure to only test/support Go 1.2 and later. Or configure
should detect Go 1.1 and then test without -cgo.

I'd like to fix this for the pending 3.0.9 release, so please let me
know your thoughts asap.

Thanks
Ian Lance Taylor
2016-05-28 13:55:33 UTC
Permalink
On Sat, May 28, 2016 at 6:44 AM, William S Fulton
From the SWIG docs http://swig.org/Doc3.0/Go.html#Go_running_swig, it
appears -cgo requires Go 1.5 and later, so I presume this is why the
examples and test-suite use -cgo now. The examples and test-suite
don't work with -cgo though for Go 1.1.2 with numerous linker errors,
~/swig/github/swig/Examples/go/class> make -s clean check
# example
/tmp/go-build090199946/example/_obj/example.cgo2.o: In function
./example.go:91: undefined reference to
`_wrap_Circle_area_example_ce26c1f9f9997e3a'
Is this easily fixed for Go 1.1 using the 'go build' approach used in
the go_cpp Examples/Makefile target? If not, it feels like we need to
modify configure to only test/support Go 1.2 and later. Or configure
should detect Go 1.1 and then test without -cgo.
I'd like to fix this for the pending 3.0.9 release, so please let me
know your thoughts asap.
I'm not sure why 1.1 doesn't work, but I think it would be fine to
restrict to 1.2 and higher in the top level configure script. It
already restricts to 1.1 and higher. I don't think anybody is using
anything older than 1.3 anyhow.

I can look more at this later, maybe after the weekend, or it's fine
with me if you change configure so that 1.2 is the minimum version.

Sorry for the trouble.

Ian
William S Fulton
2016-05-29 09:38:18 UTC
Permalink
Post by Ian Lance Taylor
I'm not sure why 1.1 doesn't work, but I think it would be fine to
restrict to 1.2 and higher in the top level configure script. It
already restricts to 1.1 and higher. I don't think anybody is using
anything older than 1.3 anyhow.
I can look more at this later, maybe after the weekend, or it's fine
with me if you change configure so that 1.2 is the minimum version.
I've made a really simple change to ignore versions < 1.2. Clearly the
Makefiles could be made simpler if we keep the minimum at 1.2. I've
got to say that the Makefiles are frustratingly complex to maintain
and and I'd like to see them simplified. The output from running the
examples should be simple and easy to follow and useful for users. The
usual approach is to use configure to change the output rather than
use bash at runtime.

For the swig-3.0.x series, we'd better keep the default SWIG options
as is wrt cgo wrappers, but for swig-3.1, are you thinking of changing
the default output cgo wrappers (-cgo turned on)? Either way at some
point I presume we'll stop testing the non-cgo wrappers which will
lead to further simplification.

William

Loading...