Forums

Skip to content

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

[SOLVED] CPU_FLAGS, -march, or both?

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
7 posts • Page 1 of 1
Author
Message
ShrekMovieFreeLegit
n00b
n00b
Posts: 3
Joined: Wed Dec 30, 2020 4:35 pm

[SOLVED] CPU_FLAGS, -march, or both?

  • Quote

Post by ShrekMovieFreeLegit » Wed Nov 24, 2021 9:21 am

Hello. I’m new to both Gentoo and the forums so I apologise if this isn’t the right place to post

What I’m asking is if I should use either CPU_FLAGS or -march in my make.conf?
To clarify, I’ve read somewhere that using both could potentially break some packages (don’t remember exactly which but I’m pretty sure it’s either ffmpeg or something related to mozilla). I wanted to know which of these are better for more optimised packages (i. e. compiles faster), or if I could just use both safely without any breakage.

Thanks! :D
Last edited by ShrekMovieFreeLegit on Wed Nov 24, 2021 1:26 pm, edited 1 time in total.
Top
soundrolf
Apprentice
Apprentice
Posts: 158
Joined: Thu Sep 08, 2016 3:57 pm
Location: Cologne / Germany

  • Quote

Post by soundrolf » Wed Nov 24, 2021 11:51 am


My make.conf

Code: Select all

# Compiler Settings
COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

# CPU FLAGS: AMD FX(tm)-6100 Six-Core Processor CPU Family: 21
CPU_FLAGS_X86="aes avx fma4 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop"
CHOST="x86_64-pc-linux-gnu"

# USE flags
USE="truetype elogind -consolekit -ipv6 -kde -gnome -systemd -pulseaudio 
smp usb alsa v4l -aim -infiniband -cjk -qt4 icu -oci8 -oscar -joystick 
-libav ffmpeg dbus dvd dvb cdr nls sockets twolame usb X udev udisks 
libnotify thunar xinerama qt5 -xscreensaver vdpau ${CPU_FLAGS_X86}"

# USE_EXPAND flags
PORTDIR="/usr/portage"
PORTAGE_LOGDIR="/var/log/portage_log"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
MAKEOPTS="-j6"
GENTOO_MIRRORS="http://mirror.netcologne.de/gentoo/ https:ftp.halifax.rwth-aachen.de/gentoo/"
ACCEPT_LICENSE="*"
ACCEPT_KEYWORDS="amd64"
LINGUAS="de"
L10N="de"
LC_MESSAGES="C"
GRUB_PLATFORMS="pc"
LLVM_TARGETS="X86-64 AMDGPU"
VIDEO_CARDS="fbdev radeon nouveau v4l vesa amdgpu"
ALSA_CARDS="hda-intel"
INPUT_DEVICES="evdev synaptics"
KDIR="/usr/src/linux"
XFCE_PLUGINS="menu clock trash"
RUBY_TARGETS="ruby26 ruby27"
# EMERGE_DEFAULT_OPTS="--quiet-build"
# EMERGE_DEFAULT_OPTS="--with-bdeps=y"
Regards

soundrolf
Regards
soundrolf

MOBO: ASUS PRIME B550M-K BIOS 4101 10/16/2025
CPU: AMD Ryzen 9 5900X 12-Core Processor (24) @ 3800 MHz
GPU: AMD Navi 24 [Radeon RX 6400/6500 XT/6500M] driver: amdgpu
RAM: 80GB crucial DDR4 3200 MHz 2x8GB 2x32GB
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31985
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Wed Nov 24, 2021 12:35 pm

The CPU_FLAGS_X86 is used by portage as use flag for some package that allow you to enable or disable certain cpu flags and you can use app-portage/cpuid2cpuflags for set correct values.
With -march=native gcc automagically enable correct flag for your cpu and them are used in all package when compiling (unless a package forces something else but for the user it is transparent).
I don't know where you read that these two settings can break some packages but if it happens it's definitely a bug to report.
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
ShrekMovieFreeLegit
n00b
n00b
Posts: 3
Joined: Wed Dec 30, 2020 4:35 pm

  • Quote

Post by ShrekMovieFreeLegit » Wed Nov 24, 2021 1:26 pm

fedeliallalinea wrote:With -march=native gcc automagically enable correct flag for your cpu
So basically, -march=native should do the same as CPU_FLAGS_X86. Thanks a lot!
gentoo is actually pretty fun if you can get it working
Top
figueroa
Advocate
Advocate
User avatar
Posts: 3032
Joined: Sun Aug 14, 2005 8:15 pm
Location: Edge of marsh USA
Contact:
Contact figueroa
Website

  • Quote

Post by figueroa » Thu Nov 25, 2021 5:34 am

Use them both. Emerge and run app-portage/cpuid2cpuflags.
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi -wayland
Top
Hu
Administrator
Administrator
Posts: 24386
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Thu Nov 25, 2021 5:28 pm

ShrekMovieFreeLegit wrote:So basically, -march=native should do the same as CPU_FLAGS_X86. Thanks a lot!
No. -march=native tells gcc to use whatever natively available instructions it wants when generating assembly from C/C++. This generally happens on a fairly granular level, like using xmm instructions for bulk copying of small structures. It will usually not have a large scope view, such as completely changing how a function is implemented. CPU_FLAGS_X86 is used to advise particular packages to enable whole optional features. Such features are dozens or hundreds of lines long, and rely on a given CPU feature throughout. The complexity of the tool feature precludes trusting gcc to just guess that a few statements here and there ought to use the CPU feature. That is why you should use both: -march lets gcc opportunistically use advanced CPU features when specific C statements can be done better. CPU_FLAGS_X86 lets a tool build an entirely different code path, which presumably is more efficient than the generic alternative. (In some cases, the tool's maintainers may have decided not to write the generic version at all, so you don't even get the tool's feature, even in a slow inefficient version, if you don't enable the right CPU_FLAGS_X86.)
Top
CaptainBlood
Advocate
Advocate
User avatar
Posts: 4237
Joined: Sun Jan 24, 2010 9:38 am

  • Quote

Post by CaptainBlood » Thu Nov 25, 2021 5:57 pm

figueroa wrote:Use them both. Emerge and run app-portage/cpuid2cpuflags.
+1
Thks 4 ur attention, interest & support.
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Top
Post Reply

7 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