Hello. What is the right way to pass optimization flags when building GCC and when building cross-GCC? At first I tried to build native gcc, I ran configure this way (I tried 4.8.2 release and 4.9.0 from svn): $ flags='-march=core2 -mtune=core2 -O2 -pipe' $ ../gcc/configure CFLAGS="$flags" CXXFLAGS="$flags" --with-arch=core2 --with-tune=core2 \ --enable-languages='c,c++' --prefix=/opt/gcc-4.8 --disable-nls compilation was successful, but I saw a lot of lines in output, telling that lots of objects were compiled without my options but with some kind of default ones, like "-g" or "-g -O2", sometimes options were combined, and "-g" and "-march=core2" were used together. It is unclear for me - is it by design, or I did something improperly? At second, I tried to build cross-compiler (gcc 4.8.2 + eglibc 2.15 (this version is used on target device)). I successfully built cross-gcc without optimization, then I tried again with passing flags (last 3rd build of gcc): $ build_flags='-march=core2 -mtune=core2 -O2 -pipe' $ ../gcc/configure CFLAGS="$build_flags" CXXFLAGS="$build_flags" \ --with-arch=armv7-a --with-tune=marvell-pj4 --with-mode=thumb --with-float=hard --with-fpu=vfpv3 \ --enable-languages=c --target=$target --prefix=$prefix --with-sysroot=$sysroot \ --disable-libssp --disable-libgomp --disable-libmudflap --disable-nls $ make This failed with error: checking for suffix of object files... configure: error: in `/path/to/xgcc/obj/gcc3/arm-linux-gnueabi/libgcc': configure: error: cannot compute suffix of object files: cannot compile File arm-linux-gnueabi/libgcc/config.log contains: xgcc: error: unrecognized argument in option '-march=core2' xgcc: note: valid arguments to '-march=' are: armv2 armv2a ....... armv8-a+crc iwmmxt iwmmxt2 native xgcc: error: unrecognized argument in option '-mtune=core2' xgcc: note: valid arguments to '-mtune=' are: arm1020e ..... I guess make failed because at some moment build_flags (for amd64 architecture) were passed to cross-compiler, while it was expecting arm-architecture-compatible optimization options' values. I looked into Makefile and discovered variables ?FLAGS_FOR_BUILD and ?FLAGS_FOR_TARGET. Next I ran configure with vars: CFLAGS_FOR_BUILD="$build_flags" CXXFLAGS_FOR_BUILD="$build_flags" it compiled successfully, but again I saw lots of objects were compiled without my options. I roughly counted entries passing make's output through grep and got: mtune=core2 127 -g -O2 4371 It seems only little number of objects were compiled with flags I passed to configure. Next I tried to experiment and ran configure with such vars defined (trying to override "global flags" with "target flags" where needed): target_flags="-march=armv7-a -mtune=marvell-pj4 -O2 -pipe -mthumb -mthumb-interwork -mfloat-abi=hard -mfpu=vfpv3" CFLAGS="$build_flags" CXXFLAGS="$build_flags" CFLAGS_FOR_TARGET="$target_flags" CXXFLAGS_FOR_TARGET="$target_flags" It was built with success, and output contained: mtune=core2 799 -g -O2 0 march=armv7-a 3701 But this is only if --enable-languages=c With --enable-languages=c,c++ compilation again failed with: make[3]: Entering directory `/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3' Making all in include make[4]: Entering directory `/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/include' make[4]: Nothing to be done for `all'. make[4]: Leaving directory `/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/include' Making all in libsupc++ make[4]: Entering directory `/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/libsupc++' /bin/bash ../libtool --tag CXX --tag disable-shared --mode=compile /mnt/home/sergio/wrk/xgcc/obj/gcc3/./gcc/xgcc -shared-libgcc -B/mnt/home/sergio/wrk/xgcc/obj/gcc3/./gcc -nostdinc++ -L/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/src -L/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/src/.libs -L/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/libsupc++/.libs -B/home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/bin/ -B/home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/lib/ -isystem /home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/include -isystem /home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/sys-include -I/mnt/home/sergio/wrk/xgcc/src/gcc-svn-208890/libstdc++-v3/../libgcc -I/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/include/arm-linux-gnueabi -I/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/include -I/mnt/home/sergio/wrk/xgcc/src/gcc-svn-208890/libstdc++-v3/libsupc++ -prefer-pic -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=array_type_info.lo -march=core2 -mtune=core2 -O2 -pipe -D_GNU_SOURCE -c -o array_type_info.lo /mnt/home/sergio/wrk/xgcc/src/gcc-svn-208890/libstdc++-v3/libsupc++/array_type_info.cc libtool: compile: /mnt/home/sergio/wrk/xgcc/obj/gcc3/./gcc/xgcc -shared-libgcc -B/mnt/home/sergio/wrk/xgcc/obj/gcc3/./gcc -nostdinc++ -L/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/src -L/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/src/.libs -L/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/libsupc++/.libs -B/home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/bin/ -B/home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/lib/ -isystem /home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/include -isystem /home/sergio/opt/xgcc-armada370/arm-linux-gnueabi/sys-include -I/mnt/home/sergio/wrk/xgcc/src/gcc-svn-208890/libstdc++-v3/../libgcc -I/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/include/arm-linux-gnueabi -I/mnt/home/sergio/wrk/xgcc/obj/gcc3/arm-linux-gnueabi/libstdc++-v3/include -I/mnt/home/sergio/wrk/xgcc/src/gcc-svn-208890/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=array_type_info.lo -march=core2 -mtune=core2 -O2 -pipe -D_GNU_SOURCE -c /mnt/home/sergio/wrk/xgcc/src/gcc-svn-208890/libstdc++-v3/libsupc++/array_type_info.cc -D_GLIBCXX_SHARED xgcc: error: unrecognized argument in option '-march=core2' xgcc: note: valid arguments to '-march=' are: armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5e armv5t armv5te armv6 armv6-m armv6j armv6k armv6s-m armv6t2 armv6z armv6zk armv7 armv7-a armv7-m armv7-r armv7e-m armv7ve armv8-a armv8-a+crc iwmmxt iwmmxt2 native xgcc: error: unrecognized argument in option '-mtune=core2' xgcc: note: valid arguments to '-mtune=' are: arm1020e arm1020t ........... Once again CFLAGS/CXXFLAGS were occasionally passed to arm-targeted crosscompiler... Another issue is that the built crosscompiler links helloworld to ld-linux-armhf.so.3 , while the built library had installed only ld-linux.so.3 Am I right thinking this is due to aged version of library, ld-linux naming scheme for hard-fp was changed after eglibc 2.15 release? and I have to rename installed library to new name? Or this may be due to some mess with build options, and library could actually be built not for float-point=hard? Is there any method to discover ABI-specs of built executables and .so? objdump or readelf or somewhat else? what to seek for in their output? Thanks. /sergio