• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Static initialisers in static libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Static initialisers in static libraries


  • Subject: Static initialisers in static libraries
  • From: Dair Grant <email@hidden>
  • Date: Mon, 29 Aug 2005 23:08:55 +0100

Hi,

We've run into a problem where static initialisers within static
libraries aren't being called, and I wanted to confirm this is the
expected behaviour prior to logging a bug.

From what we can see, ld appears to be make a distinction between .o
files and .a files when it comes to static initialisers. The rules seem
to be:

  - If the initialiser is in a .o file, it will be called
  - If the initialiser is in a .a file, it may  be called

I.e., if you have a static initialiser in foo.cpp, and you build foo.cpp
as part of your app, then that initialiser will always be called.

If you put foo.cpp into a static library, and link your app to that,
then the initialiser will only be called if a)you pass -all_load to the
linker or b)foo.cpp is referenced for some other reason.


We'd rather not use -all_load, so is there any other flag we can use to
persuade the linker to treat static initialisers consistently no matter
how they're introduced into the link?

The behaviour seems to be distinct from -no_dead_strip_inits_and_terms:
i.e., the decision to treat a static initialiser as reachable or not
seems to depend on how the object code is packaged, and not on if dead
code stripping is/is not enabled.


-dair
___________________________________________________
mailto:email@hidden     http://www.zonic.co.uk/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Static initialisers in static libraries
      • From: "Peter O'Gorman" <email@hidden>
  • Prev by Date: Re: Editor Centers Insertion Point On Resize - MAKE IT STOP!
  • Next by Date: Re: Static initialisers in static libraries
  • Previous by thread: Re: Editor Centers Insertion Point On Resize - MAKE IT STOP!
  • Next by thread: Re: Static initialisers in static libraries
  • Index(es):
    • Date
    • Thread