gcc -dumpmachine
is almost perfect, but it doesn't respect flags that affect the target. On the other hand, clang
does:
$ gcc -dumpmachine
x86_64-unknown-linux-gnu
$ gcc -dumpmachine -m32
x86_64-unknown-linux-gnu
$ clang -dumpmachine
x86_64-unknown-linux-gnu
$ clang -dumpmachine -m32
i386-unknown-linux-gnu
Perhaps -print-multiarch
is useful. According to the documentations, this option "display the target's normalized GNU triplet, used as a component in the library path".
In my box (x86_64) I get:
$ gcc -print-multiarch
x86_64-linux-gnu
$ gcc -print-multiarch -m32
i386-linux-gnu
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With