tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] __attribute__((constructor)) not getting called


From: Michael Matz
Subject: Re: [Tinycc-devel] __attribute__((constructor)) not getting called
Date: Wed, 5 Oct 2022 14:11:06 +0200 (CEST)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,

On Sat, 1 Oct 2022, Liam Wilson wrote:

Note __attribute__((constructor)) has been stripped off bar and not foo.

Yep, that's the glibc headers defining __attribute__ away ...

Digging a bit further, it seems to be due to sys/cdefs.h (which is
included by string.h and many other standard headers). In sys/cdefs.h
I found this:

... as you found out.

Is there a work around for this issue? I can define __GNUC__ but presumably that may cause other issues?

The work-around is to use the other form of attribute: __attribute(foo)
(note the missing suffix of '__'). That's still in the implementation namespace and not defined away by glibc.

The other work-around would be to '#undef __attribute__' after all glibc headers are included. As <sys/cdefs.h> (on glibc!) also has header guards you might also get away with this, as first directives in the .c files:

  #include <sys/cdefs.h>
  #undef __attribute__

as the following includes, even if they include <sys/cdefs.h> again, won't parse its content again. As TCC ignores unknown attributes that should work fine for the decls in the glibc headers as well.


Ciao,
Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]