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

proposal: cmd/cgo: pkg-config support default pc file #46226

Closed
chai2010 opened this issue May 18, 2021 · 6 comments
Closed

proposal: cmd/cgo: pkg-config support default pc file #46226

chai2010 opened this issue May 18, 2021 · 6 comments

Comments

@chai2010
Copy link
Contributor

cgo user can custom default pc file to change CFLAGS and LDFLAGS.

for example:

#cgo pkg-config png

will read ${GOPATH}/pkg/cgo_${GOOS}_${GOARCH}/png.pc at first (donot need install ‘pkg-config’ tool):

# See: man pkg-config
pkgroot=${GOPATH}/pkg/cgo_${GOOS}_${GOARCH}/png

Name: png
Description: png library
Version: 1.2.3

Requires:
Cflags: -I${pkgroot}/include
Libs: -L${pkgroot}/lib -lpng

if no default pc file, then use local pkg-config tool.

@gopherbot gopherbot added this to the Proposal milestone May 18, 2021
@ianlancetaylor ianlancetaylor changed the title proposal: cgo pkg-config support default pc file proposal: cmd/cgo: pkg-config support default pc file May 18, 2021
@ianlancetaylor
Copy link
Contributor

It seems to me that we can already do this using #cgo comments. What is the advantage to putting those flags into a .pc file?

@chai2010
Copy link
Contributor Author

@ianlancetaylor
as cgo user, i hope use different cflags and ldflags for dev and release mode (build target and zip).
if use #cgo comments, i need change the code.
if use .pc file, i can set PKG_CONFIG_PATH to custom pc file for release mode.

@rsc
Copy link
Contributor

rsc commented May 19, 2021

GOPATH/pkg is really meant for binaries and things that can be regenerated.
It is a bit surprising to put a directory of configuration files into GOPATH/pkg/cgo_GOOS_GOARCH/

@rsc
Copy link
Contributor

rsc commented May 19, 2021

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented May 26, 2021

Based on the discussion above, this proposal seems like a likely decline.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented Jun 2, 2021

No change in consensus, so declined.
— rsc for the proposal review group

@rsc rsc closed this as completed Jun 2, 2021
@golang golang locked and limited conversation to collaborators Jun 2, 2022
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