[AD] [ alleg-Bugs-3157005 ] Dynamic linker can't find _al_managled_main with XCode4

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Bugs item #3157005, was opened at 2011-01-13 08:59
Message generated for change (Comment added) made by peterhull90
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=3157005&group_id=5665

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Mac OSX
Group: None
Status: Open
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Owen Anderson (resistor)
Assigned to: Peter Hull (peterhull90)
Summary: Dynamic linker can't find _al_managled_main with XCode4

Initial Comment:
The XCode4 Developer Preview has -fvisibility=hidden on by default, which makes the dynamic linker unable to resolve it at runtime.  This option is good for both launch time and optimization, so it's desirable to have it on.  Given that, please consider adding "__attribute__ ((visibility("default")))" to the OS X declaration of _al_mangled_main.

----------------------------------------------------------------------

>Comment By: Peter Hull (peterhull90)
Date: 2011-01-16 09:04

Message:
So there are 2 issues:
First, making _al_mangled_main visible. That just needs the definition of
main to be changed as Resistor suggested. Slight caveat, it clashes with
NSThread's -(void) main method (this always happened but didn't cause any
problems before). I think the best way is to disable Magic Main when
building the library. I'll post a patch when I've had a chance to test it a
bit more.
Second, compiling the whole of allegro with -fvisibility=hidden. As Elias
expected this causes a whole load of linker errors. Fortunately we already
have the AL_FUNC macro, which is used on MSVC to do the analogous thing for
DLLs (i.e. declspec(dllexport) ). So, it should be straightforward to add
__attribute__ ((visibility("default"))) to the definition of AL_FUNC for OS
X (and Linux too, I guess) but I haven't tried it yet.

----------------------------------------------------------------------

Comment By: Elias Pschernig (elias)
Date: 2011-01-15 04:51

Message:
Ah, yes, I keep forgetting that under OSX the user main() is just some
weird macro. Makes sense then.


----------------------------------------------------------------------

Comment By: Owen Anderson (resistor)
Date: 2011-01-15 03:39

Message:
That's not the same situation.  The user's main is rewritten to
_al_mangled_main on OS X, and is in the user's linked binary.  The real
main is in allegro_main.dylib, which calls _al_mangled_main on launch. 
This means that _al_mangled_main has to be public, rather than hidden, even
though it's in the user's code rather than in the Allegro dynamic library.

----------------------------------------------------------------------

Comment By: Elias Pschernig (elias)
Date: 2011-01-14 14:44

Message:
Does Allegro compile with -fvisibility=hidden at all? We don't set any
symbols to __attribute__ ((visibility("default"))) from what I can see. And
all non-public functions are declared static anyway. (Functions starting
with _al_ are public if user code includes any of the allegro5/internal/*
headers.)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=3157005&group_id=5665




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/