Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 692126 - sys-devel/gcc[-cxx] still supports g++/c++
Summary: sys-devel/gcc[-cxx] still supports g++/c++
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-14 10:20 UTC by Agostino Sarubbo
Modified: 2021-12-13 01:21 UTC (History)
1 user (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 Agostino Sarubbo gentoo-dev 2019-08-14 10:20:27 UTC
Seems that USE cxx is here to switch off g++ and ability to compile c++ code, however with the latest gcc I can do it.
I didn't test previous


[ebuild   R   ~] sys-devel/gcc-9.2.0:9.2.0::gentoo  USE="fortran lto (multilib) nptl openmp pch (-altivec) -cxx -d -debug -doc (-fixed-point) -go -graphite (-hardened) (-jit) (-libssp) -nls -objc -objc++ -objc-gc -pgo -pie -sanitize -ssp -systemtap -test -vanilla -vtv" 0 KiB

# g++-9.2.0 hello.cpp -o hello && ./hello
Hello, World!
Comment 1 Arfrever Frehtes Taifersar Arahesis 2019-08-14 19:06:59 UTC
https://gitweb.gentoo.org/repo/gentoo.git/tree/eclass/toolchain.eclass?id=84fc5c9d1092eeacdf29900874d83fedca5bdacc#n2374:

is_cxx() {
	gcc-lang-supported 'c++' || return 1
	! is_crosscompile && tc_version_is_at_least 4.8 && return 0
	use_if_iuse cxx
}


This allows to disable support for C++ only for cross-compiled GCC >=4.8.


eclass/toolchain.eclass CVS log:
https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?view=log

- Revision 1.616:
"For 4.8+ C++ is always enabled. We should eventually drop the cxx USE flag,
but who knows what that would break."
https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.615&r2=1.616

- Revision 1.618:
"fix cross-compiling a stage1 with gcc-4.8 -- we can't enable c++ right away"
https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.eclass?r1=1.617&r2=1.618


I do not know what was the problem with cross-compiling.
If there is no longer a problem, then "cxx" USE flag could be dropped from IUSE in GCC >=4.8.
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2019-08-14 21:43:36 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #1)
> https://gitweb.gentoo.org/repo/gentoo.git/tree/eclass/toolchain.
> eclass?id=84fc5c9d1092eeacdf29900874d83fedca5bdacc#n2374:
> 
> is_cxx() {
> 	gcc-lang-supported 'c++' || return 1
> 	! is_crosscompile && tc_version_is_at_least 4.8 && return 0
> 	use_if_iuse cxx
> }
> 
> 
> This allows to disable support for C++ only for cross-compiled GCC >=4.8.
> 
> 
> eclass/toolchain.eclass CVS log:
> https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.
> eclass?view=log
> 
> - Revision 1.616:
> "For 4.8+ C++ is always enabled. We should eventually drop the cxx USE flag,
> but who knows what that would break."
> https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.
> eclass?r1=1.615&r2=1.616
> 
> - Revision 1.618:
> "fix cross-compiling a stage1 with gcc-4.8 -- we can't enable c++ right away"
> https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/toolchain.
> eclass?r1=1.617&r2=1.618
> 
> 
> I do not know what was the problem with cross-compiling.
> If there is no longer a problem, then "cxx" USE flag could be dropped from
> IUSE in GCC >=4.8.

USE=-cxx is useful for cross-compilers because:
- Some targets (like bare metal) don't support C++ as there is no complete OS interface available.
- Sometimes the only thing you need it a bare minimum of a cross-compiler for C only. Without need to build c++/libstdc++.

For native case USE=-cxx does not make sense because gcc is written in c++. It would brick your system.
Comment 3 Arfrever Frehtes Taifersar Arahesis 2019-08-14 23:39:36 UTC
Maybe it would make sense for profiles/base/package.use.force to have this entry?:

# C++ support can be disabled only for cross-compilers.
sys-devel/gcc cxx
Comment 4 Larry the Git Cow gentoo-dev 2019-08-17 22:56:16 UTC
The bug has been closed via the following commit(s):

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

commit 006c932930706e3d1aed08c9b2270ea7c456050d
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-08-17 22:49:01 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-08-17 22:56:07 +0000

    base/package.use.force: force sys-devel/gcc[cxx]
    
    Modern gcc needs c++ to boostrap. Self-hosted Gentoo system
    can't do it with USE=-cxx gcc. Historically toolchain.eclass
    prevented from disabling the flag by accident.
    
    Reported-by: Agostino Sarubbo
    Closes: https://bugs.gentoo.org/692126
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 profiles/base/package.use.force | 6 ++++++
 1 file changed, 6 insertions(+)

Additionally, it has been referenced in the following commit(s):

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

commit 908c4163cd990303aa7ffc2241f058eefffe91ff
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-08-17 22:52:48 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-08-17 22:56:07 +0000

    toolchain.eclass: obey user's USE=cxx option, bug #692126
    
    USE=cxx presence on typical systems is maintained by
    profiles/base/package.use.force entry. Let's drop
    silent override from the eclass.
    
    Reported-by: Agostino Sarubbo
    Bug: https://bugs.gentoo.org/692126
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 eclass/toolchain.eclass | 1 -
 1 file changed, 1 deletion(-)
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-12-10 13:01:26 UTC
*** Bug 828678 has been marked as a duplicate of this bug. ***
Comment 6 Alec Ari 2021-12-13 01:18:55 UTC
Following up on the comment from duplicate bug report:

(In reply to Sam James from comment #3)
> It's forced on. Have you verified the build.log / emerge actually says -cxx?

Yes, emerge --info sys-devel/gcc shows cxx is disabled.

build.log shows:

Languages: c

Configuring GCC with:

blah blah blah
--enable-languages=c
blah blah blah
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-12-13 01:21:06 UTC
(In reply to Alec Ari from comment #6)
> Following up on the comment from duplicate bug report:
> 
> (In reply to Sam James from comment #3)
> > It's forced on. Have you verified the build.log / emerge actually says -cxx?
> 
> Yes, emerge --info sys-devel/gcc shows cxx is disabled.
> 
> build.log shows:
> 
> Languages: c
> 
> Configuring GCC with:
> 
> blah blah blah
> --enable-languages=c
> blah blah blah

If you are certain it's actually disabled and it's still being built, please upload the build.log in the other bug and I guess it's not a duplicate.