package/gcc: undefine NDEBUG directive
PATCH 1/1 package/gcc: undefine NDEBUG directive
GCC performs internal consistency checks that can be controlled with --enable-checking, but not completely removed for all stages of the build. One of these checks uses the assert macro from <assert.h> Defining NDEBUG removes the assertion code, which is not anticipated in the gcc code.
Undefine the NDEBUG flag for package/gcc to preserve assertions.
This fixes the following error during build of GCC 10:
../../../libgomp/target.c: In function ?gomp_unmap_vars_internal?:../../../libgomp/target.c:1474:9: error: unused variable ?is_tgt_unmapped? [-Werror=unused-variable]
1474 | bool is_tgt_unmapped = gomp_remove_var (devicep, k);
| ^~~~~~~~~~~~~~~../../../libgomp/target.c:1473:28: error: unused variable ?k_tgt? [-Werror=unused-variable]
1473 | struct target_mem_desc *k_tgt = k->tgt;
| ^~~~~
--- package/gcc/gcc.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
package/gcc/gcc.mk +2 -1
@@ -90,7 +90,8 @@ HOST_GCC_COMMON_CONF_OPTS = \ HOST_GCC_COMMON_CONF_ENV = \ MAKEINFO=missing -GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) +# gcc should not be built with NDEBUG enabled +GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) -UNDEBUG GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS) # used to fix ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Signature · 1 line
2.25.1
PATCH 1/1 package/gcc: undefine NDEBUG directive
Hello Andreas,
Le 17/06/2021 ? 14:19, Andreas Ziegler a ?crit?:
Quoted 6 lines
GCC performs internal consistency checks that can be controlled with --enable-checking, but not completely removed for all stages of the build. One of these checks uses the assert macro from <
assert.h> Defining NDEBUG removes the assertion code, which is not anticipated in the gcc code.Undefine the NDEBUG flag for package/gcc to preserve assertions.
This fixes the following error during build of GCC 10:
Quoted 7 lines
../../../libgomp/target.c: In function ?gomp_unmap_vars_internal?:../../../libgomp/target.c:1474:9: error: unused variable ?is_tgt_unmapped? [-Werror=unused-variable]1474 | bool is_tgt_unmapped = gomp_remove_var (devicep, k); | ^~~~~~~~~~~~~~~
../../../libgomp/target.c:1473:28: error: unused variable ?k_tgt? [-Werror=unused-variable]
1473 | structtarget_mem_desc*k_tgt=k->tgt;
| ^~~~~
It seems an error related to Werror being enabled.
Usually we prefer disable Werror while building a package in Buildroot because any package can trigger new warning with the latest compiler.
Maybe we can use -Wno-error not just when BR2_ENABLE_DEBUG is set:
https://git.buildroot.net/buildroot/commit/?id=dcaf6e75acb4d21c2c31c70b054dac8d18710fcb
Best regards,
Romain
Quoted 21 lines
Signed-off-by Andreas Ziegler <[email protected]>--- package/gcc/gcc.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)package/gcc/gcc.mk +2
-1@@ -90,7 +90,8 @@ HOST_GCC_COMMON_CONF_OPTS = \ HOST_GCC_COMMON_CONF_ENV = \ MAKEINFO=missing -GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) +# gcc should not be built with NDEBUG enabled +GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) -UNDEBUG GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS) # used to fix ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
PATCH 1/1 package/gcc: undefine NDEBUG directive
Bonjour Romain,
Quoted 23 lines · Romain Naour
Hello Andreas,
Le 17/06/2021 ? 14:19, Andreas Ziegler a ?crit?:
Quoted 13 lines
GCC performs internal consistency checks that can be controlled with --enable-checking, but not completely removed for all stages of the build. One of these checks uses the assert macro from <
assert.h> Defining NDEBUG removes the assertion code, which is not anticipated in the gcc code.Undefine the NDEBUG flag for package/gcc to preserve assertions.
This fixes the following error during build of GCC 10:
../../../libgomp/target.c: In function ?gomp_unmap_vars_internal?:../../../libgomp/target.c:1474:9: error: unused variable ?is_tgt_unmapped? [-Werror=unused-variable]Quoted 6 lines
1474 | bool is_tgt_unmapped = gomp_remove_var (devicep, k); | ^~~~~~~~~~~~~~~
../../../libgomp/target.c:1473:28: error: unused variable ?k_tgt? [-Werror=unused-variable]
1473 | structtarget_mem_desc*k_tgt=k->tgt;
| ^~~~~
Quoted 5 lines
It seems an error related to Werror being enabled.
Usually we prefer disable Werror while building a package in Buildroot because
any package can trigger new warning with the latest compiler.
Using -Wno-error was my first idea, though I would have preferred to just disable the actual error: -Werror=unused-variable. I posted a question an the mailing list
https://marc.info/?l=buildroot&m=162366255526973&w=2
After receiving no answer, I did some more research:
-- gcc does not use NDEBUG consistently, but relies on assertions to monitor some internal structures. These assertions, but not the code, are disabled via the C library when NDEBUG is set.
-- The build process explicitly sets -Werror in some phases.
-- For enabling and disabling individual internal checks and assertions, configure options exist:
--enable-werror
--disable-werror
--enable-checking
--disable-checking
--disable-stage1-checking
--enable-stage1-checking
So my recommendation is to remove NDEBUG, not suppress the error message. This is the least invasive option.
Quoted 3 lines
Maybe we can use -Wno-error not just when
BR2_ENABLE_DEBUGis set:https://git.buildroot.net/buildroot/commit/?id=dcaf6e75acb4d21c2c31c70b054dac8d18710fcb
I have seen this, but would not recommend disabling errors overall to catch one specific error that manifests. -Wno-error=maybe-uninitialized might have been more elegant ...
Kind regards,
Andreas
Quoted 27 lines
Best regards,
RomainQuoted 24 lines
Signed-off-by Andreas Ziegler <[email protected]>--- package/gcc/gcc.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)package/gcc/gcc.mk +2
-1@@ -90,7 +90,8 @@ HOST_GCC_COMMON_CONF_OPTS = \ HOST_GCC_COMMON_CONF_ENV = \ MAKEINFO=missing -GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) +# gcc should not be built with NDEBUG enabled +GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) -UNDEBUG GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS) # used to fix
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21:
error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
PATCH 1/1 package/gcc: undefine NDEBUG directive
In reply to Andreas ZieglerAndreas, All,
On 2021-06-17 14:19 +0200, Andreas Ziegler spake thusly:
Quoted 8 lines
GCC performs internal consistency checks that can be controlled with --enable-checking, but not completely removed for all stages of the build. One of these checks uses the assert macro from <
assert.h> Defining NDEBUG removes the assertion code, which is not anticipated in the gcc code.Undefine the NDEBUG flag for package/gcc to preserve assertions.
This fixes the following error during build of GCC 10:
../../../libgomp/target.c: In function ?gomp_unmap_vars_internal?:../../../libgomp/target.c:1474:9: error: unused variable ?is_tgt_unmapped? [-Werror=unused-variable]
Quoted 7 lines
1474 | bool is_tgt_unmapped = gomp_remove_var (devicep, k); | ^~~~~~~~~~~~~~~
../../../libgomp/target.c:1473:28: error: unused variable ?k_tgt? [-Werror=unused-variable]
1473 | structtarget_mem_desc*k_tgt=k->tgt;
| ^~~~~Signed-off-by Andreas Ziegler <[email protected]>
We are now no longer setting NDEBUG in the infra; see a1c7cff1a081.
So this patch is no longer needed; I've marked it as rejected.
Thanks!
Regards,
Yann E. MORIN.
Quoted 25 lines
--- package/gcc/gcc.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)package/gcc/gcc.mk +2
-1@@ -90,7 +90,8 @@ HOST_GCC_COMMON_CONF_OPTS = \ HOST_GCC_COMMON_CONF_ENV = \ MAKEINFO=missing -GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) +# gcc should not be built with NDEBUG enabled +GCC_COMMON_TARGET_CFLAGS = $(TARGET_CFLAGS) -UNDEBUG GCC_COMMON_TARGET_CXXFLAGS = $(TARGET_CXXFLAGS) # used to fix ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'