Bug 747372

Summary: gcc wont compile math.h with -march=native -O
Product: [Fedora] Fedora Reporter: Christoph Breitkopf <chbreitkopf>
Component: glibcAssignee: Jeff Law <law>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 16CC: fweimer, jakub, schwab
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-26 20:41:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Christoph Breitkopf 2011-10-19 16:06:27 UTC
Description of problem:

gcc will report an error when compiling any c program that includes <math.h> when invoked with the options -march=native and -O (also O2, O3)


Version-Release number of selected component (if applicable):

gcc version 4.6.1 20111003 (Red Hat 4.6.1-10) (GCC)

How reproducible:

always

Steps to Reproduce:
1. Save this as foo.c:
----- cut here -----
#include <math.h>
int main(int argc, char **argv) { return (int) ceil(2.3); }
----- cut here -----

2. gcc -match=native -O foo.c
  
Actual results:

[user@system ~]$ gcc -march=native -O foo.c
In file included from /usr/include/math.h:417:0,
                 from foo.c:1:
/usr/include/bits/mathinline.h:190:1: error: redefinition of ‘ceil’
/usr/include/bits/mathinline.h:200:1: error: redefinition of ‘ceilf’


Expected results:

No errors, executable a.out is created, and ./a.out prints 3

Additional info:

Comment 1 Christoph Breitkopf 2011-10-19 16:08:46 UTC
Oops, the example program won't print 3, of course.
Expected result is:
$ ./a.out
$ echo $?
3

Comment 2 Jakub Jelinek 2011-10-20 08:09:01 UTC
Likely a a glibc header bug, but -march=native is ambiguous, it can mean a lot of options depending on different hw, so please post gcc -march=native -O foo.c -v
output which will list what is actually passed to cc1.

Comment 3 Christoph Breitkopf 2011-10-20 08:40:21 UTC
Here's the output of gcc -march=native -O foo.c -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.6.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.6.1 20111003 (Red Hat 4.6.1-10) (GCC) 
COLLECT_GCC_OPTIONS='-march=native' '-O' '-v'
 /usr/libexec/gcc/x86_64-redhat-linux/4.6.1/cc1 -quiet -v foo.c -march=core2 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx -mno-sse4.2 -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=core2 -quiet -dumpbase foo.c -auxbase foo -O -version -o /tmp/cchiSk1U.s
GNU C (GCC) version 4.6.1 20111003 (Red Hat 4.6.1-10) (x86_64-redhat-linux)
	compiled by GNU C version 4.6.1 20111003 (Red Hat 4.6.1-10), GMP version 4.3.2, MPFR version 3.0.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.6.1/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.6.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/4.6.1/include
 /usr/local/include
 /usr/include
End of search list.
GNU C (GCC) version 4.6.1 20111003 (Red Hat 4.6.1-10) (x86_64-redhat-linux)
	compiled by GNU C version 4.6.1 20111003 (Red Hat 4.6.1-10), GMP version 4.3.2, MPFR version 3.0.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 31e268251477f7cecc907ba6eb82b846
In file included from /usr/include/math.h:417:0,
                 from foo.c:1:
/usr/include/bits/mathinline.h:190:1: error: redefinition of ‘ceil’
/usr/include/bits/mathinline.h:200:1: error: redefinition of ‘ceilf’

Comment 4 Christoph Breitkopf 2011-10-25 16:46:49 UTC
No long reproducible after updating today. I suspect that the latest glibc update fixed this problem (glibc-2.14.90-13.x86_64), as there was no gcc update.

Comment 5 Fedora Admin XMLRPC Client 2011-11-14 19:15:26 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 6 Jeff Law 2012-01-26 20:41:10 UTC
Yea, that was an upstream fix we picked up in the -13 update.