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...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: cflags
  Show dependency tree
 
Reported: 2023-03-12 14:33 UTC by Marcus Comstedt
Modified: 2024-06-25 06:43 UTC (History)
2 users (show)

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


Attachments

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
Comment 1 Larry the Git Cow gentoo-dev 2024-06-25 06:43:01 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4913cc739d6aeffc72834222f21a2d8ce9efe4e1

commit 4913cc739d6aeffc72834222f21a2d8ce9efe4e1
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-06-25 06:40:23 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-06-25 06:41:21 +0000

    app-containers/docker-cli: don't clobber CGO_*
    
    Note that we don't have to export now either as go-env.eclass does that.
    
    Bug: https://bugs.gentoo.org/900933
    Signed-off-by: Sam James <sam@gentoo.org>

 app-containers/docker-cli/docker-cli-26.1.0.ebuild | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1375818e7b5b3300812a7e86402526d0b2f72078

commit 1375818e7b5b3300812a7e86402526d0b2f72078
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-06-25 06:39:53 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-06-25 06:41:18 +0000

    app-containers/docker: don't clobber CGO_*
    
    Note that we don't have to export now either as go-env.eclass does that.
    
    Bug: https://bugs.gentoo.org/900933
    Signed-off-by: Sam James <sam@gentoo.org>

 app-containers/docker/docker-26.1.0-r1.ebuild | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cbd4158ebd536bc92d1d28878ed12eee1fbea357

commit cbd4158ebd536bc92d1d28878ed12eee1fbea357
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-06-25 06:38:26 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-06-25 06:41:06 +0000

    app-containers/runc: don't clobber CGO_*
    
    Note that we don't have to export now either as go-env.eclass does that.
    
    Bug: https://bugs.gentoo.org/900933
    Signed-off-by: Sam James <sam@gentoo.org>

 app-containers/runc/runc-1.1.12.ebuild | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)