Bug 10246 - BR2_ENABLE_DEBUG does not have the expected effect for cmake packages
Summary: BR2_ENABLE_DEBUG does not have the expected effect for cmake packages
Status: RESOLVED WONTFIX
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2017.05.1
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-23 04:10 UTC by Mehdi Amini
Modified: 2017-08-23 09:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Proposed patch. (1.27 KB, patch)
2017-08-23 04:41 UTC, Mehdi Amini
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mehdi Amini 2017-08-23 04:10:57 UTC
I've been bitten by the option BR2_ENABLE_DEBUG which does not exactly do what the doc describes:


config BR2_ENABLE_DEBUG
        bool "build packages with debugging symbols"
        help
          Build packages with debugging symbols enabled. All libraries
          and binaries in the 'staging' directory will have debugging
          symbols, which allows remote debugging even if libraries and
          binaries are stripped on the target. Whether libraries and
          binaries are stripped on the target is controlled by the
          BR2_STRIP_* options below.


For a CMake package, this corresponds to `-DCMAKE_BUILD_TYPE=RelWithDebInfo`, however currently buildroot will pass  `-DCMAKE_BUILD_TYPE=Debug` which has the effect of generating a *non-optimized* build (i.e. -O0).

I suggest the following patch:

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index db78d897d826..0a7bee685096 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -257,7 +257,7 @@ $(HOST_DIR)/share/buildroot/toolchainfile.cmake:
                -e 's#@@TARGET_FC@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_FC)))#' \
                -e 's#@@CMAKE_SYSTEM_PROCESSOR@@#$(call qstrip,$(CMAKE_SYSTEM_PROCESSOR))#' \
                -e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \
-               -e 's#@@CMAKE_BUILD_TYPE@@#$(if $(BR2_ENABLE_DEBUG),Debug,Release)#' \
+               -e 's#@@CMAKE_BUILD_TYPE@@#$(if $(BR2_ENABLE_DEBUG),RelWithDebInfo,Release)#' \
                $(TOPDIR)/support/misc/toolchainfile.cmake.in \
                > $@
Comment 1 Mehdi Amini 2017-08-23 04:41:52 UTC
Created attachment 7201 [details]
Proposed patch.
Comment 2 Thomas Petazzoni 2017-08-23 08:22:15 UTC
What you're proposing is to exactly revert https://git.buildroot.org/buildroot/commit/package/pkg-cmake.mk?id=104bb29e0490bfb487e2e665448dd3ca07fcc2b5, which already reverted the change you're proposing :)

So, see the commit log of https://git.buildroot.org/buildroot/commit/package/pkg-cmake.mk?id=104bb29e0490bfb487e2e665448dd3ca07fcc2b5 for the explanation of why we're using the Debug build type and not the RelWithDebInfo build type.

If you disagree, please submit a patch to the mailing list with a precise description of why reverting https://git.buildroot.org/buildroot/commit/package/pkg-cmake.mk?id=104bb29e0490bfb487e2e665448dd3ca07fcc2b5 is a good idea. Thanks!
Comment 3 Mehdi Amini 2017-08-23 09:00:46 UTC
Thanks for the pointer. The rational in the commit message your pointing to does not make sense to me, will email the mailing-list.