public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
@ 2011-03-05  1:06 anatol.pomozov at gmail dot com
  2011-03-05  2:26 ` [Bug c/47997] " howarth at nitro dot med.uc.edu
                   ` (28 more replies)
  0 siblings, 29 replies; 30+ messages in thread
From: anatol.pomozov at gmail dot com @ 2011-03-05  1:06 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: gcc on macosx: "ld: warning: -fwritable-strings not
                    compatible with literal CF/NSString"
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: anatol.pomozov@gmail.com


Created attachment 23553
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23553
A repro case for "ld: warning: -fwritable-strings not compatible with literal
CF/NSString" warning

Hi,

I am trying to implement a program that uses fsevent library on macosx.
http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html#//apple_ref/doc/uid/TP40005289-CH4-SW4

And I need some features (such as __thread) that is not supported neither by
outdated GCC from XCode, nor by Clang. The only option is GCC from MacPorts.

I installed GCC-4.6 from macports (gcc46 @4.6-20110226) and trying to compile a
fsevent sample (see it in the attachement).

When I try to compile it with gcc 4.6 it produces a weird warning:

$ gcc-mp-4.6 -framework CoreServices ld_warn.c
ld: warning: -fwritable-strings not compatible with literal CF/NSString in
/var/folders/++/++27Xk++6+0++4RjPqRgNE+-0Mw/-Tmp-//cc3B1vHB.o


The output binary looks OK.

When I try to compile the same sources either with gcc from XCode or clang - it
compiles without any warning:

$ clang -framework CoreServices ld_warn.c


It makes me think that this is an issue with GCC.


I also googled following clang bug that looks very similar
http://llvm.org/bugs/show_bug.cgi?id=8993


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug c/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
@ 2011-03-05  2:26 ` howarth at nitro dot med.uc.edu
  2011-03-05  9:08 ` iains at gcc dot gnu.org
                   ` (27 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2011-03-05  2:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jack Howarth <howarth at nitro dot med.uc.edu> 2011-03-05 02:26:12 UTC ---
This is odd since -fwritable-strings has been removed from FSF gcc since 2004.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug c/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
  2011-03-05  2:26 ` [Bug c/47997] " howarth at nitro dot med.uc.edu
@ 2011-03-05  9:08 ` iains at gcc dot gnu.org
  2011-03-05 10:18 ` [Bug target/47997] " iains at gcc dot gnu.org
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-03-05  9:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> 2011-03-05 09:08:29 UTC ---
we don't implement writable strings, but at present we place the ascii in
".const".
it seems that ld is expecting to see constant strings in .cstring (and won't
accept .const as an alternative).
[[ FTR, the Apple compiler places the strings in .data when they are writable
]].

untested patch:

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c (revision 170678)
+++ gcc/config/darwin.c (working copy)
@@ -1536,6 +1536,12 @@ machopic_select_section (tree decl,
       gcc_unreachable ();
     }

+  if (TREE_CODE (decl) == STRING_CST
+      && (MAX ((HOST_WIDE_INT)TREE_STRING_LENGTH (decl),
+              int_size_in_bytes (TREE_TYPE (decl)))
+         == (HOST_WIDE_INT) strlen (TREE_STRING_POINTER (decl)) + 1))
+    return darwin_sections[cstring_section];
+
   /* Darwin weird special cases.  
      a) OBJC Meta-data. */
   if (DECL_P (decl)


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
  2011-03-05  2:26 ` [Bug c/47997] " howarth at nitro dot med.uc.edu
  2011-03-05  9:08 ` iains at gcc dot gnu.org
@ 2011-03-05 10:18 ` iains at gcc dot gnu.org
  2011-03-07 15:38 ` howarth at nitro dot med.uc.edu
                   ` (25 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-03-05 10:18 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-apple-darwin10
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.03.05 10:18:04
          Component|c                           |target
     Ever Confirmed|0                           |1

--- Comment #3 from Iain Sandoe <iains at gcc dot gnu.org> 2011-03-05 10:18:04 UTC ---
... changing category to 'target'
... not reproducible on Darwin9 (OSX 10.5).


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (2 preceding siblings ...)
  2011-03-05 10:18 ` [Bug target/47997] " iains at gcc dot gnu.org
@ 2011-03-07 15:38 ` howarth at nitro dot med.uc.edu
  2011-03-07 17:45 ` mrs at gcc dot gnu.org
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2011-03-07 15:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jack Howarth <howarth at nitro dot med.uc.edu> 2011-03-07 15:37:54 UTC ---
The proposed patch in Comment 2 fixes the problem testcase and causes no
regressions on x86_64-apple-darwin10.

http://gcc.gnu.org/ml/gcc-testresults/2011-03/msg00571.html


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (3 preceding siblings ...)
  2011-03-07 15:38 ` howarth at nitro dot med.uc.edu
@ 2011-03-07 17:45 ` mrs at gcc dot gnu.org
  2011-03-07 17:47 ` howarth at nitro dot med.uc.edu
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: mrs at gcc dot gnu.org @ 2011-03-07 17:45 UTC (permalink / raw)
  To: gcc-bugs

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

mrs@gcc.gnu.org <mrs at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrs at gcc dot gnu.org

--- Comment #5 from mrs at gcc dot gnu.org <mrs at gcc dot gnu.org> 2011-03-07 17:45:29 UTC ---
Ok.  I'm hoping you double checked the incantation with the other version that
exists.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (4 preceding siblings ...)
  2011-03-07 17:45 ` mrs at gcc dot gnu.org
@ 2011-03-07 17:47 ` howarth at nitro dot med.uc.edu
  2011-03-07 18:16 ` mikestump at comcast dot net
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2011-03-07 17:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jack Howarth <howarth at nitro dot med.uc.edu> 2011-03-07 17:46:58 UTC ---
(In reply to comment #5)
> Ok.  I'm hoping you double checked the incantation with the other version that
> exists.

How would I do that?


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (5 preceding siblings ...)
  2011-03-07 17:47 ` howarth at nitro dot med.uc.edu
@ 2011-03-07 18:16 ` mikestump at comcast dot net
  2011-03-12  4:50 ` anatol.pomozov at gmail dot com
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: mikestump at comcast dot net @ 2011-03-07 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Mike Stump <mikestump at comcast dot net> 2011-03-07 18:16:13 UTC ---
Ok, you can look for strlen (s) == IDENTIFIER_LENGTH (x) in either the
darwin.[ch] files, or, failing one there, in the backend files...  I know I've
seen one before, just can't recall where exactly.  In theory, the two should be
virtually identical, or one of them is wrong.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (6 preceding siblings ...)
  2011-03-07 18:16 ` mikestump at comcast dot net
@ 2011-03-12  4:50 ` anatol.pomozov at gmail dot com
  2011-03-12 10:09 ` iains at gcc dot gnu.org
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: anatol.pomozov at gmail dot com @ 2011-03-12  4:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Anatol <anatol.pomozov at gmail dot com> 2011-03-12 04:50:22 UTC ---
What are the plans? Are you going to submit the fix to 4.6?

How can I help you with testing?


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (7 preceding siblings ...)
  2011-03-12  4:50 ` anatol.pomozov at gmail dot com
@ 2011-03-12 10:09 ` iains at gcc dot gnu.org
  2011-03-12 13:45 ` iains at gcc dot gnu.org
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-03-12 10:09 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (8 preceding siblings ...)
  2011-03-12 10:09 ` iains at gcc dot gnu.org
@ 2011-03-12 13:45 ` iains at gcc dot gnu.org
  2011-03-12 16:24 ` mikestump at comcast dot net
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-03-12 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Iain Sandoe <iains at gcc dot gnu.org> 2011-03-12 13:45:38 UTC ---
patch @ comment #9 works for me on *-darwin9 (places the strings in .cstring).

I would propose this rather than the one in comment #2.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (9 preceding siblings ...)
  2011-03-12 13:45 ` iains at gcc dot gnu.org
@ 2011-03-12 16:24 ` mikestump at comcast dot net
  2011-06-26 16:26 ` iains at gcc dot gnu.org
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: mikestump at comcast dot net @ 2011-03-12 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Mike Stump <mikestump at comcast dot net> 2011-03-12 16:23:45 UTC ---
Ok for the patch in comment #9.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (10 preceding siblings ...)
  2011-03-12 16:24 ` mikestump at comcast dot net
@ 2011-06-26 16:26 ` iains at gcc dot gnu.org
  2011-06-28  9:17 ` iains at gcc dot gnu.org
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-06-26 16:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Iain Sandoe <iains at gcc dot gnu.org> 2011-06-26 16:25:32 UTC ---
Author: iains
Date: Sun Jun 26 16:25:29 2011
New Revision: 175410

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175410
Log:

    PR target/47997
    * config/darwin.c (darwin_mergeable_string_section): Place string
    constants in '.cstring' rather than '.const' when CF/NSStrings are
    active.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/darwin.c


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (11 preceding siblings ...)
  2011-06-26 16:26 ` iains at gcc dot gnu.org
@ 2011-06-28  9:17 ` iains at gcc dot gnu.org
  2011-06-28  9:18 ` iains at gcc dot gnu.org
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-06-28  9:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Iain Sandoe <iains at gcc dot gnu.org> 2011-06-28 09:16:08 UTC ---
Author: iains
Date: Tue Jun 28 09:16:04 2011
New Revision: 175578

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175578
Log:

    PR target/47997
    * config/darwin.c (darwin_mergeable_string_section): Place string
    constants in '.cstring' rather than '.const' when CF/NSStrings are
    active.


Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/darwin.c


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (12 preceding siblings ...)
  2011-06-28  9:17 ` iains at gcc dot gnu.org
@ 2011-06-28  9:18 ` iains at gcc dot gnu.org
  2011-07-20 20:52 ` tobias.netzel at googlemail dot com
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-06-28  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #14 from Iain Sandoe <iains at gcc dot gnu.org> 2011-06-28 09:17:47 UTC ---
fixed on trunk and 4.6 branch (sorry it took a while to commit the fix).


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (13 preceding siblings ...)
  2011-06-28  9:18 ` iains at gcc dot gnu.org
@ 2011-07-20 20:52 ` tobias.netzel at googlemail dot com
  2011-07-20 20:54 ` tobias.netzel at googlemail dot com
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: tobias.netzel at googlemail dot com @ 2011-07-20 20:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Tobias Netzel <tobias.netzel at googlemail dot com> 2011-07-20 20:51:12 UTC ---
Created attachment 24800
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24800
sample objective-c code that still causes the warning

Said warning does still occur when linking many Objective-C and Objective-C++
files from the mozilla codebase.
The attached sample code and playing a little with it reveals the following
behaviour of gcc:
(to be compiled as follows: "gcc main.m -framework Foundation")
- the strings "Me", "Myself", "I", "Three", "a", "b", "c", "d", "e", "f" and ""
are put into (__TEXT,__const) -> warning
- the strings "One", "Two", "You" and "foo" are put into (__TEXT,__cstring) ->
no warning
- when adding more strings to "NSMutableArray *mutable" or to the
initialization of "NSArray *arr", all strings that have a length other than
three characters are put into (__TEXT,__const) (-> warning) and all strings of
exactly three characters are put into (__TEXT,__cstring) (-> no warning)
- when there's only one string in (__TEXT,__const) there is no warning!


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (14 preceding siblings ...)
  2011-07-20 20:52 ` tobias.netzel at googlemail dot com
@ 2011-07-20 20:54 ` tobias.netzel at googlemail dot com
  2011-07-20 21:16 ` mrs at gcc dot gnu.org
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: tobias.netzel at googlemail dot com @ 2011-07-20 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Netzel <tobias.netzel at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobias.netzel at googlemail
                   |                            |dot com

--- Comment #16 from Tobias Netzel <tobias.netzel at googlemail dot com> 2011-07-20 20:53:38 UTC ---
Forgot to mention that there weren't any warnings with the 1st (unaccepted)
patch applied.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (15 preceding siblings ...)
  2011-07-20 20:54 ` tobias.netzel at googlemail dot com
@ 2011-07-20 21:16 ` mrs at gcc dot gnu.org
  2011-07-20 21:26 ` mrs at gcc dot gnu.org
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: mrs at gcc dot gnu.org @ 2011-07-20 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

mrs@gcc.gnu.org <mrs at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
         Resolution|FIXED                       |

--- Comment #17 from mrs at gcc dot gnu.org <mrs at gcc dot gnu.org> 2011-07-20 21:15:07 UTC ---
If your not happy, we're not happy.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (16 preceding siblings ...)
  2011-07-20 21:16 ` mrs at gcc dot gnu.org
@ 2011-07-20 21:26 ` mrs at gcc dot gnu.org
  2011-07-20 21:54 ` tobias.netzel at googlemail dot com
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: mrs at gcc dot gnu.org @ 2011-07-20 21:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from mrs at gcc dot gnu.org <mrs at gcc dot gnu.org> 2011-07-20 21:25:37 UTC ---
Iain, I'm thinking we should do your code unconditionally for darwin10 and
later.  In darwin10.h, we put:

#define LINKER_PEDANTICALLY_WANTS_CSTRING 1

and then in the code:

   if ((LINKER_PEDANTICALLY_WANTS_CSTRING
       || darwin_constant_cfstrings || flag_merge_constants)
       && TREE_CODE (exp) == STRING_CST
       && TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
       && align <= 256

Another possibility, is to just _always_ do this:

   if (TREE_CODE (exp) == STRING_CST
       && TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
       && align <= 256

thoughts?  Jack, if you do the testsuite run, I'll check it in if it works. 
I'm a little nervous about the release branch...  :-(  Linker, shut up, would
have been my preference, but, I don't know if we have that option.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (17 preceding siblings ...)
  2011-07-20 21:26 ` mrs at gcc dot gnu.org
@ 2011-07-20 21:54 ` tobias.netzel at googlemail dot com
  2011-07-21  7:55 ` iains at gcc dot gnu.org
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: tobias.netzel at googlemail dot com @ 2011-07-20 21:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from Tobias Netzel <tobias.netzel at googlemail dot com> 2011-07-20 21:53:16 UTC ---
(In reply to comment #18)
> Iain, I'm thinking we should do your code unconditionally for darwin10 and
> later.  In darwin10.h, we put:

To me it seems that specifying LINKER_PEDANTICALLY_WANTS_CSTRING would only do
the same thing as passing -mconstant-cfstrings to gcc. And passing
-mconstant-cfstrings doesn't change anything in my case.
The only thing that helps in my case is the first patch.
You should also be aware that one can build and use (I do) the linker from
darwin10 in earlier versions of the OS.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (18 preceding siblings ...)
  2011-07-20 21:54 ` tobias.netzel at googlemail dot com
@ 2011-07-21  7:55 ` iains at gcc dot gnu.org
  2011-07-21  9:06 ` iains at gcc dot gnu.org
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-07-21  7:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Iain Sandoe <iains at gcc dot gnu.org> 2011-07-21 07:54:51 UTC ---
hm .. I think this might be a new (objc). bug, rather than a back-end problem;
since it doesn't show with normal c-strings (even when compiled -x
objective-c).  

Will try to take a look.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (19 preceding siblings ...)
  2011-07-21  7:55 ` iains at gcc dot gnu.org
@ 2011-07-21  9:06 ` iains at gcc dot gnu.org
  2011-07-21 10:36 ` iains at gcc dot gnu.org
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-07-21  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from Iain Sandoe <iains at gcc dot gnu.org> 2011-07-21 09:05:10 UTC ---
This is indeed a new bug - if there is to be any lengthly deliberation, please
move it to its own PR (against objective-c).

----

calling fix_string_type () on a tree that is already a STRING_CST appears to
break things.. 

(the size and unit_size fields get screwed up).

... this might be intended [i.e. we should not call the function when we
already have a STRING_CST]
(or indicate a bug elsewhere).

I am assuming the former for now.... ergo, try this:

Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 176554)
+++ gcc/objc/objc-act.c (working copy)
@@ -3132,10 +3132,13 @@ objc_build_string_object (tree string)
   struct string_descriptor *desc, key;
   void **loc;

-  /* Prep the string argument.  */
-  string = fix_string_type (string);
-  TREE_SET_CODE (string, STRING_CST);
-  length = TREE_STRING_LENGTH (string) - 1;
+  if (TREE_CODE (string) != STRING_CST)
+    {
+      /* Prep the string argument.  */
+      string = fix_string_type (string);
+      TREE_SET_CODE (string, STRING_CST);
+      length = TREE_STRING_LENGTH (string) - 1;
+    }

   /* The target may have different ideas on how to construct an ObjC string
      literal.  On Darwin (Mac OS X), for example, we may wish to obtain a


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (20 preceding siblings ...)
  2011-07-21  9:06 ` iains at gcc dot gnu.org
@ 2011-07-21 10:36 ` iains at gcc dot gnu.org
  2011-07-21 14:53 ` iains at gcc dot gnu.org
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-07-21 10:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from Iain Sandoe <iains at gcc dot gnu.org> 2011-07-21 10:36:02 UTC ---
hmm, comment #21 is not the right solution ...  (even if it works)

... the right solution is either  
   (a) to handle arrays of arbitrary-sized ints in fix_string_type () (without
assuming that they are whar when not explicitly set to
char{,16,32}_array_type_node)

   or

   (b) to force the type of CPP_OBJC_STRING to be char{,16,32}_array_type_node
as appropriate.

a. might look something like:

Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c     (revision 176554)
+++ gcc/c-family/c-common.c     (working copy)
@@ -911,6 +911,32 @@ fix_string_type (tree value)
       nchars = length / (TYPE_PRECISION (char32_type_node) / BITS_PER_UNIT);
       e_type = char32_type_node;
     }
+  else if (TREE_TYPE (value) && TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE)
+    {
+      int prec;
+
+      if (TREE_TYPE (TREE_TYPE ((value))))
+        prec = TYPE_PRECISION (TREE_TYPE (TREE_TYPE ((value))));
+      else
+        prec = TYPE_PRECISION (wchar_type_node);
+
+      nchars = length / (prec / BITS_PER_UNIT);
+      switch (prec)
+        {
+       case BITS_PER_UNIT:
+         e_type = char_type_node;
+         break;
+       case 16:
+         e_type = char16_type_node;
+         break;
+       case 32:
+         e_type = char32_type_node;
+         break;
+       default:
+         e_type = wchar_type_node;
+         break;
+       }
+    }
   else
     {
       nchars = length / (TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT);

b. needs some more investigation.

thoughts?


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (21 preceding siblings ...)
  2011-07-21 10:36 ` iains at gcc dot gnu.org
@ 2011-07-21 14:53 ` iains at gcc dot gnu.org
  2011-08-31 19:03 ` mrs at gcc dot gnu.org
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-07-21 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #23 from Iain Sandoe <iains at gcc dot gnu.org> 2011-07-21 14:52:26 UTC ---
OK, done some more debugging ....

so one can't call fix_string_type () twice on the same string and get a
sensible result...
... the determination of the string type by equating to one of the global_tree
nodes is broken on the second call since the first call overwrites the tree
type:

code fragment from fix_string_type ():

  i_type = build_index_type (size_int (nchars - 1));
  a_type = build_array_type (e_type, i_type);
  if (c_dialect_cxx() || warn_write_strings)
    a_type = c_build_qualified_type (a_type, TYPE_QUAL_CONST);

  TREE_TYPE (value) = a_type;

===

So either this is wrong - or we need some way to know that fix_string_type has
already been called (by lex_string()).

in the meantime - this just avoids making the second call, because I can't see
that there's any case in which objc_build_string_object () is called without a
string from lex_string ()?  
(grep suggests not).

thus; assuming that fix_string_type () is behaving as expected, the following
is a fix :

Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 176554)
+++ gcc/objc/objc-act.c (working copy)
@@ -3132,9 +3132,8 @@ objc_build_string_object (tree string)
   struct string_descriptor *desc, key;
   void **loc;

-  /* Prep the string argument.  */
-  string = fix_string_type (string);
-  TREE_SET_CODE (string, STRING_CST);
+  gcc_checking_assert (TREE_CODE (string) == STRING_CST);
+
   length = TREE_STRING_LENGTH (string) - 1;

   /* The target may have different ideas on how to construct an ObjC string


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (22 preceding siblings ...)
  2011-07-21 14:53 ` iains at gcc dot gnu.org
@ 2011-08-31 19:03 ` mrs at gcc dot gnu.org
  2011-09-08 16:30 ` tobias.netzel at googlemail dot com
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: mrs at gcc dot gnu.org @ 2011-08-31 19:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #24 from mrs at gcc dot gnu.org <mrs at gcc dot gnu.org> 2011-08-31 17:55:19 UTC ---
I don't have a take on the best way to fix this.  With that said, if you like
the last patch and it tests out, Ok.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (23 preceding siblings ...)
  2011-08-31 19:03 ` mrs at gcc dot gnu.org
@ 2011-09-08 16:30 ` tobias.netzel at googlemail dot com
  2011-10-29 13:00 ` iains at gcc dot gnu.org
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: tobias.netzel at googlemail dot com @ 2011-09-08 16:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #25 from Tobias Netzel <tobias.netzel at googlemail dot com> 2011-09-08 16:27:21 UTC ---
As for me the patch does what it is expected to do; no more linker warnings
when linking objective-c code. I didn't notice anything that might be broken by
it.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (24 preceding siblings ...)
  2011-09-08 16:30 ` tobias.netzel at googlemail dot com
@ 2011-10-29 13:00 ` iains at gcc dot gnu.org
  2011-10-29 13:04 ` iains at gcc dot gnu.org
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-10-29 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #26 from Iain Sandoe <iains at gcc dot gnu.org> 2011-10-29 12:59:33 UTC ---
Author: iains
Date: Sat Oct 29 12:59:30 2011
New Revision: 180653

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180653
Log:

gcc/objc:

    PR target/47997
    * objc-act.c (objc_build_string_object): Remove redundant second
    call to fix_string_type ().  Add a checking assert that we are,
    indeed, passed a STRING_CST.


Modified:
    trunk/gcc/objc/ChangeLog
    trunk/gcc/objc/objc-act.c


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (25 preceding siblings ...)
  2011-10-29 13:00 ` iains at gcc dot gnu.org
@ 2011-10-29 13:04 ` iains at gcc dot gnu.org
  2011-11-12 14:13 ` iains at gcc dot gnu.org
  2011-11-12 14:14 ` iains at gcc dot gnu.org
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-10-29 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #27 from Iain Sandoe <iains at gcc dot gnu.org> 2011-10-29 13:03:27 UTC ---
let's give it a few weeks on trunk - and then back-port to 4.6 if all is OK
(since we just missed the 4.6.2 release).


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (26 preceding siblings ...)
  2011-10-29 13:04 ` iains at gcc dot gnu.org
@ 2011-11-12 14:13 ` iains at gcc dot gnu.org
  2011-11-12 14:14 ` iains at gcc dot gnu.org
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-11-12 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #29 from Iain Sandoe <iains at gcc dot gnu.org> 2011-11-12 14:05:32 UTC ---
fixed.


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Bug target/47997] gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString"
  2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
                   ` (27 preceding siblings ...)
  2011-11-12 14:13 ` iains at gcc dot gnu.org
@ 2011-11-12 14:14 ` iains at gcc dot gnu.org
  28 siblings, 0 replies; 30+ messages in thread
From: iains at gcc dot gnu.org @ 2011-11-12 14:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #28 from Iain Sandoe <iains at gcc dot gnu.org> 2011-11-12 14:05:03 UTC ---
Author: iains
Date: Sat Nov 12 14:04:58 2011
New Revision: 181314

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181314
Log:

gcc/objc:

    Backport from mainline
    2011-10-29  Iain Sandoe  <iains@gcc.gnu.org>

    PR target/47997
    * objc-act.c (objc_build_string_object): Remove redundant second
    call to fix_string_type ().  Add a checking assert that we are,
    indeed, passed a STRING_CST.


Modified:
    branches/gcc-4_6-branch/gcc/objc/ChangeLog
    branches/gcc-4_6-branch/gcc/objc/objc-act.c


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2011-11-12 14:07 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-05  1:06 [Bug c/47997] New: gcc on macosx: "ld: warning: -fwritable-strings not compatible with literal CF/NSString" anatol.pomozov at gmail dot com
2011-03-05  2:26 ` [Bug c/47997] " howarth at nitro dot med.uc.edu
2011-03-05  9:08 ` iains at gcc dot gnu.org
2011-03-05 10:18 ` [Bug target/47997] " iains at gcc dot gnu.org
2011-03-07 15:38 ` howarth at nitro dot med.uc.edu
2011-03-07 17:45 ` mrs at gcc dot gnu.org
2011-03-07 17:47 ` howarth at nitro dot med.uc.edu
2011-03-07 18:16 ` mikestump at comcast dot net
2011-03-12  4:50 ` anatol.pomozov at gmail dot com
2011-03-12 10:09 ` iains at gcc dot gnu.org
2011-03-12 13:45 ` iains at gcc dot gnu.org
2011-03-12 16:24 ` mikestump at comcast dot net
2011-06-26 16:26 ` iains at gcc dot gnu.org
2011-06-28  9:17 ` iains at gcc dot gnu.org
2011-06-28  9:18 ` iains at gcc dot gnu.org
2011-07-20 20:52 ` tobias.netzel at googlemail dot com
2011-07-20 20:54 ` tobias.netzel at googlemail dot com
2011-07-20 21:16 ` mrs at gcc dot gnu.org
2011-07-20 21:26 ` mrs at gcc dot gnu.org
2011-07-20 21:54 ` tobias.netzel at googlemail dot com
2011-07-21  7:55 ` iains at gcc dot gnu.org
2011-07-21  9:06 ` iains at gcc dot gnu.org
2011-07-21 10:36 ` iains at gcc dot gnu.org
2011-07-21 14:53 ` iains at gcc dot gnu.org
2011-08-31 19:03 ` mrs at gcc dot gnu.org
2011-09-08 16:30 ` tobias.netzel at googlemail dot com
2011-10-29 13:00 ` iains at gcc dot gnu.org
2011-10-29 13:04 ` iains at gcc dot gnu.org
2011-11-12 14:13 ` iains at gcc dot gnu.org
2011-11-12 14:14 ` iains at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).