First Last Prev Next    No search results available
Details
: Need weak linkage on memory functions to make them overri...
Bug#: 186
: Runtime Libraries
: libc
Status: RESOLVED
Resolution: FIXED
: Macintosh
: MacOS X
: 1.0
: P2
: normal
: 1.2

:
: compile-fail
:
:
  Show dependency tree - Show dependency graph
People
Reporter: Misha Brukman <brukman+bugs@uiuc.edu>
Assigned To: Brian R. Gaeke <gaeke+bugs@uiuc.edu>
:

Attachments
proposed patch (UNTESTED) (434 bytes, patch)
2003-12-19 01:14, Brian R. Gaeke
Details


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2003-12-15 16:39
Some applications may choose to implement their own memory managers, thus
overriding the default implementations of malloc, calloc, free, et al. Thus, we
should have weak linkage on these symbols so that an application can override
them with its own. This was found trying to link together bash.
------- Comment #2 From Brian R. Gaeke 2003-12-16 16:11:44 -------
Please note that this will produce a warning on Mac OS X, and potentially on
other systems that do not support __attribute__((weak)). 

Perhaps we should do something like what I made the C Writer output for weak
symbols?
------- Comment #4 From Brian R. Gaeke 2003-12-16 17:29:54 -------
hmm. On second glance, I realize that I don't actually know what is making the
*llvm* gcc print out the "attribute weak not supported" warning. I will have to
look through the cfe source more thoroughly. (I thought this warning was coming
from the native C compiler.) I don't have time to do it right now, but I will
reopen this so that I remember to look at it.

------- Comment #5 From Chris Lattner 2003-12-19 00:19:55 -------
When do you see this warning
?
------- Comment #6 From Brian R. Gaeke 2003-12-19 00:54:32 -------
I see this warning when I compile the LLVM runtime (bytecode) libraries on the
Mac with Misha's patch. I assume it is an erroneous warning because the
applicable backend is that of LLVM, not the Mac OS X/PPC-specific stuff, and
LLVM supports weak linkage.
------- Comment #7 From Chris Lattner 2003-12-19 00:55:24 -------
Ah, interesting!  :)

-Chris
------- Comment #8 From Brian R. Gaeke 2003-12-19 01:02:22 -------
I think what is going on is, SUPPORTS_WEAK is 0 because ASM_WEAKEN_LABEL and
ASM_WEAKEN_DECL are not defined, and darwin does not include elfos.h because it
uses Mach-O instead of ELF. I have not verified this completely, but it looks
like the most likely scenario. My guess is that varasm.c should define
SUPPORTS_WEAK to be 1 unconditionally if EMIT_LLVM....

Does this sound good Chris? (I haven't tested it.)
------- Comment #9 From Chris Lattner 2003-12-19 01:06:16 -------
Ugh, yeah.  It looks like SUPPORTS_WEAK and SUPPORTS_ONE_ONLY should be
unconditionally set when compiling into LLVM.  Maybe this should be added to
llvm-out.h, like we do for ASM_OUTPUT_DEF and CRT_*

-Chris
------- Comment #10 From Brian R. Gaeke 2003-12-19 01:14:46 -------
Created an attachment (id=51) [details]
proposed patch (UNTESTED)

You mean like this? 

(I don't feel like booting up the mac right now to test it but if you see
anything obvious let me know, and I'll try to go ahead and test it soon.)
------- Comment #11 From Chris Lattner 2003-12-19 01:15:54 -------
Yup, exactly.  Let me know if that works for you and I'll "check it in".  :)
------- Comment #12 From Brian R. Gaeke 2004-01-30 16:38:06 -------
The proposed patch seems to work on PowerPC/Mac OS X; I don't get the
warning anymore when compiling the LLVM runtime.

John, can I just go ahead and commit this to llvm-out.h?
------- Comment #13 From John T. Criswell 2004-01-30 16:44:41 -------
I believe this is fine.  Go ahead and commit it.
------- Comment #14 From Brian R. Gaeke 2004-02-02 12:43:56 -------
finally taken care of:

http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040202/011064.html

First Last Prev Next    No search results available