Skip to content

runtime: SWIG: Export Go version through runtime.h and let SWIG generated code fail to build if the Go version is unsupported #9082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michael-schaller opened this issue Nov 10, 2014 · 4 comments
Milestone

Comments

@michael-schaller
Copy link
Contributor

Issue:
SWIG or the generated C code by SWIG currently has no support for checking the Go
version in use.


Background:
During the discussion of issue #9065 [1] Ian pointed out that the current SWIG version no
longer works with Go 1.0.3 [2].  In general SWIG should support old Go versions for as
long as possible but sometimes support for old Go versions needs to be dropped because
of incompatibilities or bugs or in order to support new features.


Proposal:
runtime.h defines the Go version as a constant similarly to SWIG_VERSION [3] or the
often used GCC_VERSION [4] constant.


Possible use cases:
1) Clear error message to the user in case an unsupported Go version is in use. The C
code generated by SWIG can include a simple preprocessor check if the Go version in use
is supported and if it isn't fail via the #error directive and a clear error message.

2) New and optional features could be made available conditionally if the Go version in
use supports it. In case a Go version does not support a new feature a warning message
can be generated via the #warning preprocessor directive. CL 171270043 [5] would need to
be reverted though as currently warnings are ignored/hidden.

3) If there are incompatibilities between major Go versions (Go 1 vs. 2) then the
generated C code by SWIG could be made compatible to several major Go versions.


Links:
[1] https://golang.org/issue/9065
[2] https://golang.org/issue/9065?c=7
[3] http://www.swig.org/Doc3.0/SWIGDocumentation.html#Preprocessor_condition_compilation
[4]
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros4
[5] https://golang.org/cl/171270043
@ianlancetaylor
Copy link
Member

Comment 1:

Labels changed: added repo-main, release-go1.5.

Owner changed to @ianlancetaylor.

Status changed to Accepted.

@michael-schaller
Copy link
Contributor Author

Ian, do you think this issue is still relevant? Is there another way to export the Go version now that runtime.h is gone?

@ianlancetaylor
Copy link
Member

I hope that this will not be an issue as we move past the Go 1.5 release. Since SWIG now depends only on documented interfaces, it should no longer be necessary to update SWIG for each new Go release, and after everybody is using Go 1.5 and SWIG 3.0.6 there should no longer be a concern about having a mismatch between SWIG and Go. I hope.

@michael-schaller
Copy link
Contributor Author

SGTM. :-D

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants