1

When I input gcc -v, it just shows the same...

I have try it in Debian and it behaves normally..

I only meet this problem in arch and how can i fix it??

Andrew
  • 18,680
  • 13
  • 103
  • 118
iosmanthus
  • 71
  • 3
  • What do you mean by `gcc -v` shows the same? I would find it very unlikely that `gcc -v` shows its target as `unknown` in any working distro. `gcc` has its target defined at compilation time. – grochmal May 31 '16 at 17:05

1 Answers1

1

uname -i is non-portable according to man uname and it can be compiled out. My new Debian 8 also prints it as

$ uname -i
unknown

uname is part of the GNU coreutils and it is a very simple program. you can see the code on savannah. If you look through the command line option there --hardware-platform is -i:

  88 static struct option const uname_long_options[] =
  89 {
  90   {"all", no_argument, NULL, 'a'},
  ...
  97   {"machine", no_argument, NULL, 'm'},
  98   {"processor", no_argument, NULL, 'p'},
  99   {"hardware-platform", no_argument, NULL, 'i'},
 100   {"operating-system", no_argument, NULL, 'o'},
 101   {GETOPT_HELP_OPTION_DECL},
 102   {GETOPT_VERSION_OPTION_DECL},
 103   {NULL, 0, NULL, 0}
 104 };

Which forces the printing of the define PRINT_HARDWARE_PLATFORM

 198       while ((c = getopt_long (argc, argv, "asnrvmpio",
 199                                uname_long_options, NULL)) != -1)
 200         {
 201           switch (c)
 202             {
 ...
 227             case 'p':
 228               toprint |= PRINT_PROCESSOR;
 229               break;
 230 
 231             case 'i':
 232               toprint |= PRINT_HARDWARE_PLATFORM;
 233               break;

Which, in turn does the printing of "unknown" by default.

 344   if (toprint & PRINT_HARDWARE_PLATFORM)
 345     {
 346       char const *element = unknown;
 347 #if HAVE_SYSINFO && defined SI_PLATFORM
 348       {
 349         static char hardware_platform[257];
 350         if (0 <= sysinfo (SI_PLATFORM,
 351                           hardware_platform, sizeof hardware_platform))
 352           element = hardware_platform;
 353       }
 354 #endif

If i am not mistaken (i might be) HAVE_SYSINFO should be in sys/systeminfo.h, and that file is not present by default in arch. That does not necessarily mean that it was not there when the package was compiled. Yet, it shows that, most likely, the packager did not bother compiling the package with HAVE_SYSINFO properly setup. Which is acceptable since it is a non-portable option.


See my comment about gcc -v, my arch evaluates it correctly to Target: x86_64-pc-linux-gnu. But that has nothing to do with uname, uname sends system calls to print information about the system, gcc has the target compiled into it.


Note: saying that uname is part of coreutils is not 100% correct. uname is part of the POSIX standard, yet the -i (--hardware-platform) option to uname is not part of that specification. -i is only implemented by the coreutils package (hell, *BSD systems have -i but it has a completely different meaning there).

grochmal
  • 2,901
  • 2
  • 22
  • 28