musl-1.1.15-assert.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From e738b8cbe64b6dd3ed9f47b6d4cd7eb2c422b38d Mon Sep 17 00:00:00 2001
  2. From: Rich Felker <dalias@aerifal.cx>
  3. Date: Tue, 30 Aug 2016 20:39:54 +0000
  4. Subject: restore _Noreturn to __assert_fail
  5. this reverts commit 2c1f8fd5da3306fd7c8a2267467e44eb61f12dd4. without
  6. the _Noreturn attribute, the compiler cannot use asserts to perform
  7. reachability/range analysis. this leads to missed optimizations and
  8. spurious warnings.
  9. the original backtrace problem that prompted the removal of _Noreturn
  10. was not clearly documented at the time, but it seems to happen only
  11. when libc was built without -g, which also breaks many other
  12. backtracing cases.
  13. ---
  14. diff --git a/include/assert.h b/include/assert.h
  15. index e679adb..d14ec94 100644
  16. --- a/include/assert.h
  17. +++ b/include/assert.h
  18. @@ -16,7 +16,7 @@
  19. extern "C" {
  20. #endif
  21. -void __assert_fail (const char *, const char *, int, const char *);
  22. +_Noreturn void __assert_fail (const char *, const char *, int, const char *);
  23. #ifdef __cplusplus
  24. }
  25. diff --git a/src/exit/assert.c b/src/exit/assert.c
  26. index e87442a..49b0dc3 100644
  27. --- a/src/exit/assert.c
  28. +++ b/src/exit/assert.c
  29. @@ -1,7 +1,7 @@
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. -void __assert_fail(const char *expr, const char *file, int line, const char *func)
  33. +_Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func)
  34. {
  35. fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line);
  36. fflush(NULL);
  37. --
  38. cgit v0.9.0.3-65-g4555