This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

-march, -mcpu and preprocessor


There is a bug (or inconsistensy with the manual) in how GCC handles
-march and -mcpu options. GCC is version 2.95.1, configured for
and running on i586-linux.

The manual (Node: i386 Options) says:

  `-march=CPU TYPE'
       Generate instructions for the machine type CPU TYPE.  The choices
       for CPU TYPE are the same as for `-mcpu'.  Moreover, specifying
       `-march=CPU TYPE' implies `-mcpu=CPU TYPE'.

So "-march=XXX" must be equivalent to "-march=XXX -mcpu=XXX".
However there is at least one difference: cpp is called with different
options. From gcc-2.95.1 configured for i586-linux:

  ~$ gcc -v -march=i486 -mcpu=i486 a.c
  Reading specs from /usr/lib/gcc-lib/i586-pc-linux/2.95.1/specs
  gcc version 2.95.1 19990816 (release)
   /usr/lib/gcc-lib/i586-pc-linux/2.95.1/cpp -lang-c -v -D__GNUC__=2
  -D__GNUC_MINOR__=95 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__
  -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix)
  -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di486 -D__i486
  -D__i486__ a.c /tmp/ccJiCNo1.i
  [...]

  ~$ gcc -v -march=i486 a.c
  Reading specs from /usr/lib/gcc-lib/i586-pc-linux/2.95.1/specs
  gcc version 2.95.1 19990816 (release)
   /usr/lib/gcc-lib/i586-pc-linux/2.95.1/cpp -lang-c -v -D__GNUC__=2
  -D__GNUC_MINOR__=95 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__
  -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix)
  -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di586 -Dpentium
  -D__i586 -D__i586__ -D__pentium -D__pentium__ a.c /tmp/cc62ftde.i
  [...]

The defines are different ("i486" vs. "i586" and "pentium").
This affects glibc headers in particular.

If I try i586 options (with the same i586-configured gcc),
the results are funny. -march=i586 does not change anything in
cpp options (__i586__ and the like are defined anyway), but
-mcpu=i586 makes __i586__ undefined!  How can I force compilation
for i586 with gcc configured for an unknown ix86?

A similar problem exists with i686 names. The manual says that
-mcpu=i686 is equivalent to -mcpu=pentiumpro. But -mcpu=i686
does not define any CPU macros at all (!), while -mcpu=pentiumpro
defines __i686__, __pentiumpro__ etc.

Cheers,
  Sergei


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]