Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CFLAGS for chroot-build with incompatible CPU types
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
nagmat84
Apprentice
Apprentice


Joined: 27 Mar 2007
Posts: 218

PostPosted: Tue Apr 02, 2024 8:32 pm    Post subject: CFLAGS for chroot-build with incompatible CPU types Reply with quote

I try to set up a build server for my old laptop following the guide https://wiki.gentoo.org/wiki/Binary_package_guide#Handling_.2AFLAGS_in_detail. My laptop is a Lenovo X1 Carbon 3rd Gen. My future build server is based on an AMD EPYC 7702P. Currently, I try to figure out what CFLAGS I can/should use such that the binary packages from the build server also run on the laptop.

resolve-march-native gives
Code:

Build server:     -march=znver2                -mno-mwaitx -mno-xsaves --param=l1-cache-line-size=64 --param=l1-cache-size=64 --param=l2-cache-size=512
Client (laptop):  -march=broadwell -mabm -maes                         --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=3072

cpuid2cpuflags gives
Code:

Build server:     CPU_FLAGS_X86: aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3
Client (laptop):  CPU_FLAGS_X86: aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand     sse sse2 sse3 sse4_1 sse4_2       ssse3

(indentation by myself for easier comparison.)

According, to https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html the CPU types Broadwell and Zen v2 are incompatible (neither is a superset of the other).
Instruction set extensions supported by both CPU types:
  • ABM
  • ADCX
  • AES
  • AVX
  • AVX2
  • BMI
  • BMI2
  • CX16
  • F16C
  • FMA
  • FSGSBASE
  • MMX
  • MOVBE
  • PCLMUL
  • POPCNT
  • RDSEED
  • SSE
  • SSE2
  • SSE3
  • SSE4.1
  • SSE4.2
  • SSSE3
Instruction set extensions only supported by Broadwell:
  • FXSR
  • HLE
  • LZCNT
  • PREFETCHW
  • RDRND
  • SAHF
  • XSAVE
Instruction set extensions only supported by Zen v2:
  • CLFLUSHOPT
  • CLWB
  • CLZERO
  • RDPID
  • SHA
  • SSE4A
  • WBNOINVD
  • XSAVEC
(At least this is how I understand that manual page.) From what I understand, a safe, conservative selection for CFLAGS would be
Code:
CFLAGS="-march=x86-64 -mtune=broadwell"
However, I wonder if I should at least add the instruction set extensions which have both CPU types in common, i.e. whether
Code:
CFLAGS="-march=x86-64 -mtune=broadwell -mabm -maes -mavx -mavx2 -mbmi -mbmi2 -mcx16 -mf16c -mfma -mfsgsbase -mmmx -mmovbe -mpclmul -mpopcnt -mrdseed -msse -msse2 -mssse3 -msse4.1 -msse4.2 -msse3"
would provide any benefits.
  • Would it work?
  • Does it improve anything?


Last edited by nagmat84 on Wed Apr 03, 2024 3:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
netfab
Veteran
Veteran


Joined: 03 Mar 2005
Posts: 1902
Location: 127.0.0.1

PostPosted: Wed Apr 03, 2024 7:26 am    Post subject: Reply with quote

Hi,

Yes, I think you should.
Somewhere in the gcc manual you can find :
Quote:

There is no -march=generic option because -march indicates the instruction set the compiler can use, and there is no
generic instruction set applicable to all processors.

Since you want to use -march=x86-64 you should add instructions you want to enable.
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