[Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"

iains at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Mar 12 10:09:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47997

--- Comment #9 from Iain Sandoe <iains at gcc dot gnu.org> 2011-03-12 10:08:56 UTC ---
(In reply to comment #8)

firstly, I don't think you need to worry overly about the warning (we do place
the strings in the __TEXT segment, just not in the __cfstring section).  IMO ld
is being somewhat picky ... 
(but perhaps there is good reason for some future plans we're not aware of)

> What are the plans? Are you going to submit the fix to 4.6?

I doubt I'll have a chance before 4.6 forks -- we must be pretty close to that
... but ...

I'm currently testing a less intrusive patch (if people would like to check
this with different variants of XCode - and Mike approves it - perhaps it could
be done in time):

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c (revision 170897)
+++ gcc/config/darwin.c (working copy)
@@ -1195,7 +1195,11 @@ static section *
 darwin_mergeable_string_section (tree exp,
                                 unsigned HOST_WIDE_INT align)
 {
-  if (flag_merge_constants
+  /* Darwin's ld expects to see non-writable string literals in the .cstring 
+     section.  Later versions of ld check and complain when CFStrings are 
+     enabled.  Therefore we shall force the strings into .cstring since we
+     don't support writable ones anyway.  */
+  if ((darwin_constant_cfstrings || flag_merge_constants)
       && TREE_CODE (exp) == STRING_CST
       && TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
       && align <= 256



More information about the Gcc-bugs mailing list