Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a gcc option to print the target triplet when cross-compiling?

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
like image 536
Tavian Barnes Avatar asked Feb 13 '15 17:02

Tavian Barnes


1 Answers

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
like image 116
Grodriguez Avatar answered Sep 20 '22 05:09

Grodriguez