Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

Specific GCC version per package basis

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
10 posts • Page 1 of 1
Author
Message
ZekeMorrin
n00b
n00b
User avatar
Posts: 29
Joined: Sun Oct 15, 2023 2:18 pm
Contact:
Contact ZekeMorrin
Website

Specific GCC version per package basis

  • Quote

Post by ZekeMorrin » Wed Jan 29, 2025 12:18 pm

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!
Top
leonik375
n00b
n00b
Posts: 12
Joined: Tue Jul 19, 2016 4:17 pm

  • Quote

Post by leonik375 » Wed Jan 29, 2025 12:56 pm

Did you try this?
viewtopic-p-7996118.html#7996118
Top
grknight
Retired Dev
Retired Dev
Posts: 2565
Joined: Fri Feb 20, 2015 9:36 pm

  • Quote

Post by grknight » Wed Jan 29, 2025 1:43 pm

Beware of errors stemming from C++ library mismatches if this is attempted.
Top
oneone
Tux's lil' helper
Tux's lil' helper
Posts: 113
Joined: Wed Sep 20, 2017 12:45 pm

  • Quote

Post by oneone » Wed Jan 29, 2025 3:44 pm

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: Select all

# 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: Select all

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.
Top
Hu
Administrator
Administrator
Posts: 24403
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Wed Jan 29, 2025 4:31 pm

gcc-14 looks stable to me.

Code: Select all

$ 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.
Top
freke
Veteran
Veteran
Posts: 1136
Joined: Thu Jan 23, 2003 3:17 pm
Location: Somewhere in Denmark
Contact:
Contact freke
Website

  • Quote

Post by freke » Wed Jan 29, 2025 5:18 pm

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: Select all

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.
Top
sam_
Developer
Developer
User avatar
Posts: 2817
Joined: Fri Aug 14, 2020 12:33 am

  • Quote

Post by sam_ » Wed Jan 29, 2025 5:36 pm

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: Select all

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.
Top
freke
Veteran
Veteran
Posts: 1136
Joined: Thu Jan 23, 2003 3:17 pm
Location: Somewhere in Denmark
Contact:
Contact freke
Website

  • Quote

Post by freke » Wed Jan 29, 2025 5:39 pm

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: Select all

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: Select all

## 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
Top
ZekeMorrin
n00b
n00b
User avatar
Posts: 29
Joined: Sun Oct 15, 2023 2:18 pm
Contact:
Contact ZekeMorrin
Website

  • Quote

Post by ZekeMorrin » Wed Jan 29, 2025 5:47 pm

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;
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.
Top
oneone
Tux's lil' helper
Tux's lil' helper
Posts: 113
Joined: Wed Sep 20, 2017 12:45 pm

  • Quote

Post by oneone » Fri Jan 31, 2025 11:35 am

Thanks for all the answers as well. I was not aware that gcc did become stable since the last time I checked. Time for me to upgrade :)
Top
Post Reply

10 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic