Skip to contentSkip to conversation

package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

PATCH New Charles Hardin 3 participants 7 messages May 21, 2016 – Jul 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

From the documentation on BR2_ENABLE_DEBUG, the intention is to get a build with debug symbols and not a "debug build" since that can have the unintended consequence of being a different code path then a release build type definition.

Switch the "Debug" to "RelWithDebInfo" in the cmake package support to accomodate getting the debug symbols and still be a release build.

---
 package/pkg-cmake.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/pkg-cmake.mk +1 -1
index 81dcfcc..bca3603 100644
@@ -87,7 +87,7 @@ define $(2)_CONFIGURE_CMDS
 	PATH=$$(BR_PATH) \
 	$$($$(PKG)_CONF_ENV) $$(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
-		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),Debug,Release) \
+		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),RelWithDebInfo,Release) \
 		-DCMAKE_INSTALL_PREFIX="/usr" \
 		-DCMAKE_COLOR_MAKEFILE=OFF \
 		-DBUILD_DOC=OFF \
Signature · 1 line
2.7.4 (Apple Git-66)
#1 lore raw

PATCH 1/1 package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

Samuel,

Please review/ack this patch if appropriate.

If there is no feedback in the next days, I'll assume it's good and I'll apply.

Thanks,

Thomas

Quoted 27 lines · Charles Hardin

From the documentation on BR2_ENABLE_DEBUG, the intention is to get a build with debug symbols and not a "debug build" since that can have the unintended consequence of being a different code path then a release build type definition.

Switch the "Debug" to "RelWithDebInfo" in the cmake package support to accomodate getting the debug symbols and still be a release build.

---
 package/pkg-cmake.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/pkg-cmake.mk +1 -1
index 81dcfcc..bca3603 100644
@@ -87,7 +87,7 @@ define $(2)_CONFIGURE_CMDS
 	PATH=$$(BR_PATH) \
 	$$($$(PKG)_CONF_ENV) $$(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
-		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),Debug,Release) \
+		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),RelWithDebInfo,Release) \
 		-DCMAKE_INSTALL_PREFIX="/usr" \
 		-DCMAKE_COLOR_MAKEFILE=OFF \
 		-DBUILD_DOC=OFF \
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

Hi all,

Quoted 6 lines · Thomas Petazzoni

Samuel,

Please review/ack this patch if appropriate.

If there is no feedback in the next days, I'll assume it's good and I'll apply.

Ooops, I missed this patch :-/

Quoted 15 lines

Thanks,

Thomas

Quoted 9 lines · Charles Hardin

From the documentation on BR2_ENABLE_DEBUG, the intention is to get a build with debug symbols and not a "debug build" since that can have the unintended consequence of being a different code path then a release build type definition.

Switch the "Debug" to "RelWithDebInfo" in the cmake package support to accomodate getting the debug symbols and still be a release build.

By default CMake sets the CFLAGS like this:
CMAKE_C_FLAGS_DEBUG=-g
CMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG
CMAKE_C_FLAGS_RELEASE=-O3 -DNDEBUG

I do not see what could be wrong with this patch, hence:

Quoted 17 lines
Quoted 17 lines
---
 package/pkg-cmake.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/pkg-cmake.mk +1 -1
index 81dcfcc..bca3603 100644
@@ -87,7 +87,7 @@ define $(2)_CONFIGURE_CMDS
      PATH=$$(BR_PATH) \
      $$($$(PKG)_CONF_ENV) $$(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
              -DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
-             -DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),Debug,Release) \
+             -DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),RelWithDebInfo,Release) \
              -DCMAKE_INSTALL_PREFIX="/usr" \
              -DCMAKE_COLOR_MAKEFILE=OFF \
Quoted 8 lines

package/pkg-cmake.mk define $(2)_CONFIGURE_CMDS · line 93

Quoted 1 line
package/pkg-cmake.mk +0 -0
              -DBUILD_DOC=OFF \

--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

Regards,

Signature · 1 line
Samuel
#3 lore raw

PATCH 1/1 package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

Hello,

Quoted 3 lines · Samuel Martin

By default CMake sets the CFLAGS like this:
CMAKE_C_FLAGS_DEBUG=-g
CMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG

Is -O2 -g really what we want for debugging? Optimized code very often doesn't play well with debugging.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

Quoted 10 lines · Thomas Petazzoni

Hello,

Quoted 3 lines · Samuel Martin

By default CMake sets the CFLAGS like this:
CMAKE_C_FLAGS_DEBUG=-g
CMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG

Is -O2 -g really what we want for debugging? Optimized code very often doesn't play well with debugging.

To be honest, I don't have a strong opinion about it.

Note that this is the default flags CMake sets; if you add to the configure opts:
-DCMAKE_C_FLAGS_RELWITHDEBINFO=-g -O1 -UNDEBUG
then these flags are taken into account, not the default ones.

OTOH, applying no optimization at all in debug build may lead to some size issues for (very) tiny targets... Who knows? though I don't remember any bug report/complaint about such a situation.

Regards,

Signature · 1 line
Samuel
#5 lore raw

PATCH 1/1 package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

We hit the size and the NDEBUG issue as well.

Sent from my iPhone

Quoted 30 lines · Samuel Martin
Quoted 10 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Samuel Martin

By default CMake sets the CFLAGS like this:
CMAKE_C_FLAGS_DEBUG=-g
CMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG

Is -O2 -g really what we want for debugging? Optimized code very often doesn't play well with debugging.

To be honest, I don't have a strong opinion about it.

Note that this is the default flags CMake sets; if you add to the configure opts:
-DCMAKE_C_FLAGS_RELWITHDEBINFO=-g -O1 -UNDEBUG
then these flags are taken into account, not the default ones.

OTOH, applying no optimization at all in debug build may lead to some size issues for (very) tiny targets... Who knows? though I don't remember any bug report/complaint about such a situation.

Regards,

Signature · 1 line
Samuel
#6 lore raw

PATCH 1/1 package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo

In reply to Charles Hardin

Hello,

Quoted 5 lines · Charles Hardin

From the documentation on BR2_ENABLE_DEBUG, the intention is to get a build with debug symbols and not a "debug build" since that can have the unintended consequence of being a different code path then a release build type definition.

Quoted 8 lines

Switch the "Debug" to "RelWithDebInfo" in the cmake package support to accomodate getting the debug symbols and still be a release build.

---
 package/pkg-cmake.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com