commit 52f6ed4d768614b02d5c132c661adf408c239d7e from: Vladimir Davydov via: Vladimir Davydov date: Thu Apr 27 10:18:09 2023 UTC static-build: enable compiler optimizations for dependencies An autoconf-generated configure script doesn't enable compiler optimization flags if CFLAGS / CXXFLAGS options are set explicitly. We started setting CFLAGS / CXXFLAGS in commit e6abe1c91ae3 ("cmake: add extra security compiler options"). As a result, users started experiencing performance degradation issues, like the one described in tarantool/tarantool-ee#440. Let's set -O2 in CFLAGS / CXXFLAGS explicitly to fix that. Closes #8606 Needed for tarantool/tarantool-ee#440 NO_DOC=build NO_TEST=build commit - d8faca69a6339d21e97ceee4def69082b9c0acba commit + 52f6ed4d768614b02d5c132c661adf408c239d7e blob - /dev/null blob + 2843474fd8f9dba46d8c3d461146a16de13754d1 (mode 644) --- /dev/null +++ changelogs/unreleased/gh-8606-static-build-enable-optimization.md @@ -0,0 +1,4 @@ +## bugfix/build + +* Enabled compiler optimizations for static build dependencies, which were + erroneously disabled in version 2.10.3 (gh-8606). blob - bcb864335d9142f5ac2273b2f9839904db6ce93d blob + 6672d7158f2b153d1d90192d29128fc09bc496be --- static-build/cmake/AddDependencyProjects.cmake +++ static-build/cmake/AddDependencyProjects.cmake @@ -33,14 +33,20 @@ set(BACKUP_STORAGE https://distrib.hb.bizmrg.com) # using of corresponding environment variable. It is possible that a # linker flag assumes that some compilation flag is set. We don't pass # CFLAGS from environment, so we should not do it for LDFLAGS too. -set(DEPENDENCY_CFLAGS "") -set(DEPENDENCY_CXXFLAGS "") +# +# Note: A configure script generated by autoconf doesn't enable compiler +# optimizations if CFLAGS / CXXFLAGS is set so we have to enable them +# explicitly, see https://github.com/tarantool/tarantool/issues/8606 +# +set(DEPENDENCY_CFLAGS "-O2") +set(DEPENDENCY_CXXFLAGS "-O2") set(DEPENDENCY_CPPFLAGS "") -set(DEPENDENCY_LDFLAGS) +set(DEPENDENCY_LDFLAGS "") + if (APPLE) - set(DEPENDENCY_CFLAGS "${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") - set(DEPENDENCY_CXXFLAGS "${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") - set(DEPENDENCY_CPPFLAGS "${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") + set(DEPENDENCY_CFLAGS "${DEPENDENCY_CFLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") + set(DEPENDENCY_CXXFLAGS "${DEPENDENCY_CXXFLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") + set(DEPENDENCY_CPPFLAGS "${DEPENDENCY_CPPFLAGS} ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT}") endif() set(DEPENDENCY_CFLAGS "${DEPENDENCY_CFLAGS} ${HARDENING_FLAGS}")