15

I would like to know why when I run gcc -v under Arch Linux, it shows the unknown word in these outputs:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu

while in other distro, like ubuntu it shows the distro name, like, ubuntu:

 Using built-in specs.
 COLLECT_GCC=gcc
 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-ubuntu-linux-gnu/5.1.0/lto-wrapper
 Target: x86_64-ubuntu-linux-gnu
noslin005
  • 191
  • 1
  • 2
  • 7

2 Answers2

10

As it was already mentioned in the comment, by default the target triplet is generated by config.guess script. It's logic is fairly simple. First it uses uname to get some basic system information:

UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown

These strings are combined and matched against hardcoded patterns. The result is also hardcoded:

case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
...(snip)...
    x86_64:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
...(snip)...

For some systems it is possible to give more meaningful result, like IBM in "rs6000-ibm-aix".

Distribution maintainers simply override this string with their own (also hardcoded):

$ gcc -v
...(snip)...
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10'
...(snip)...
--target=x86_64-linux-gnu

GCC 6 will probably output x86_64-pc-linux-gnu by default: updated config.guess in the upstream repository.

Mikhail Maltsev
  • 200
  • 1
  • 5
6

That's the manufacterer part of the configuration/target triplet. The Autobook says about that:

manufacturer
   A somewhat freeform field which indicates the manufacturer of the system. This is often simply `unknown'. Other common strings are `pc' for an IBM PC compatible system, or the name of a workstation vendor, such as `sun'.

The autoconf manual calls it company.

I'm not an expert in compilation with GCC, but it sounds like the information provided by that field is more of informational nature and unknown is just the default value GCC uses unless explicitly overwritten. GCC on Ubuntu 12.04 for example uses x86_64-linux-gnu, Debian 7s GCC i486-linux-gnu, so it's entirely possible to leave the field empty.

Wieland
  • 6,353
  • 3
  • 28
  • 31
  • That's pretty much it. The `x86_64-linux-gnu` variety are shortcut targets, standing for `x86_64-unknown-linux-gnu` or `x86_64-pc-linux-gnu`. `gcc -v` shows the target it was compiled for, and `config.sub` gives the canonical triplet (look for it in `/usr/share/misc` on Debian-derived systems with `autotools-dev` installed). – Stephen Kitt May 30 '15 at 08:44