Closed magnified103 closed 1 year ago
confirmed.
It looks like the code (at O0) saves the end position of the array as a constant (.data.rel.ro.local is constant data section on ELF, but not for Mach-O). At O1 and above the value is computed in-line (so that it does not try to create the constant in that section).
Oddly, it looks like we compute the end address of smaller arrays in-line even at O0 (so it will be a case of tracking down where this decision is made, and then making sure that we emit a suitable section designator for macOS / Mach-O).
This issue still exists on gcc13. I have attempted to downgrade to gcc11 and the issue has been resolved.
fixed on this branch now.
I'm trying to build this snippet under GCC 12.2 (homebrew) on macOS 13
Build:
It seems that the error does not occur with
-O2
flag.g++-12 -v
```shell Using built-in specs. COLLECT_GCC=g++-12 COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/12.2.0/bin/../libexec/gcc/aarch64-apple-darwin22/12/lto-wrapper Target: aarch64-apple-darwin22 Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-12 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 12.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=aarch64-apple-darwin22 --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Homebrew GCC 12.2.0) ```