earlephilhower / esp-quick-toolchain

GCC toolchain for esp8266/arduino on MacOS, Linux, ARM64, Raspberry Pi, and Windows
87 stars 24 forks source link

Makefile: Add "-pipe -g -O2" to CFLAGS/CXXFLAGS #41

Closed jjsuwa-sys3175 closed 2 years ago

jjsuwa-sys3175 commented 2 years ago

This fixes that the host binaries (assmebler, compiler, linker and so on) are not optimized well.

earlephilhower commented 2 years ago

Thanks, but a quick test of time make in the BearSSL directory didn't show any runtime difference. Are you sure that -O2 is not the default anyway? Did you have a test case that I can check?

(to be clear, I did a make; make clean; time make with the old and new Linux x86 builds to get runtime while avoiding any issues about file caches)

jjsuwa-sys3175 commented 2 years ago

Did you have a test case that I can check?

simply compare the binaries before and after:

[before]

pi@atom330:/tmp/xtensa-lx106-elf/bin$ ls -la
total 57284
drwxr-xr-x 2 pi pi      660 Jun 22 05:13 .
drwxr-xr-x 8 pi pi      180 Jun 22 05:13 ..
-rwxr-xr-x 1 pi pi  1464200 Jun 22 05:13 xtensa-lx106-elf-addr2line
-rwxr-xr-x 2 pi pi  1496688 Jun 22 05:13 xtensa-lx106-elf-ar
-rwxr-xr-x 2 pi pi  1919192 Jun 22 05:13 xtensa-lx106-elf-as
-rwxr-xr-x 2 pi pi  1145856 Jun 22 05:13 xtensa-lx106-elf-c++
lrwxrwxrwx 1 pi pi       20 Jun 22 05:09 xtensa-lx106-elf-cc -> xtensa-lx106-elf-gcc
-rwxr-xr-x 1 pi pi  1463688 Jun 22 05:13 xtensa-lx106-elf-c++filt
-rwxr-xr-x 1 pi pi  1141760 Jun 22 05:13 xtensa-lx106-elf-cpp
-rwxr-xr-x 1 pi pi    39408 Jun 22 05:13 xtensa-lx106-elf-elfedit
-rwxr-xr-x 2 pi pi  1145856 Jun 22 05:13 xtensa-lx106-elf-g++
-rwxr-xr-x 2 pi pi  1141760 Jun 22 05:13 xtensa-lx106-elf-gcc
-rwxr-xr-x 2 pi pi  1141760 Jun 22 05:13 xtensa-lx106-elf-gcc-10.3.0
-rwxr-xr-x 1 pi pi    31216 Jun 22 05:13 xtensa-lx106-elf-gcc-ar
-rwxr-xr-x 1 pi pi    31216 Jun 22 05:13 xtensa-lx106-elf-gcc-nm
-rwxr-xr-x 1 pi pi    31216 Jun 22 05:13 xtensa-lx106-elf-gcc-ranlib
-rwxr-xr-x 1 pi pi   798784 Jun 22 05:13 xtensa-lx106-elf-gcov
-rwxr-xr-x 1 pi pi   561112 Jun 22 05:13 xtensa-lx106-elf-gcov-dump
-rwxr-xr-x 1 pi pi   581656 Jun 22 05:13 xtensa-lx106-elf-gcov-tool
-rwxr-xr-x 1 pi pi  8167432 Jun 22 05:13 xtensa-lx106-elf-gdb
-rwxr-xr-x 1 pi pi     3270 Jun 22 05:09 xtensa-lx106-elf-gdb-add-index
-rwxr-xr-x 1 pi pi  1543272 Jun 22 05:13 xtensa-lx106-elf-gprof
-rwxr-xr-x 4 pi pi  1968472 Jun 22 05:13 xtensa-lx106-elf-ld
-rwxr-xr-x 4 pi pi  1968472 Jun 22 05:13 xtensa-lx106-elf-ld.bfd
-rwxr-xr-x 1 pi pi 19027152 Jun 22 05:13 xtensa-lx106-elf-lto-dump
-rwxr-xr-x 2 pi pi  1481288 Jun 22 05:13 xtensa-lx106-elf-nm
-rwxr-xr-x 2 pi pi  1644072 Jun 22 05:13 xtensa-lx106-elf-objcopy
-rwxr-xr-x 2 pi pi  1867688 Jun 22 05:13 xtensa-lx106-elf-objdump
-rwxr-xr-x 2 pi pi  1496720 Jun 22 05:13 xtensa-lx106-elf-ranlib
-rwxr-xr-x 2 pi pi   728328 Jun 22 05:13 xtensa-lx106-elf-readelf
-rwxr-xr-x 1 pi pi  1463944 Jun 22 05:13 xtensa-lx106-elf-size
-rwxr-xr-x 1 pi pi  1464072 Jun 22 05:13 xtensa-lx106-elf-strings
-rwxr-xr-x 2 pi pi  1644104 Jun 22 05:13 xtensa-lx106-elf-strip

[after]

pi@atom330:/tmp/xtensa-lx106-elf/bin$ ls -la
total 50792
drwxr-xr-x 2 pi pi      660 Jul 15 11:47 .
drwxr-xr-x 8 pi pi      180 Jul 15 11:47 ..
-rwxr-xr-x 1 pi pi  1173856 Jul 15 11:47 xtensa-lx106-elf-addr2line
-rwxr-xr-x 2 pi pi  1206376 Jul 15 11:47 xtensa-lx106-elf-ar
-rwxr-xr-x 2 pi pi  1550760 Jul 15 11:47 xtensa-lx106-elf-as
-rwxr-xr-x 2 pi pi  1092368 Jul 15 11:47 xtensa-lx106-elf-c++
lrwxrwxrwx 1 pi pi       20 Jul 15 11:22 xtensa-lx106-elf-cc -> xtensa-lx106-elf-gcc
-rwxr-xr-x 1 pi pi  1169248 Jul 15 11:47 xtensa-lx106-elf-c++filt
-rwxr-xr-x 1 pi pi  1088272 Jul 15 11:47 xtensa-lx106-elf-cpp
-rwxr-xr-x 1 pi pi    39792 Jul 15 11:47 xtensa-lx106-elf-elfedit
-rwxr-xr-x 2 pi pi  1092368 Jul 15 11:47 xtensa-lx106-elf-g++
-rwxr-xr-x 2 pi pi  1084176 Jul 15 11:47 xtensa-lx106-elf-gcc
-rwxr-xr-x 2 pi pi  1084176 Jul 15 11:47 xtensa-lx106-elf-gcc-10.3.0
-rwxr-xr-x 1 pi pi    31184 Jul 15 11:47 xtensa-lx106-elf-gcc-ar
-rwxr-xr-x 1 pi pi    31184 Jul 15 11:47 xtensa-lx106-elf-gcc-nm
-rwxr-xr-x 1 pi pi    31184 Jul 15 11:47 xtensa-lx106-elf-gcc-ranlib
-rwxr-xr-x 1 pi pi   733200 Jul 15 11:47 xtensa-lx106-elf-gcov
-rwxr-xr-x 1 pi pi   528264 Jul 15 11:47 xtensa-lx106-elf-gcov-dump
-rwxr-xr-x 1 pi pi   548840 Jul 15 11:47 xtensa-lx106-elf-gcov-tool
-rwxr-xr-x 1 pi pi  7328776 Jul 15 11:47 xtensa-lx106-elf-gdb
-rwxr-xr-x 1 pi pi     3270 Jul 15 11:22 xtensa-lx106-elf-gdb-add-index
-rwxr-xr-x 1 pi pi  1240544 Jul 15 11:47 xtensa-lx106-elf-gprof
-rwxr-xr-x 4 pi pi  1616688 Jul 15 11:47 xtensa-lx106-elf-ld
-rwxr-xr-x 4 pi pi  1616688 Jul 15 11:47 xtensa-lx106-elf-ld.bfd
-rwxr-xr-x 1 pi pi 18185744 Jul 15 11:47 xtensa-lx106-elf-lto-dump
-rwxr-xr-x 2 pi pi  1186816 Jul 15 11:47 xtensa-lx106-elf-nm
-rwxr-xr-x 2 pi pi  1316864 Jul 15 11:47 xtensa-lx106-elf-objcopy
-rwxr-xr-x 2 pi pi  1491320 Jul 15 11:47 xtensa-lx106-elf-objdump
-rwxr-xr-x 2 pi pi  1206408 Jul 15 11:47 xtensa-lx106-elf-ranlib
-rwxr-xr-x 2 pi pi   617496 Jul 15 11:47 xtensa-lx106-elf-readelf
-rwxr-xr-x 1 pi pi  1177696 Jul 15 11:47 xtensa-lx106-elf-size
-rwxr-xr-x 1 pi pi  1173728 Jul 15 11:47 xtensa-lx106-elf-strings
-rwxr-xr-x 2 pi pi  1316864 Jul 15 11:47 xtensa-lx106-elf-strip

And in general, not setting "CFLAGS" (and/or "CXXFLAGS") implicitly includes appropriate optimization level options such as "-O2", but explicitly setting "CFLAGS" does not automatically include such options (optimization level must be explicitly specified when using "CFLAGS").

earlephilhower commented 2 years ago

Fair enough. I don't see this hurting, so I'm happy to merge. Thx again!