tpoechtrager / cctools-port

Apple cctools port for Linux and *BSD
721 stars 165 forks source link

don't try to include __assert for NDEBUG builds #133

Closed h-vetinari closed 1 year ago

h-vetinari commented 1 year ago

Even though cctools/ld64/src/3rd/helper.c correctly does #include <assert.h>, that header is basically empty when NDEBUG is defined.

On clang 16, this causes a compilation error because it now got stricter about implicit function declarations:

The -Wimplicit-function-declaration and -Wimplicit-int warnings now default to an error in C99, C11, and C17. As of C2x, support for implicit function declarations and implicit int has been removed, and the warning options will have no effect. Specifying -Wimplicit-int in C89 mode will now issue warnings instead of being a noop.

In other words, __assert_rtn should not try to call __assert in the case of NDEBUG being defined. Add an #ifndef guard around the body of the function to achieve this.