Last active
August 31, 2019 20:18
-
-
Save user5145/2a638892ef14a5d55a118503ff9daa81 to your computer and use it in GitHub Desktop.
common cpu flags for gcc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# instructions supported by everything from this century (bulldozer(Steamroller)+, Sandy Bridge+) | |
# these good ones are not included -mxsavec -mxsaves -mavx2 | |
# these may slow down -ftree-vectorize -ftree-slp-vectorize | |
FLAGS_TEMP="-mtune=generic -O2 -g -pipe -fstack-protector-strong -fno-plt -frecord-gcc-switches -D_FORTIFY_SOURCE=2 -msse -msse2 -mssse3 -msse3 -msse4.1 -msse4.2 -mfpmath=sse -msse2avx -mavx -maes -mbmi -mbmi2 -mxsave -mxsaveopt -msahf -mprfchw -mcx16" | |
# | |
# these instructions are for everything usable | |
FLAGS_TEMP="-mtune=generic -O2 -g -pipe -fstack-protector-strong -fno-plt -frecord-gcc-switches -D_FORTIFY_SOURCE=2 -msse -msse2 -mssse3 -msse3 -msse4.1 -msse4.2 -mfpmath=sse -msse2avx -mavx -mavx2 -maes -mbmi -mbmi2 -mxsave -mxsavec -mxsaveopt -mxsaves -msahf -mprfchw -mcx16" | |
# | |
# the same but with some legacy flags | |
FLAGS_TEMP="-mtune=generic -O2 -g -pipe -fstack-protector-strong -fno-plt -frecord-gcc-switches -D_FORTIFY_SOURCE=2 -msse -msse2 -mssse3 -msse3 -msse4.1 -msse4.2 -mfpmath=sse -msse2avx -mavx -mavx2 -maes -mbmi -mbmi2 -mpopcnt -mlzcnt -mfma -mf16c -mpclmul -mxsave -mxsavec -mxsaveopt -mxsaves -msahf -mprfchw -mcx16" | |
# | |
# This is for fun | |
FLAGS_TEMP="-march=native -mtune=native -O2 -g -pipe -fstack-protector-strong -fno-plt -frecord-gcc-switches -D_FORTIFY_SOURCE=2" | |
# | |
# these shouldn't worry people too much when used in public sources | |
FLAGS_TEMP="-O2 -g -pipe -fstack-protector-strong -fno-plt -frecord-gcc-switches -D_FORTIFY_SOURCE=2 -msse -msse2 -msse3 -mssse3 -mfpmath=sse -msahf -mprfchw -mcx16" | |
# LDFLAGS="-Wl,-O2,--sort-common,--as-needed,-z,relro,-z,now" | |
LDFLAGS="-fstack-protector-strong -Wl,-z,relro,-z,now" | |
CPPFLAGS=$FLAGS_TEMP | |
CXXFLAGS=$FLAGS_TEMP | |
CFLAGS=$FLAGS_TEMP | |
MAKEFLAGS="-j5" | |
# to check flags | |
gcc -march=generic -Q --help=target | |
### What to know | |
# mac os uses ssse3 or higher for everything | |
# windows requires sse2 -mcx16 -mprfchw -msahf | |
# pre BMI1 -mpopcnt -mlzcnt aka ABM, but for long intel ignored lzcnt until they used it as a part of their new extension... so only popcnt is viable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment