Re: Is there a reason why avr-gcc does not support constructor priority (both in C and C++ worlds)?

Senthil Kumar Selvaraj <[email protected]>
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <[email protected]>
On Tue, Mar 18, 2014 at 11:51:33AM +0000, David Fernandez wrote:
> Hi there,
> 
> I've been trying to use both the attributes "init_priority" for C++, and
> "constructor" for C, with priority numbers, in atxmega{16,32}a4u, and the
> compiler complains saying "error: 'init_priority' attribute is not supported
> on this platform", or "error: constructor priorities are not supported".

This features requires the target backend to opt in (by declaring
SUPPORTS_INIT_PRIORITY) to a non-zero value. The avr backend doesn't, even on 
the latest sources, so newer versions don't have it either.

I checked out what the x86_64 target does with init_priority. It actually

* generates individual intitializer functions for each unique priority
* generates a .init_array.<priority> section for each unique priority
  and puts a pointer to the initializer function inside it.
* These input sections are sorted in the linker script with 
SORT_BY_INIT_PRIORITY, instead of just SORT to so that the linker will
do a numerical sort on priority.

I don't see a reason to not support this though. Can you please file a
bug so we can track this?

Regards
Senthil
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.