Bug 105522 - [powerpc-darwin] ICE: in decode_addr_const, at varasm.c:3059
Summary: [powerpc-darwin] ICE: in decode_addr_const, at varasm.c:3059
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2022-05-08 06:10 UTC by Sergey Fedorov
Modified: 2024-04-28 14:46 UTC (History)
2 users (show)

See Also:
Host:
Target: powerpc-apple-darwin
Build:
Known to work:
Known to fail: 11.3.0
Last reconfirmed: 2022-05-08 00:00:00


Attachments
Build log in a case needed (35.36 KB, text/plain)
2022-05-08 06:10 UTC, Sergey Fedorov
Details
save-temps file (118.33 KB, text/plain)
2022-05-08 08:09 UTC, Sergey Fedorov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Fedorov 2022-05-08 06:10:07 UTC
Created attachment 52938 [details]
Build log in a case needed

```
36-111% /opt/local/bin/gcc-mp-11 -DSDL2_EXPORTS -DUSING_GENERATED_CONFIG_H -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/build/include -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/include -pipe -Os -DNDEBUG -I/opt/local/include -idirafter "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/video/khronos" -I/opt/local/include/libusb-1.0 -D_THREAD_SAFE -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -fno-strict-aliasing -Wall  -arch ppc -mmacosx-version-min=10.6 -fPIC -MD -MT CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o -MF CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o.d -o CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/SDL_hidapi.c
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/SDL_hidapi.c:578:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'PLATFORM_free_hid_device':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:163:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  163 |         struct input_report *rpt = dev->input_reports;
      |         ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'get_string_property':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:265:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  265 |                 CFIndex str_len = CFStringGetLength(str);
      |                 ^~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:269:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  269 |                 CFIndex used_buf_len;
      |                 ^~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'get_string_property_utf8':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:304:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  304 |                 CFIndex str_len = CFStringGetLength(str);
      |                 ^~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:308:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  308 |                 CFIndex used_buf_len;
      |                 ^~~~~~~
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/SDL_hidapi.c:578:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'PLATFORM_hid_enumerate':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:530:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  530 |         CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
      |         ^~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:540:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  540 |         IOHIDDeviceRef *device_array = (IOHIDDeviceRef*)calloc(num_devices, sizeof(IOHIDDeviceRef));
      |         ^~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'PLATFORM_read_thread':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:742:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  742 |         CFRunLoopSourceContext ctx;
      |         ^~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:759:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  759 |         SInt32 code;
      |         ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'PLATFORM_hid_open_path':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:812:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  812 |         CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
      |         ^~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:815:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  815 |         IOHIDDeviceRef *device_array = (IOHIDDeviceRef *)calloc(num_devices, sizeof(IOHIDDeviceRef));
      |         ^~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:848:33: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  848 |                                 struct hid_device_list_node *node = (struct hid_device_list_node *)calloc(1, sizeof(struct hid_device_list_node));
      |                                 ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'PLATFORM_hid_get_feature_report':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:1091:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
 1091 |         int skipped_report_id = 0;
      |         ^~~
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/SDL_hidapi.c:578:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'create_usage_match':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/mac/hid.c:407:21: internal compiler error: in decode_addr_const, at varasm.c:3059
  407 |         const void *keys[2] = { (void *) CFSTR(kIOHIDDeviceUsagePageKey), (void *) CFSTR(kIOHIDDeviceUsageKey) };
      |                     ^~~~
```

`-save-temps` fails to produce i file, but gives the following output:
```
36-111% sudo /opt/local/bin/gcc-mp-11 -save-temps -v -DSDL2_EXPORTS -DUSING_GENERATED_CONFIG_H -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/build/include -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/include -pipe -Os -DNDEBUG -I/opt/local/include -idirafter "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/video/khronos" -I/opt/local/include/libusb-1.0 -D_THREAD_SAFE -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -fno-strict-aliasing -Wall  -arch ppc -mmacosx-version-min=10.6 -fPIC -MD -MT CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o -MF CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o.d -o CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/SDL_hidapi.c
gcc-mp-11: warning: '-pipe' ignored because '-save-temps' specified
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gcc-mp-11
Target: ppc-apple-darwin10
Configured with: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_gcc11/gcc11/work/gcc-11.3.0/configure --prefix=/opt/local --build=ppc-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc11 --includedir=/opt/local/include/gcc11 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-11 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-11 --with-gxx-include-dir=/opt/local/include/gcc11/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --with-zstd=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-bugurl=https://trac.macports.org/newticket --enable-host-shared --with-tune-cpu=G5 --disable-tls --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-pkgversion='MacPorts gcc11 11.3.0_0'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (MacPorts gcc11 11.3.0_0) 
COLLECT_GCC_OPTIONS='-save-temps' '-v' '-D' 'SDL2_EXPORTS' '-D' 'USING_GENERATED_CONFIG_H' '-I' '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/build/include' '-I' '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/include' '-pipe' '-Os' '-D' 'NDEBUG' '-I' '/opt/local/include' '-idirafter' '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/video/khronos' '-I' '/opt/local/include/libusb-1.0' '-D' '_THREAD_SAFE' '-Wshadow' '-fvisibility=hidden' '-Wdeclaration-after-statement' '-fno-strict-aliasing' '-Wall' '-fPIC' '-MD' '-MT' 'CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o' '-MF' 'CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o.d' '-o' 'CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o' '-c' '-m32' '-mmacosx-version-min=10.6' '-asm_macosx_version_min=10.6' '-nodefaultexport' '-dumpdir' 'CMakeFiles/SDL2.dir/src/hidapi/'
 /opt/local/libexec/gcc/ppc-apple-darwin10/11.3.0/cc1 -E -quiet -v -I /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/build/include -I /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/include -I /opt/local/include -I /opt/local/include/libusb-1.0 -MD CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.d -MF CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o.d -MT CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.o -D__DYNAMIC__ -D SDL2_EXPORTS -D USING_GENERATED_CONFIG_H -D NDEBUG -D _THREAD_SAFE -idirafter /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/video/khronos /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/hidapi/SDL_hidapi.c -fPIC -m32 -mmacosx-version-min=10.6 -Wshadow -Wdeclaration-after-statement -Wall -fvisibility=hidden -fno-strict-aliasing -fPIC -Os -fpch-preprocess -o CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.i
ignoring nonexistent directory "/opt/local/lib/gcc11/gcc/ppc-apple-darwin10/11.3.0/../../../../../ppc-apple-darwin10/include"
ignoring duplicate directory "/opt/local/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/build/include
 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/include
 /opt/local/include/libusb-1.0
 /opt/local/lib/gcc11/gcc/ppc-apple-darwin10/11.3.0/include
 /opt/local/include
 /opt/local/lib/gcc11/gcc/ppc-apple-darwin10/11.3.0/include-fixed
 /usr/include
 /System/Library/Frameworks
 /Library/Frameworks
 /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2/libsdl2/work/SDL2-2.0.22/src/video/khronos
End of search list.
cc1: fatal error: opening output file CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.i: No such file or directory
compilation terminated.
```
Comment 1 Iain Sandoe 2022-05-08 07:54:59 UTC
I am not going to be able to make any progress on this without a .i file (it is not an error that I've seen in any testing).

====

> CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.i: No such file or directory

Perhaps that directory has not been created at the time you are trying to run the command...

please take the -save-temps command and see if you can simplify it to just get it to produce output in the current directory.
Comment 2 Sergey Fedorov 2022-05-08 08:08:45 UTC
(In reply to Iain Sandoe from comment #1)
> I am not going to be able to make any progress on this without a .i file (it
> is not an error that I've seen in any testing).
> 
> ====
> 
> > CMakeFiles/SDL2.dir/src/hidapi/SDL_hidapi.c.i: No such file or directory
> 
> Perhaps that directory has not been created at the time you are trying to
> run the command...
> 
> please take the -save-temps command and see if you can simplify it to just
> get it to produce output in the current directory.

I am sorry, I stupidly ran command from a wrong directory. I produced the file now.
Comment 3 Sergey Fedorov 2022-05-08 08:09:59 UTC
Created attachment 52939 [details]
save-temps file
Comment 4 Iain Sandoe 2022-05-08 09:05:35 UTC
I can repeat this with the 11.3-darwin-r0 release build on powwerpc-darwin9.

Do you happen to know if this previously worked with GCC 11 and/or earlier, if so please could you identify what the last known working version was.  Thanks.
Comment 5 Sergey Fedorov 2022-05-08 09:31:30 UTC
(In reply to Iain Sandoe from comment #4)
> I can repeat this with the 11.3-darwin-r0 release build on powwerpc-darwin9.
> 
> Do you happen to know if this previously worked with GCC 11 and/or earlier,
> if so please could you identify what the last known working version was. 
> Thanks.

Unfortunately, no. I will try to test it and provide an update in awhile. (The technical difficulty is that due to changes in libgcc, I only have 11.3.0 working on 10.6, and on 10.5.8 the port doesn’t yet build for different reasons.)
Comment 6 Iain Sandoe 2022-05-08 14:31:44 UTC
it seems to fail "forever" (at least back to 5.5)

minimal reproducer:

typedef const struct __CFString * CFStringRef;

static void
create_usage_match(const unsigned int page, const unsigned int usage, int *okay)
{

 const void *keys[2] = 
   { (void *) ((CFStringRef) __builtin___CFStringMakeConstantString ("" "DeviceUsagePage" ""))
   , (void *) ((CFStringRef) __builtin___CFStringMakeConstantString ("" "DeviceUsage" ""))
   };

}
Comment 7 Sergey Fedorov 2022-05-08 16:11:41 UTC
(In reply to Iain Sandoe from comment #6)
> it seems to fail "forever" (at least back to 5.5)
> 
> minimal reproducer:
> 
> typedef const struct __CFString * CFStringRef;
> 
> static void
> create_usage_match(const unsigned int page, const unsigned int usage, int
> *okay)
> {
> 
>  const void *keys[2] = 
>    { (void *) ((CFStringRef) __builtin___CFStringMakeConstantString (""
> "DeviceUsagePage" ""))
>    , (void *) ((CFStringRef) __builtin___CFStringMakeConstantString (""
> "DeviceUsage" ""))
>    };
> 
> }

Oh wow. Surprising that it never got caught until gcc11.

P. S. Thank you very much for dealing with this!
Comment 8 Sergey Fedorov 2022-11-01 00:36:53 UTC
(In reply to Iain Sandoe from comment #6)
> it seems to fail "forever" (at least back to 5.5)

Any chance of fixing this before the next update of GCC?
Comment 9 Sergey Fedorov 2023-07-17 10:33:16 UTC
Just to update, GCC 12.3.0 exhibits the same error:

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2-snowleopard/libsdl2-snowleopard/work/SDL2-2.0.22/src/hidapi/mac/hid.c: In function 'create_usage_match':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_libsdl2-snowleopard/libsdl2-snowleopard/work/SDL2-2.0.22/src/hidapi/mac/hid.c:407:21: internal compiler error: in decode_addr_const, at varasm.cc:3083
  407 |         const void *keys[2] = { (void *) CFSTR(kIOHIDDeviceUsagePageKey), (void *) CFSTR(kIOHIDDeviceUsageKey) };
      |                     ^~~~
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <https://trac.macports.org/newticket> for instructions.
make: *** [build/SDL_hidapi.lo] Error 1
Comment 10 GCC Commits 2024-01-18 13:55:38 UTC
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:aecc0d4ba73d0810334b351da1e67232cea450d3

commit r14-8232-gaecc0d4ba73d0810334b351da1e67232cea450d3
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Jan 6 10:52:38 2024 +0000

    Darwin: Fix constant CFString code-gen [PR105522].
    
    Although this only fires for one of the Darwin sub-ports, it is latent
    elsewhere, it is also a regression c.f. the Darwin system compiler.
    
    In the code we imported from an earlier branch, CFString objects (which
    are constant aggregates) are constructed as CONST_DECLs.  Although our
    current documentation suggests that these are reserved for enumeration
    values, in fact they are used elsewhere in the compiler for constants.
    This includes Objective-C where they are used to form NSString constants.
    
    In the particular case, we take the address of the constant and that
    triggers varasm.cc:decode_addr_constant, which does not currently support
    CONST_DECL.
    
    If there is a general intent to allow/encourage wider use of CONST_DECL,
    then we should fix decode_addr_constant to look through these and evaluate
    the initializer (a two-line patch, but I'm not suggesting it for stage-4).
    
    We also need to update the GCC internals documentation to allow for the
    additional uses.
    
    This patch is Darwin-local and fixes the problem by making the CFString
    constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan
    to back-port this to the open branches once it has baked a while on trunk.
    
    Since, for Darwin, the Objective-C default is to construct constant
    NSString objects as CFStrings; this will also cover the majority of cases
    there (this patch does not make any changes to Objective-C NSStrings).
    
            PR target/105522
    
    gcc/ChangeLog:
    
            * config/darwin.cc (machopic_select_section): Handle C and C++
            CFStrings.
            (darwin_rename_builtins): Move this out of the CFString code.
            (darwin_libc_has_function): Likewise.
            (darwin_build_constant_cfstring): Create an anonymous var to
            hold each CFString.
            * config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant
            CFstrings.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Comment 11 Sergey Fedorov 2024-01-18 14:34:05 UTC
(In reply to GCC Commits from comment #10)
> The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

Iain, thank you very much for addressing this!
Comment 12 Peter Bergner 2024-03-03 21:13:19 UTC
(In reply to Sergey Fedorov from comment #11)
> (In reply to GCC Commits from comment #10)
> > The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:
> 
> Iain, thank you very much for addressing this!

If this is fixed for you, can you please move this to RESOLVED / FIXED?
Comment 13 Iain Sandoe 2024-03-03 22:00:24 UTC
fixed on trunk, intending to backport it.
Comment 14 Sergey Fedorov 2024-03-18 12:53:46 UTC
(In reply to Iain Sandoe from comment #13)
> fixed on trunk, intending to backport it.

Great! Once it is on your branches, hopefully Macports borrows the patch as well.
Comment 15 Sergey Fedorov 2024-03-18 12:55:16 UTC
(In reply to Peter Bergner from comment #12)
> (In reply to Sergey Fedorov from comment #11)
> > (In reply to GCC Commits from comment #10)
> > > The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:
> > 
> > Iain, thank you very much for addressing this!
> 
> If this is fixed for you, can you please move this to RESOLVED / FIXED?

I will need to rebuild gcc13 and try it out, allow me some time please.
Comment 16 Iain Sandoe 2024-03-18 16:09:01 UTC
(In reply to Sergey Fedorov from comment #15)
> (In reply to Peter Bergner from comment #12)
> > (In reply to Sergey Fedorov from comment #11)
> > > (In reply to GCC Commits from comment #10)
> > > > The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:
> > > 
> > > Iain, thank you very much for addressing this!
> > 
> > If this is fixed for you, can you please move this to RESOLVED / FIXED?
> 
> I will need to rebuild gcc13 and try it out, allow me some time please.

it is only fixed on trunk so far - I am currently working on back ports to earlier branches and this will be one of them - so please leave open for now.
Comment 17 GCC Commits 2024-03-31 12:47:19 UTC
The releases/gcc-13 branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:bd760ac35d792683cd82f6b665516528fe11752a

commit r13-8537-gbd760ac35d792683cd82f6b665516528fe11752a
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Jan 6 10:52:38 2024 +0000

    Darwin: Fix constant CFString code-gen [PR105522].
    
    Although this only fires for one of the Darwin sub-ports, it is latent
    elsewhere, it is also a regression c.f. the Darwin system compiler.
    
    In the code we imported from an earlier branch, CFString objects (which
    are constant aggregates) are constructed as CONST_DECLs.  Although our
    current documentation suggests that these are reserved for enumeration
    values, in fact they are used elsewhere in the compiler for constants.
    This includes Objective-C where they are used to form NSString constants.
    
    In the particular case, we take the address of the constant and that
    triggers varasm.cc:decode_addr_constant, which does not currently support
    CONST_DECL.
    
    If there is a general intent to allow/encourage wider use of CONST_DECL,
    then we should fix decode_addr_constant to look through these and evaluate
    the initializer (a two-line patch, but I'm not suggesting it for stage-4).
    
    We also need to update the GCC internals documentation to allow for the
    additional uses.
    
    This patch is Darwin-local and fixes the problem by making the CFString
    constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan
    to back-port this to the open branches once it has baked a while on trunk.
    
    Since, for Darwin, the Objective-C default is to construct constant
    NSString objects as CFStrings; this will also cover the majority of cases
    there (this patch does not make any changes to Objective-C NSStrings).
    
            PR target/105522
    
    gcc/ChangeLog:
    
            * config/darwin.cc (machopic_select_section): Handle C and C++
            CFStrings.
            (darwin_rename_builtins): Move this out of the CFString code.
            (darwin_libc_has_function): Likewise.
            (darwin_build_constant_cfstring): Create an anonymous var to
            hold each CFString.
            * config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant
            CFstrings.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    (cherry picked from commit aecc0d4ba73d0810334b351da1e67232cea450d3)
Comment 18 GCC Commits 2024-04-19 13:14:47 UTC
The releases/gcc-12 branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:b9ee0c8830592212678c402aed8a6b11ef8d2640

commit r12-10348-gb9ee0c8830592212678c402aed8a6b11ef8d2640
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Jan 6 10:52:38 2024 +0000

    Darwin: Fix constant CFString code-gen [PR105522].
    
    Although this only fires for one of the Darwin sub-ports, it is latent
    elsewhere, it is also a regression c.f. the Darwin system compiler.
    
    In the code we imported from an earlier branch, CFString objects (which
    are constant aggregates) are constructed as CONST_DECLs.  Although our
    current documentation suggests that these are reserved for enumeration
    values, in fact they are used elsewhere in the compiler for constants.
    This includes Objective-C where they are used to form NSString constants.
    
    In the particular case, we take the address of the constant and that
    triggers varasm.cc:decode_addr_constant, which does not currently support
    CONST_DECL.
    
    If there is a general intent to allow/encourage wider use of CONST_DECL,
    then we should fix decode_addr_constant to look through these and evaluate
    the initializer (a two-line patch, but I'm not suggesting it for stage-4).
    
    We also need to update the GCC internals documentation to allow for the
    additional uses.
    
    This patch is Darwin-local and fixes the problem by making the CFString
    constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan
    to back-port this to the open branches once it has baked a while on trunk.
    
    Since, for Darwin, the Objective-C default is to construct constant
    NSString objects as CFStrings; this will also cover the majority of cases
    there (this patch does not make any changes to Objective-C NSStrings).
    
            PR target/105522
    
    gcc/ChangeLog:
    
            * config/darwin.cc (machopic_select_section): Handle C and C++
            CFStrings.
            (darwin_rename_builtins): Move this out of the CFString code.
            (darwin_libc_has_function): Likewise.
            (darwin_build_constant_cfstring): Create an anonymous var to
            hold each CFString.
            * config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant
            CFstrings.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    (cherry picked from commit aecc0d4ba73d0810334b351da1e67232cea450d3)
Comment 19 GCC Commits 2024-04-28 14:35:20 UTC
The releases/gcc-11 branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:a1b0ace9737a40957bfb298de22066d8ee9a6603

commit r11-11385-ga1b0ace9737a40957bfb298de22066d8ee9a6603
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Jan 6 10:52:38 2024 +0000

    Darwin: Fix constant CFString code-gen [PR105522].
    
    Although this only fires for one of the Darwin sub-ports, it is latent
    elsewhere, it is also a regression c.f. the Darwin system compiler.
    
    In the code we imported from an earlier branch, CFString objects (which
    are constant aggregates) are constructed as CONST_DECLs.  Although our
    current documentation suggests that these are reserved for enumeration
    values, in fact they are used elsewhere in the compiler for constants.
    This includes Objective-C where they are used to form NSString constants.
    
    In the particular case, we take the address of the constant and that
    triggers varasm.cc:decode_addr_constant, which does not currently support
    CONST_DECL.
    
    If there is a general intent to allow/encourage wider use of CONST_DECL,
    then we should fix decode_addr_constant to look through these and evaluate
    the initializer (a two-line patch, but I'm not suggesting it for stage-4).
    
    We also need to update the GCC internals documentation to allow for the
    additional uses.
    
    This patch is Darwin-local and fixes the problem by making the CFString
    constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan
    to back-port this to the open branches once it has baked a while on trunk.
    
    Since, for Darwin, the Objective-C default is to construct constant
    NSString objects as CFStrings; this will also cover the majority of cases
    there (this patch does not make any changes to Objective-C NSStrings).
    
            PR target/105522
    
    gcc/ChangeLog:
    
            * config/darwin.c (machopic_select_section): Handle C and C++
            CFStrings.
            (darwin_rename_builtins): Move this out of the CFString code.
            (darwin_libc_has_function): Likewise.
            (darwin_build_constant_cfstring): Create an anonymous var to
            hold each CFString.
            * config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant
            CFstrings.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    (cherry picked from commit aecc0d4ba73d0810334b351da1e67232cea450d3)
Comment 20 Iain Sandoe 2024-04-28 14:46:35 UTC
fixed on open branches (needed on earlier if maintained).