When compiling any fortran program on Intel Darwin with -m64 -ffast-math, I get the following warning: ld64 warning: in /opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/x86_64/crtfastmath.o, file is not of required architecture This yields the failure of gfortran.dg/pr32533.f90 and gfortran.dg/pr33794.f90.
Can you get the same warning with a C program? And can you please post the output of running gfortran with -v, so that we know what subprocesses are invoked and what arguments they get passed?
> Can you get the same warning with a C program? Yes > And can you please post the output of running gfortran with -v [ibook-dhum] f90/bug% gfc -v -m64 -ffast-math ac.f90 Driving: gfc -mmacosx-version-min=10.4 -v -m64 -ffast-math ac.f90 -lgfortranbegin -lgfortran -shared-libgcc Using built-in specs. Target: i686-apple-darwin8 Configured with: ../gcc-4.3-work/configure --prefix=/opt/gcc/gcc4.3w --mandir=/opt/gcc/gcc4.3w/share/man --infodir=/opt/gcc/gcc4.3w/share/info --build=i686-apple-darwin8 --enable-languages=c,c++,fortran,objc,obj-c++ --with-gmp=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib Thread model: posix gcc version 4.3.0 20071108 (experimental) (GCC) COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-m64' '-ffast-math' '-shared-libgcc' '-mtune=generic' /opt/gcc/gcc4.3w/libexec/gcc/i686-apple-darwin8/4.3.0/f951 ac.f90 -fPIC -quiet -dumpbase ac.f90 -mmacosx-version-min=10.4 -m64 -mtune=generic -auxbase ac -version -ffast-math -fintrinsic-modules-path /opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/finclude -o /var/tmp//ccjovyzu.s GNU F95 (GCC) version 4.3.0 20071108 (experimental) (i686-apple-darwin8) compiled by GNU C version 4.3.0 20071108 (experimental), GMP version 4.2.1, MPFR version 2.2.1. GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-m64' '-ffast-math' '-shared-libgcc' '-mtune=generic' as -arch x86_64 -force_cpusubtype_ALL -o /var/tmp//cc5GHKYm.o /var/tmp//ccjovyzu.s COMPILER_PATH=/opt/gcc/gcc4.3w/libexec/gcc/i686-apple-darwin8/4.3.0/:/opt/gcc/gcc4.3w/libexec/gcc/i686-apple-darwin8/4.3.0/:/opt/gcc/gcc4.3w/libexec/gcc/i686-apple-darwin8/:/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/:/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/:/usr/libexec/gcc/i686-apple-darwin8/:/usr/lib/gcc/i686-apple-darwin8/ LIBRARY_PATH=/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/x86_64/:/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/../../../x86_64/:/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/:/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/../../../:/usr/lib/ COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-m64' '-ffast-math' '-shared-libgcc' '-mtune=generic' /opt/gcc/gcc4.3w/libexec/gcc/i686-apple-darwin8/4.3.0/collect2 -dynamic -arch x86_64 -macosx_version_min 10.4 -multiply_defined suppress -weak_reference_mismatches non-weak -o a.out -lcrt1.o /opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/x86_64/crt3.o -L/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/x86_64 -L/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/../../../x86_64 -L/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0 -L/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/../../.. /var/tmp//cc5GHKYm.o -lgfortranbegin -lgfortran -lgcc_s.10.4 -lgcc -lSystem /opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/x86_64/crtfastmath.o ld64 warning: in /opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/x86_64/crtfastmath.o, file is not of required architecture COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-m64' '-ffast-math' '-shared-libgcc' '-mtune=generic'
>/opt/gcc/gcc4.3w/lib/gcc/i686-apple-darwin8/4.3.0/x86_64/crtfastmath.o, file is not of required architecture Hmmm, this should have been compiled with -m64. Can you attach your build log for building GCC?
Subject: Re: Warning when compiling with -m64 -ffast-math on Intel Darwin > Hmmm, this should have been compiled with -m64. Can you attach your build log > for building GCC? The full log or only the part concerning crtfastmath.o?
Subject: Re: Warning when compiling with -m64 -ffast-math on Intel Darwin > this should have been compiled with -m64. Apparently it has not been with -m64: /opt/gcc/i686-darwin/./gcc/xgcc -B/opt/gcc/i686-darwin/./gcc/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/bin/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/lib/ -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/include -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/sys-include -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -I. -I/opt/gcc/i686-darwin/i686-apple-darwin8/x86_64/libgcc -I../../gcc-4.3-work/gcc -I../../gcc-4.3-work/gcc//opt/gcc/i686-darwin/i686-apple-darwin8/x86_64/libgcc -I../../gcc-4.3-work/gcc/../include -I../../gcc-4.3-work/gcc/../libcpp/include -I/sw/include -I../../gcc-4.3-work/gcc/../libdecnumber -I../../gcc-4.3-work/gcc/../libdecnumber/dpd -I../libdecnumber -g -O2 -fomit-frame-pointer -m64 \ -fno-tree-dominator-opts \ -c ../../gcc-4.3-work/gcc/config/darwin-crt3.c -o /opt/gcc/i686-darwin/i686-apple-darwin8/x86_64/libgcc/crt3.o /opt/gcc/i686-darwin/./gcc/xgcc -B/opt/gcc/i686-darwin/./gcc/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/bin/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/lib/ -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/include -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/sys-include -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -msse -minline-all-stringops -c \ ../../gcc-4.3-work/gcc/config/i386/crtfastmath.c \ -o /opt/gcc/i686-darwin/i686-apple-darwin8/x86_64/libgcc/crtfastmath.o /opt/gcc/i686-darwin/./gcc/xgcc -B/opt/gcc/i686-darwin/./gcc/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/bin/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/lib/ -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/include -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/sys-include -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -D__PREC=32 -c \ ../../gcc-4.3-work/gcc/config/i386/crtprec.c \ -o /opt/gcc/i686-darwin/i686-apple-darwin8/x86_64/libgcc/crtprec32.o /opt/gcc/i686-darwin/./gcc/xgcc -B/opt/gcc/i686-darwin/./gcc/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/bin/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/lib/ -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/include -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/sys-include -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -D__PREC=64 -c \ ../../gcc-4.3-work/gcc/config/i386/crtprec.c \ -o /opt/gcc/i686-darwin/i686-apple-darwin8/x86_64/libgcc/crtprec64.o /opt/gcc/i686-darwin/./gcc/xgcc -B/opt/gcc/i686-darwin/./gcc/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/bin/ -B/opt/gcc/gcc4.3w/i686-apple-darwin8/lib/ -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/include -isystem /opt/gcc/gcc4.3w/i686-apple-darwin8/sys-include -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -D__PREC=80 -c \ ../../gcc-4.3-work/gcc/config/i386/crtprec.c \ -o /opt/gcc/i686-darwin/i686-apple-darwin8/x86_64/libgcc/crtprec80.o
Note that I still get the warning after having recompiled gcc/config/i386/crtfastmath.c with -m64.
I find the following works here... cd /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/gcc ./xgcc -m64 -B./ -B/sw/lib/gcc4.3/i686-apple-darwin9/bin/ -isystem /sw/lib/gcc4.3/i686-apple-darwin9/include -isystem /sw/lib/gcc4.3/i686-apple-darwin9/sys-include -L/sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/gcc/../ld -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -msse -minline-all-stringops -c ../../gcc-4.3-20071214/gcc/config/i386/crtfastmath.c -o x86_64/crtfastmath.o This eliminates the failures in make check at -m64. I wonder if we really shouldn't be using lines like... EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o \ crtbeginT.o crtprec32.o crtprec64.o crtprec80.o \ crtfastmath.o from gcc/config/i386/t-linux64 for t-darwin? On x86-64 linux, a build of gcc trunk properly creates the correct architecture of crtfastmath.o in the 32 subdirectory. Or alternatively maybe it would be sufficient to just add crtfastmath.o to the line... # How to build crt3.o EXTRA_MULTILIB_PARTS=crt3.o in gcc/config/t-darwin since that seems to properly build the correct architecture of crt3.o for the x86_64 subdirectory on i686-apple-darwin9.
Hmmm... I see... file *.o crt3.o: Mach-O 64-bit object x86_64 crtfastmath.o: Mach-O object i386 crtprec32.o: Mach-O object i386 crtprec64.o: Mach-O object i386 crtprec80.o: Mach-O object i386 in /sw/lib/gcc4.3/lib/gcc/i686-apple-darwin9/4.3.0/x86_64. This makes me wonder if we shouldn't really have... --- gcc-4.3-20071214/gcc/config/t-darwin.org 2007-12-15 16:37:44.000000000 -0500 +++ gcc-4.3-20071214/gcc/config/t-darwin 2007-12-15 16:38:24.000000000 -0500 @@ -18,7 +18,7 @@ $(srcdir)/config/darwin-driver.c # How to build crt3.o -EXTRA_MULTILIB_PARTS=crt3.o +EXTRA_MULTILIB_PARTS=crt3.o crtfastmath.o crtprec32.o crtprec64.o crtprec80.o # Pass -fno-tree-dominator-opts to work around bug 26840. $(T)crt3$(objext): $(srcdir)/config/darwin-crt3.c $(GCC_PASSES) \ $(TCONFIG_H) stmp-int-hdrs tsystem.h I'll try a test build of that next.
This should probably be added as... -- gcc-4.3-20071214/gcc/config/i386/t-darwin.org 2007-12-15 18:12:06.000000000 -0500 +++ gcc-4.3-20071214/gcc/config/i386/t-darwin 2007-12-15 18:12:43.000000000 -0500 @@ -2,6 +2,7 @@ MULTILIB_DIRNAMES = x86_64 LIB2_SIDITI_CONV_FUNCS=yes LIB2FUNCS_EXTRA = $(srcdir)/config/darwin-64.c +EXTRA_MULTILIB_PARTS=crtfastmath.o crtprec32.o crtprec64.o crtprec80.o softfp_wrap_start := '\#ifdef __x86_64__' softfp_wrap_end := '\#endif' instead. Testing that now.
The last formulation doesn't fix the problem.
For some reason the last change isn't forcing the MULTILIB_CFLAGS to actually be used on the build lines for the objects added to EXTRA_MULTILIB_PARTS. # Recursively invoke make in the GCC directory to build any # startfiles (for now). We must do this just once, passing # it all the GCC_EXTRA_PARTS as simultaneous goal targets, # so that rules which cannot execute simultaneously are properly # serialized. We indirect through T_TARGET in case any multilib # directories contain an equals sign, to prevent make from # interpreting any of the goals as variable assignments. # We must use cd && make rather than make -C, or else the stage # number will be embedded in debug information. T=`${PWDCMD-pwd}`/ \ && cd ../../.././gcc \ && make GCC_FOR_TARGET="/sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/xgcc -B/sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/ -B/sw/lib/gcc4.3/i686-apple-darwin9/bin/ -B/sw/lib/gcc4.3/i686-apple-darwin9/lib/ -isystem /sw/lib/gcc4.3/i686-apple-darwin9/include -isystem /sw/lib/gcc4.3/i686-apple-darwin9/sys-include" \ MULTILIB_CFLAGS="-g -O2 -fomit-frame-pointer -m64" \ T=$T \ T_TARGET="${T}crtfastmath.o ${T}crtprec32.o ${T}crtprec64.o ${T}crtprec80.o" \ T_TARGET /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/xgcc -B/sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/ -B/sw/lib/gcc4.3/i686-apple-darwin9/bin/ -B/sw/lib/gcc4.3/i686-apple-darwin9/lib/ -isystem /sw/lib/gcc4.3/i686-apple-darwin9/include -isystem /sw/lib/gcc4.3/i686-apple-darwin9/sys-include -O2 -O2 -g -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -msse -minline-all-stringops -c \ ../../gcc-4.3-20071214/gcc/config/i386/crtfastmath.c \ -o /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/i686-apple-darwin9/x86_64/libgcc/crtfastmath.o /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/xgcc -B/sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/ -B/sw/lib/gcc4.3/i686-apple-darwin9/bin/ -B/sw/lib/gcc4.3/i686-apple-darwin9/lib/ -isystem /sw/lib/gcc4.3/i686-apple-darwin9/include -isystem /sw/lib/gcc4.3/i686-apple-darwin9/sys-include -O2 -O2 -g -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -D__PREC=32 -c \ ../../gcc-4.3-20071214/gcc/config/i386/crtprec.c \ -o /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/i686-apple-darwin9/x86_64/libgcc/crtprec32.o /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/xgcc -B/sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/ -B/sw/lib/gcc4.3/i686-apple-darwin9/bin/ -B/sw/lib/gcc4.3/i686-apple-darwin9/lib/ -isystem /sw/lib/gcc4.3/i686-apple-darwin9/include -isystem /sw/lib/gcc4.3/i686-apple-darwin9/sys-include -O2 -O2 -g -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -D__PREC=64 -c \ ../../gcc-4.3-20071214/gcc/config/i386/crtprec.c \ -o /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/i686-apple-darwin9/x86_64/libgcc/crtprec64.o /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/xgcc -B/sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/./gcc/ -B/sw/lib/gcc4.3/i686-apple-darwin9/bin/ -B/sw/lib/gcc4.3/i686-apple-darwin9/lib/ -isystem /sw/lib/gcc4.3/i686-apple-darwin9/include -isystem /sw/lib/gcc4.3/i686-apple-darwin9/sys-include -O2 -O2 -g -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -D__PREC=80 -c \ ../../gcc-4.3-20071214/gcc/config/i386/crtprec.c \ -o /sw/src/fink.build/gcc43-4.2.999-20071214/darwin_objdir/i686-apple-darwin9/x86_64/libgcc/crtprec80.o
I can't help but wonder if this issue is due to the fact that darwin is the only architecture that uses a single value for MULTILIB_OPTIONS. We only have... MULTILIB_OPTIONS = m64 whereas all the other architectures seem to have something like... MULTILIB_OPTIONS = m64/m32 I'll take a stab at changing this to... MULTILIB_OPTIONS = m32/m64
The last change just creates an endless loop in the build.
Created attachment 14775 [details] add missing MULTILIB_CFLAGS
The problem was that gcc/config/i386/t-crtpc and gcc/config/i386/t-crtfm had build commands which didn't use MULTILIB_CFLAGS. Now that those are added all of the object files in the x86_64 subdirectory are of the proper architecture.
The patch in comment #14 fix the problem for me. Thanks Jack for the debugging and the patch.
Subject: Bug 34025 Author: uros Date: Sun Dec 16 23:22:30 2007 New Revision: 130998 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130998 Log: PR target/34025 * config/i386/t-crtpc: Add $(MULTILIB_CFLAGS). * config/i386/t-crtfm: Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/t-crtfm trunk/gcc/config/i386/t-crtpc
This pr has been fixed by revision 130998.