Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Specific GCC version per package basis
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
ZekeMorrin
n00b
n00b


Joined: 15 Oct 2023
Posts: 19

PostPosted: Wed Jan 29, 2025 12:18 pm    Post subject: Specific GCC version per package basis Reply with quote

Hello, how can I *properly* set package.env to use a specific version of gcc to compile a package? Without encountering linking issues etc..

I have both GCC 14 and 13 installed, I want to use GCC-13 for compiling cuda and opencv related packages, that includes;

media-libs/opencv
dev-util/nvidia-cuda-toolkit
sci-libs/caffe2

I couldn't find the correct solution in older posts.

Thanks!
Back to top
View user's profile Send private message
leonik375
n00b
n00b


Joined: 19 Jul 2016
Posts: 10

PostPosted: Wed Jan 29, 2025 12:56 pm    Post subject: Reply with quote

Did you try this?
https://forums.gentoo.org/viewtopic-p-7996118.html#7996118
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1999

PostPosted: Wed Jan 29, 2025 1:43 pm    Post subject: Reply with quote

Beware of errors stemming from C++ library mismatches if this is attempted.
Back to top
View user's profile Send private message
oneone
Tux's lil' helper
Tux's lil' helper


Joined: 20 Sep 2017
Posts: 104

PostPosted: Wed Jan 29, 2025 3:44 pm    Post subject: Reply with quote

I cannot answer your question as to how to do this properly with absolute certainty, but here is what I did in order to compile hyprland with gcc-14 and the rest of my system with my default compiler gcc-13.

File /etc/portage/env/compiler-gcc-14:
Code:
# Normal settings here
COMMON_FLAGS="-O2 -march=native"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"

CC="gcc-14"
CPP="g++-14" # necessary for xorg-server and possibly other packages
CXX="g++-14"


File /etc/portage/package.env/hypr.env:
Code:
dev-libs/hyprgraphics compiler-gcc-14
gui-libs/hyprland-qtutils compiler-gcc-14
gui-wm/hyprland compiler-gcc-14
gui-libs/hyprutils compiler-gcc-14
gui-libs/aquamarine compiler-gcc-14
dev-cpp/tomlplusplus compiler-gcc-14
gui-apps/hypridle compiler-gcc-14
gui-apps/hyprlock compiler-gcc-14
gui-apps/hyprpaper compiler-gcc-14
gui-libs/hyprcursor compiler-gcc-14
dev-libs/hyprlang compiler-gcc-14
dev-libs/hyprland-protocols compiler-gcc-14
dev-util/hyprwayland-scanner compiler-gcc-14


But in fact I would prefer not having to do this, but I am in kind of a dilemma: Since gcc-14 is still unstable, I don't want to compile my whole system with it. On the other hand, hyprland requires gcc-14 (for spurious reasons in my opinion). See: https://github.com/hyprwm/Hyprland/issues/7508

I don't think there is a way to do this properly, because it probably shouldn't be done at all, but if anybody has any suggestions as to how to do this better, I would also appreciate their opinion.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23062

PostPosted: Wed Jan 29, 2025 4:31 pm    Post subject: Reply with quote

gcc-14 looks stable to me.
Code:
$ git log -1 --pretty=%H' %ad'
64a22966158c5c78b0a350ca573ff7386b6d687c Tue Jan 28 17:10:37 2025 +0800
$ git grep KEYWORDS -- sys-devel/gcc/gcc-14.*
sys-devel/gcc/gcc-14.2.1_p20241221.ebuild:30:   KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86"
There are some keyword-masked newer versions, but the one shown is stable for the major platforms.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1050
Location: Somewhere in Denmark

PostPosted: Wed Jan 29, 2025 5:18 pm    Post subject: Reply with quote

Testing/mainly using gcc15 I've been using this for my /etc/portage/env/gcc14 for those packages that didn't yet play nice with gcc15
Code:
PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/14:${PATH}"
CC="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc"
CXX="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-g++"
AR="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-ar"
NM="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-nm"
RANLIB="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-ranlib"
Can't remember where - but found that somewhere on the forums here.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2113

PostPosted: Wed Jan 29, 2025 5:36 pm    Post subject: Reply with quote

freke wrote:
Testing/mainly using gcc15 I've been using this for my /etc/portage/env/gcc14 for those packages that didn't yet play nice with gcc15
Code:
PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/14:${PATH}"
CC="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc"
CXX="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-g++"
AR="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-ar"
NM="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-nm"
RANLIB="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-ranlib"
Can't remember where - but found that somewhere on the forums here.


You should really use workarounds wherever possible instead (like passing a particular flag as a workaround). You're free to ask me if you need help doing that.

Anyway, you don't need to do that -- you can do CC=x86_64-pc-linux-gnu-gcc-14 and so on instead.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1050
Location: Somewhere in Denmark

PostPosted: Wed Jan 29, 2025 5:39 pm    Post subject: Reply with quote

sam_ wrote:
freke wrote:
Testing/mainly using gcc15 I've been using this for my /etc/portage/env/gcc14 for those packages that didn't yet play nice with gcc15
Code:
PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/14:${PATH}"
CC="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc"
CXX="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-g++"
AR="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-ar"
NM="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-nm"
RANLIB="/usr/x86_64-pc-linux-gnu/gcc-bin/14/x86_64-pc-linux-gnu-gcc-ranlib"
Can't remember where - but found that somewhere on the forums here.


You should really use workarounds wherever possible instead (like passing a particular flag as a workaround). You're free to ask me if you need help doing that.

Anyway, you don't need to do that -- you can do CC=x86_64-pc-linux-gnu-gcc-14 and so on instead.


Thanks - I currently don't have any packages using my gcc14-env, though

I'm passing -std=gnu17 to three packages
Code:
## c23-porting
=dev-perl/Bit-Vector-7.400.0-r3 porting
=net-mail/dovecot-2.3.21.1-r1 porting
=net-misc/iperf-3.17.1 porting
Back to top
View user's profile Send private message
ZekeMorrin
n00b
n00b


Joined: 15 Oct 2023
Posts: 19

PostPosted: Wed Jan 29, 2025 5:47 pm    Post subject: Reply with quote

Thanks for all the good replies, these will be useful for me. And I second to that gcc-14 is pretty stable now, it's not even keyworded anymore. (~amd64)

I'll do it as @oneone did it;

Quote:
CC="gcc-14"
CPP="g++-14" # necessary for xorg-server and possibly other packages
CXX="g++-14"


but gcc-13 instead.

cuda package has hard dependency for gcc-13 but I'm not sure if it's using the compiler to install the package or just the libraries.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum