aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2024-02-08 16:39:35 +0000
committerMichael Brown <mcb30@ipxe.org>2024-02-10 14:47:40 +0000
commit0f5abd8b117ea7da0747fe36b66c050706f6584f (patch)
treeaec562bf1eacf3e3024e5845d64c55fc1d8a09cf
parenta846c4ccfc7db212dff792e081991df17268b4d5 (diff)
downloadipxe-0f5abd8b117ea7da0747fe36b66c050706f6584f.zip
ipxe-0f5abd8b117ea7da0747fe36b66c050706f6584f.tar.gz
ipxe-0f5abd8b117ea7da0747fe36b66c050706f6584f.tar.bz2
[libc] Allow build_assert() failures to be ignored via NO_WERROR=1
We build with -Werror by default so that any warning is treated as an error and aborts the build. The build system allows NO_WERROR=1 to be used to override this behaviour, in order to allow builds to succeed when spurious warnings occur (e.g. when using a newer compiler that includes checks for which the codebase is not yet prepared). Some versions of gcc (observed with gcc 4.8.5 in CentOS 7) will report spurious build_assert() failures: the compilation will fail due to an allegedly unelided call to the build assertion's external function declared with __attribute__((error)) even though the compiler does manage to successfully elide the call (as verified by the fact that there are no unresolvable symbol references in the compiler output). Change build_assert() to declare __attribute__((warning)) instead of __attribute__((error)) on its extern function. This will still abort a normal build if the assertion fails, but may be overridden using NO_WERROR=1 if necessary to work around a spurious assertion failure. Note that if the build assertion has genuinely failed (i.e. if the compiler has genuinely not been able to elide the call) then the object will still contain an unresolvable symbol reference that will cause the link to fail (which matches the behaviour of the old linker_assert() mechanism). Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/include/assert.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/include/assert.h b/src/include/assert.h
index b3a9b1f..01a2878 100644
--- a/src/include/assert.h
+++ b/src/include/assert.h
@@ -76,7 +76,7 @@ assert_printf ( const char *fmt, ... ) asm ( "printf" );
#define build_assert( condition ) \
do { \
if ( ! (condition) ) { \
- extern void __attribute__ (( error ( \
+ extern void __attribute__ (( warning ( \
"build_assert(" #condition ") failed" \
) )) _C2 ( build_assert_, __LINE__ ) ( void ); \
_C2 ( build_assert_, __LINE__ ) (); \