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 -I= to cgo CFLAGS safelist #34449

Closed
craig65535 opened this issue Sep 21, 2019 · 1 comment
Closed

cmd/go: add -I= to cgo CFLAGS safelist #34449

craig65535 opened this issue Sep 21, 2019 · 1 comment

Comments

@craig65535
Copy link

@craig65535 craig65535 commented Sep 21, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

I want to add /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2 as an include path, but I want my go script to be able to handle different Xcode installation paths and SDKs.

In gcc, this is done by specifying an include path that is relative to the sdkroot. This can be done with -I=. See https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html:

If dir begins with ‘=’ or $SYSROOT, then the ‘=’ or $SYSROOT is replaced by the sysroot prefix; see --sysroot and -isysroot.

I found that in go 1.9.2, I was able to put this include path in cgo lines as follows:

#cgo darwin CFLAGS:-I
#cgo darwin CFLAGS:=/usr/include/libxml2

However, I upgraded to go 1.13 and this no longer works.

What did you expect to see?

A working build

What did you see instead?

An error: "invalid flag in #cgo CFLAGS: -I =/usr/include/libxml2 (see https://golang.org/s/invalidflag)"

@ianlancetaylor ianlancetaylor changed the title Add -I= to cgo CFLAGS safelist cmd/go: add -I= to cgo CFLAGS safelist Sep 22, 2019
@ianlancetaylor ianlancetaylor added this to the Go1.14 milestone Sep 22, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Sep 22, 2019

Change https://golang.org/cl/196783 mentions this issue: cmd/go: allow -I= in cgo CFLAGS

@gopherbot gopherbot closed this in c4fbaee Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.