Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#37664 closed defect (invalid)

gcc46, gcc47 @4.7.2 'init_priority' attribute is not supported on this platform

Reported by: ilg@… Owned by: mww@…
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc: jeremyhu (Jeremy Huddleston Sequoia)
Port: gcc46 gcc47

Description

According to the GCC manuals, the

 __attribute__ ((init_priority (NNN)))

should be supported by classes and

 __attribute__((constructor(NNN))) 

by functions.

http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html#C_002b_002b-Attributes

Unfortunately the current version fails to compile programs using this attributes:

OS.cpp:16:57: error: constructor priorities are not supported
OS.cpp:35:59: error: 'init_priority' attribute is not supported on this platform

Regards,

Liviu

Change History (15)

comment:1 Changed 11 years ago by ilg@…

The same problem applies to the gcc46 port.

Liviu

comment:2 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Keywords: gcc removed
Owner: changed from macports-tickets@… to mww@…
Port: gcc46 added
Summary: gcc47 @4.7.2 'init_priority' attribute is not supported on this platformgcc46, gcc47 @4.7.2 'init_priority' attribute is not supported on this platform

What should the MacPorts project do to correct this problem?

comment:3 Changed 11 years ago by mf2k (Frank Schima)

Cc: jeremyhu@… added
Port: gcc46, gcc47gcc46 gcc47

comment:4 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: wontfix
Status: newclosed

This is an upstream issue.

comment:5 in reply to:  4 ; Changed 11 years ago by ilg@…

Resolution: wontfix
Status: closedreopened

Replying to jeremyhu@…:

This is an upstream issue.

What do you mean by that?

I just performed a test and the default compiler in Ubuntu is quite happy with both

__attribute__((constructor(101)));
__attribute__((init_priority(102)));

The same applies to various cross compilers I used in the past, and lately, to the default clang++ that comes with Xcode.

My guess is that you either missed some build options, or you forgot to apply a mandatory patch.

I suggest you check the build procedure used for the Ubuntu gcc4.7 and update the MacPorts one accordingly.

Regards,

Liviu

Last edited 11 years ago by ilg@… (previous) (diff)

comment:6 Changed 11 years ago by jmroot (Joshua Root)

Resolution: wontfix
Status: reopenedclosed

You realise the error message says "on this platform" and Ubuntu is a different platform, right?

Seriously, we can't fix this.

http://gcc.gnu.org/viewcvs/tags/gcc_4_7_2_release/gcc/config/darwin.h?revision=191558&view=markup

/* The Apple assembler and linker do not support constructor priorities.  */
#undef SUPPORTS_INIT_PRIORITY
#define SUPPORTS_INIT_PRIORITY 0

comment:7 in reply to:  5 ; Changed 11 years ago by cooljeanius (Eric Gallager)

Replying to ilg@…:

Replying to jeremyhu@…:

This is an upstream issue.

What do you mean by that?

It means that it's an issue for the GCC developers, not the MacPorts developers.

comment:8 Changed 11 years ago by larryv (Lawrence Velázquez)

Resolution: wontfix
Status: closedreopened

wontfix implies that this is our problem.

comment:9 Changed 11 years ago by larryv (Lawrence Velázquez)

Resolution: invalid
Status: reopenedclosed

comment:10 in reply to:  7 ; Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Replying to egall@…:

Replying to ilg@…:

Replying to jeremyhu@…:

This is an upstream issue.

What do you mean by that?

It means that it's an issue for the GCC developers, not the MacPorts developers.

Actually, gcc developers are blocked by insufficient support on the host because OS X's dyld doesn't support this at runtime.

For anyone at Apple following up on this, see <rdar://problem/13028730>.

comment:11 in reply to:  10 Changed 11 years ago by cooljeanius (Eric Gallager)

Replying to jeremyhu@…:

Replying to egall@…:

Replying to ilg@…:

Replying to jeremyhu@…:

This is an upstream issue.

What do you mean by that?

It means that it's an issue for the GCC developers, not the MacPorts developers.

Actually, gcc developers are blocked by insufficient support on the host because OS X's dyld doesn't support this at runtime.

For anyone at Apple following up on this, see <rdar://problem/13028730>.

OpenRadar issue link for the rest of us?

comment:12 in reply to:  10 ; Changed 11 years ago by ilg@…

Resolution: invalid
Status: closedreopened

Actually, gcc developers are blocked by insufficient support on the host because OS X's dyld doesn't support this at runtime.

Really? Oops, then I just completed an impossible task :-)

My opinion is that the above statement about OS X not supporting init priorities is a thing of the past, as long as programs compiled with native clang accept it without problems, proper support should already be present since the move to llvm/clang.

To prove this I patched gcc/config/darwin.h and changed

#define SUPPORTS_INIT_PRIORITY 1

Then I successfully built the stock 4.7.2 using clang:

export CC=clang
export CXX=clang++
./configure ...
make
...

Could you update the existing Portfile to apply this simple patch and to use clang/clang++ during build? (it might not be necessary to explicitly use clang, I don't know now, but I can find out in about one hour)

Liviu

Last edited 11 years ago by ilg@… (previous) (diff)

comment:13 in reply to:  12 Changed 11 years ago by ilg@…

Replying to ilg@…:

(it might not be necessary to explicitly use clang, I don't know now, but I can find out in about one hour)

I confirm it, the init_priority() and constructor() attributes are functional even without explicitly compiling with clang, just patch the prehistoric darwin.h and the rest is done by the system.

As of now I did it only for 4.7, but I expect 4.6 to work as well.

Liviu

comment:14 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: invalid
Status: reopenedclosed

If you did that, you have a broken toolchain. The runtime doesn't support it.

comment:15 in reply to:  14 Changed 11 years ago by ilg@…

Replying to jeremyhu@…:

... The runtime doesn't support it.

further extensive tests showed that you are partly right, although the compiler reorders correctly the constructors within a compilation unit, the OS X linker ignores the init_priority() attribute and does not reorder the constructors (the constructors are called in the same order as the objects are linked).

thank you for your patience,

Liviu

Note: See TracTickets for help on using tickets.