On 8/12/21 4:12 PM, Sebastian Huber wrote:
On 12/08/2021 16:08, Martin Liška wrote:
On 7/21/21 2:44 PM, Sebastian Huber wrote:
Hello,
while testing this patch
https://www.google.com/search?client=firefox-b-e&q=gcc+enable_runtime_checking
I noticed that __gcov_info_to_gcda() uses abort(). This is due to (from
tsystem.h):
#ifdef ENABLE_RUNTIME_CHECKING
#define gcc_assert(EXPR) ((void)(!(EXPR) ? abort (), 0 : 0))
#else
/* Include EXPR, so that unused variable warnings do not occur. */
#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
#endif
In tsystem.h there is this if inhibit_libc is defined:
#ifndef abort
extern void abort (void) __attribute__ ((__noreturn__));
#endif
Who is supposed to define abort here optionally? Can this be defined for
example by a target configuration header like gcc/config/rtems.h?
Apparently, it's a hairy revision:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=7e7de68b8938
What happens now on RTERM where you have inhibit_libc set to true? Do you end
up with an undefined symbol?
No, we have abort() in RTEMS (from Newlib). The problem is that abort() is a
very heavy weight function which pulls in the signal and file streams support.
Oh, I see.
In case of RTEMS, the application and the operating system is statically linked into
one executable. The more features an application uses the bigger will be the
executable. The abort() function pulls in a lot of stuff since it uses signals and
may attempt to close all open streams. It would be nice if the gcc_assert() could be
customized by the target configuration. For RTEMS we could use the Newlib defined
__assert_func() from <assert.h>:
# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \
__ASSERT_FUNC, #__e))
void __assert_func (const char *, int, const char *, const char *)
_ATTRIBUTE ((__noreturn__));
Then what about adding a condition to gcc/tsystem.h where where you would define
a different gcc_assert based on rtems target?
Martin