How to Figure Out the Compiler Optimization Level Used When Compiling Boost with b2?

Photo by Markus Spiske on Pexels.com

I had to figure out the compiler optimization level used when compiling Boost with b2, but it wasn’t visible in b2’s output. Eventually, I found out that one can add the -d+2 option to enable debugging level 2, which shows quiet actions and displays all action text. With that, I was able to see something like the following line:

"g++" -fvisibility-inlines-hidden -pthread -O3 -finline-functions -Wno-inline -Wall -fvisibility=hidden -fvisibility=hidden -Winvalid-pch -DBOOST_ALL_NO_LIB=1 -DBOOST_BUILD_PCH_ENABLED -DBOOST_COBALT_USE_STD_PMR=1 -DNDEBUG -include "bin.v2/libs/math/build/gcc-10/release/arm_64/link-static/threading-multi/visibility-hidden/pch" -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/gcc-10/release/arm_64/link-static/threading-multi/visibility-hidden/copysignl.o" "libs/math/build/../src/tr1/copysignl.cpp"

Which proves that -O3 is used by default.

Leave a comment