Skip to content
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

cmd/go: add option to propagate '-D' flags to SWIG #36623

Open
i96751414 opened this issue Jan 17, 2020 · 2 comments
Open

cmd/go: add option to propagate '-D' flags to SWIG #36623

i96751414 opened this issue Jan 17, 2020 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@i96751414
Copy link

Related with #18339.

When building a package using go + swig, it would be great if we could provide custom flags to swig (specially -D flags).

One example where this would be needed is when we need to pass -DSWIGWORDSIZE64 or -DSWIGWORDSIZE32 so swig can properly generate its bindings.

@ianlancetaylor ianlancetaylor changed the title cmd/go: add option to propagate '-D' flags cmd/go: add option to propagate '-D' flags to SWIG Jan 17, 2020
@ianlancetaylor
Copy link
Contributor

#18339 was about adding a SWIGFLAGS environment variable similar to CFLAGS, for flags to pass to SWIG.

Would that fix your problem?

We didn't implement #18339 because nobody provided a compelling use case. What is your compelling use case? The SWIG libraries themselves don't use SWIGWORDSIZE64; what would you use it for?

@i96751414
Copy link
Author

i96751414 commented Jan 17, 2020

I believe it would fix. SWIG tries to determine the word size (see https://github.com/swig/swig/blob/master/Lib/swigarch.i) and this can also be explicit defined if one sets -DSWIGWORDSIZE32 or -DSWIGWORDSIZE64.

The main problem here is that if this is not set and any of the defines used in swigarch (namely __WORDSIZE, __x86_64 and __x86_64__) are set, swig will automatically set the word size as 32.

This is a problem for some x64 architectures as swig wrongly generates bindings considering a word size of 32 instead of 64 (see https://github.com/swig/swig/blob/master/Lib/stdint.i).

What I am currently doing as a workaround is to generate a swig interface containing these defines (obtained from cc) every time I build my application, however I feel like go should let us pass this kind of flags instead.

@cagedmantis cagedmantis added this to the Backlog milestone Jan 17, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants