Last active
February 11, 2023 01:32
-
-
Save alexdelorenzo/866225bb5de796efc65a09371b4880e6 to your computer and use it in GitHub Desktop.
Get native CFLAGS for your host device. This will list the flags that are enabled on your hardware that are not enabled on the parent arch. https://alexdelorenzo.dev/notes/cflags
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
#!/usr/bin/env bash | |
# See: https://alexdelorenzo.dev/notes/cflags | |
# Requires `strs` package for Python: https://github.com/alexdelorenzo/strs/ | |
# License: AGPLv3 | |
export detectedArch="$(gcc -march=native -Q --help=target | grep march | str col 1 | str nth 0)" | |
export arch="${1:-$detectedArch}" | |
get-diff() { | |
diff \ | |
<(gcc -march=native -mtune=native -Q --help=target) \ | |
<(gcc -march=$arch -Q --help=target) | |
} | |
get-flags() { | |
grep "<" | grep "enabled" | str col 1 \ | |
| while read flag; do | |
printf "%s " "$flag" | |
done | |
printf '\n' | |
} | |
get-diff | get-flags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made a fork that doesn't require the
strs
package, just uses the widely availableawk
command. Very useful little script though, thanks for sharing!