View previous topic :: View next topic |
Author |
Message |
ZekeMorrin n00b
Joined: 15 Oct 2023 Posts: 19
|
Posted: Wed Jan 29, 2025 12:18 pm Post subject: Specific GCC version per package basis |
|
|
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 |
|
|
leonik375 n00b
Joined: 19 Jul 2016 Posts: 10
|
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1999
|
Posted: Wed Jan 29, 2025 1:43 pm Post subject: |
|
|
Beware of errors stemming from C++ library mismatches if this is attempted. |
|
Back to top |
|
|
oneone Tux's lil' helper
Joined: 20 Sep 2017 Posts: 104
|
Posted: Wed Jan 29, 2025 3:44 pm Post subject: |
|
|
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 |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 23062
|
Posted: Wed Jan 29, 2025 4:31 pm Post subject: |
|
|
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 |
|
|
freke Veteran
Joined: 23 Jan 2003 Posts: 1050 Location: Somewhere in Denmark
|
Posted: Wed Jan 29, 2025 5:18 pm Post subject: |
|
|
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 |
|
|
sam_ Developer
Joined: 14 Aug 2020 Posts: 2113
|
Posted: Wed Jan 29, 2025 5:36 pm Post subject: |
|
|
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 |
|
|
freke Veteran
Joined: 23 Jan 2003 Posts: 1050 Location: Somewhere in Denmark
|
Posted: Wed Jan 29, 2025 5:39 pm Post subject: |
|
|
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 |
|
|
ZekeMorrin n00b
Joined: 15 Oct 2023 Posts: 19
|
Posted: Wed Jan 29, 2025 5:47 pm Post subject: |
|
|
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 |
|
|
|