From 9b6208707275c39763f3c638d6a540b52a0548ff Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Tue, 27 Feb 2024 15:34:27 +0100 Subject: [PATCH] build: Change default build from -O2 -g to -Os -g --- build-support/macros-and-definitions.cmake | 3 +++ doc/manual/source/working-with-cmake.rst | 8 ++++---- doc/tutorial/source/getting-started.rst | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 89fd6bca5..f974bbd2a 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -159,6 +159,9 @@ macro(process_options) STREQUAL "default" ) set(cmakeBuildType relwithdebinfo) + string(REPLACE "-O2" "-Os" CMAKE_CXX_FLAGS_RELWITHDEBINFO + "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" + ) set(CMAKE_CXX_FLAGS_DEFAULT ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) add_definitions(-DNS3_BUILD_PROFILE_DEBUG) elseif(${cmakeBuildType} STREQUAL "release") diff --git a/doc/manual/source/working-with-cmake.rst b/doc/manual/source/working-with-cmake.rst index 9527c0ca4..2d7dc3172 100644 --- a/doc/manual/source/working-with-cmake.rst +++ b/doc/manual/source/working-with-cmake.rst @@ -173,7 +173,7 @@ The mapping of the ``ns3`` build profiles into the CMake build types is the foll +=========================+========================+===============================+=================================+ | debug | debug | | -g | +-------------------------+------------------------+-------------------------------+---------------------------------+ -| default | default | | -O2 -g | +| default | default | | -Os -g | +-------------------------+------------------------+-------------------------------+---------------------------------+ | release | release | | -O3 | +-------------------------+------------------------+-------------------------------+---------------------------------+ @@ -235,9 +235,9 @@ build types and output executable and libraries names, which will receive a suff +==================+===================+ | DEBUG | -g | +------------------+-------------------+ -| DEFAULT | -O2 -g -DNDEBUG | +| DEFAULT | -Os -g -DNDEBUG | +------------------+-------------------+ -| RELWITHDEBINFO | -O2 -g -DNDEBUG | +| RELWITHDEBINFO | -Os -g -DNDEBUG | +------------------+-------------------+ | RELEASE | -O3 -DNDEBUG | +------------------+-------------------+ @@ -1965,7 +1965,7 @@ Installing the packages can take a while, and it can look like it hanged. -- -- Copying /ns-3-dev/cmake-build-release/_deps/armadillo-src/include/ to /ns-3-dev/cmake-build-release/_deps/armadillo-build/tmp/include/ -- Generating /ns-3-dev/cmake-build-release/_deps/armadillo-build/tmp/include/config.hpp - -- CMAKE_CXX_FLAGS = -fsanitize=address,leak,undefined -O2 + -- CMAKE_CXX_FLAGS = -fsanitize=address,leak,undefined -Os -- CMAKE_SHARED_LINKER_FLAGS = -Wl,--no-as-needed -- CMAKE_REQUIRED_INCLUDES = /usr/include;/usr/include/superlu -- diff --git a/doc/tutorial/source/getting-started.rst b/doc/tutorial/source/getting-started.rst index b488bf4c2..136bd2831 100644 --- a/doc/tutorial/source/getting-started.rst +++ b/doc/tutorial/source/getting-started.rst @@ -795,7 +795,7 @@ The build profile controls the use of logging, assertions, and compiler optimiza | Wrapper | | | | | | Macro | | | | | +----------+---------------------------------+-----------------------------+-------------------------------+---------------------------------+ - | Compiler | ``-Og -g`` | ``-O2 -g`` | ``-O3`` | ``-O3`` | + | Compiler | ``-Og -g`` | ``-Os -g`` | ``-O3`` | ``-O3`` | | Flags | | | | ``-march=native`` | | | | | | ``-mtune=native`` | +----------+---------------------------------+-----------------------------+-------------------------------+---------------------------------+