Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 900933 - app-containers/runc, app-containers/docker, app-containers/docker-cli: CGO_CFLAGS disables optimization
Summary: app-containers/runc, app-containers/docker, app-containers/docker-cli: CGO_CF...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: William Hubbs
Depends on:
Blocks: cflags
  Show dependency tree
Reported: 2023-03-12 14:33 UTC by Marcus Comstedt
Modified: 2023-03-12 16:23 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Comstedt 2023-03-12 14:33:14 UTC
In the three ebuilds app-containers/runc, app-containers/docker, app-containers/docker-cli, the variable CGO_CFLAGS is set like this:

export CGO_CFLAGS="-I${ESYSROOT}/usr/include"

However, if CGO_CFLAGS is set to anything except the empty string the default
value of "-O2 -g" is discarded.  Therefore optimization is unconditionally
disabled by this line.

I suggest as an improvement to instead set

export CGO_CFLAGS="-I${ESYSROOT}/usr/include ${CFLAGS}"

allowing whatever optimization set in make.conf or package.env to take effect.

www-apps/hugo and app-containers/snapd already include ${CFLAGS} in their
CGO_CFLAGS, so there is precedent of this behaviour.

Reproducible: Always

Steps to Reproduce:
Build app-containers/docker with CFLAGS set to "-O2" in make.conf
Actual Results:  
The cgo bindings are built without optimization

Expected Results:  
The cgo bindings are built with optimization