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

cgo: implement #cgo CFLAGS #744

Merged
merged 2 commits into from
Nov 25, 2019
Merged

cgo: implement #cgo CFLAGS #744

merged 2 commits into from
Nov 25, 2019

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Nov 22, 2019

This implementation is still very limited but provides a base to build upon. Limitations:

  • CGO_CFLAGS etc is not taken into account.
  • These CFLAGS are not used in C files compiled with the package.
  • Other flags (CPPFLAGS, LDFAGS, ...) are not yet implemented.

@aykevl aykevl force-pushed the cgo-flags branch 2 times, most recently from 3acc42f to e52ae75 Compare November 22, 2019 16:21
@deadprogram
Copy link
Member

Hi @aykevl looks like getting this to work on Windows is going to require some additional effort, in case you did notice that the build had failed.

@aykevl
Copy link
Member Author

aykevl commented Nov 23, 2019

I thought I fixed it but apparently not. Trying again.

@aykevl aykevl force-pushed the cgo-flags branch 5 times, most recently from 94d790f to 6b93bea Compare November 23, 2019 22:54
@aykevl
Copy link
Member Author

aykevl commented Nov 24, 2019

Looks like I'm hitting a bug (or feature?) of the go/ast package: golang/go#35803

This commit adds tests for CGo preprocessing. There are various errors
that can be reported while preprocessing, and they should integrate well
with the compiler (including accurate source location tracking).

Also allow CGo preprocessing to continue after Clang encountered an
error, for a better view of what happened.
This implementation is still very limited but provides a base to build
upon. Limitations:

  * CGO_CFLAGS etc is not taken into account.
  * These CFLAGS are not used in C files compiled with the package.
  * Other flags (CPPFLAGS, LDFAGS, ...) are not yet implemented.
@aykevl
Copy link
Member Author

aykevl commented Nov 24, 2019

Managed to find a workaround. This is ready for review again.

@deadprogram
Copy link
Member

It took a little longer to review this as it is rather complex. This is a great example of how important tests are to communicate intent.

Merging, great work on this!

@deadprogram deadprogram merged commit 10e1420 into dev Nov 25, 2019
@aykevl aykevl deleted the cgo-flags branch November 25, 2019 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants