Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible issue with availability macros #4

Closed
ilg-ul opened this issue May 30, 2024 · 16 comments
Closed

Possible issue with availability macros #4

ilg-ul opened this issue May 30, 2024 · 16 comments

Comments

@ilg-ul
Copy link

ilg-ul commented May 30, 2024

As I previously reported, I had successful builds of GCC 14 on

  • macOS 10.14 with CLT 10.3 (using MACOSX_DEPLOYMENT_TARGET="10.13"),
  • macOS 14.3 with CLT 15.3
  • macOS 11.7 (arm64) with CLT 13.2

In all cases I used the Homebrew patches, and running the extensive tests locally passed.

However, when making the final distribution binaries, I noticed that running the 10.13 binaries on newer machines fails during preprocessing, with errors related to the availability macros.

I isolated a preprocessor command for a simple hello program, and the result is:

[/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/gcc simple-hello.c -o simple-hello-c-one.c.h -g -v -v -Wl,-t -E]
Using built-in specs.
COLLECT_GCC=/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/gcc
Target: x86_64-apple-darwin18.7.0
Configured with: /Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/sources/gcc-14.1.0/configure --prefix=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/application --program-suffix= --infodir=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install/share/info --mandir=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install/share/man --htmldir=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install/share/html --pdfdir=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install/share/pdf --build=x86_64-apple-darwin18.7.0 --host=x86_64-apple-darwin18.7.0 --target=x86_64-apple-darwin18.7.0 --with-pkgversion='xPack GCC x86_64' --with-dwarf2 --with-diagnostics-color=auto --with-libiconv-prefix=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install --with-gmp=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install --with-isl=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install --with-mpc=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install --with-mpfr=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install --with-zstd=/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install --with-system-zlib --without-cuda-driver --enable-languages=c,c++,objc,obj-c++,lto,fortran --enable-objc-gc=auto --enable-checking=release --enable-lto --enable-plugin --enable-__cxa_atexit --enable-cet=auto --enable-cloog-backend=isl --enable-default-pie --enable-libgomp --enable-libssp --enable-default-ssp --enable-libatomic --enable-graphite --enable-libquadmath --enable-libquadmath-support --enable-libstdcxx --enable-libstdcxx-backtrace --enable-libstdcxx-time=yes --enable-libstdcxx-visibility --enable-libstdcxx-threads --enable-static --with-default-libstdcxx-abi=new --enable-pie-tools --enable-gold --disable-nls --disable-libstdcxx-debug --disable-libstdcxx-pch --disable-install-libiberty --disable-werror --enable-shared --enable-threads=posix --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk --enable-bootstrap --with-stage1-ldflags=' -L/Users/ilg/Library/xPacks/@xpack-dev-tools/clang/16.0.6-1.1/.content/lib -L/Users/ilg/Library/xPacks/@xpack-dev-tools/clang/16.0.6-1.1/.content/lib/clang/16/lib/darwin' --with-boot-ldflags=' -v -static-libstdc++ -static-libgcc  -O2 -v -Wl,-macosx_version_min,10.13 -Wl,-headerpad_max_install_names -Wl,-dead_strip -L/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install/lib -Wl,-rpath,/Users/ilg/actions-runners/xpack-dev-tools/_work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin18.7.0/install/lib' --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (xPack GCC x86_64) 
COLLECT_GCC_OPTIONS='-o' 'simple-hello-c-one.c.h' '-g' '-v' '-v' '-E' '-mmacosx-version-min=14.0.0' '-asm_macosx_version_min=14.0' '-nodefaultexport' '-mtune=core2'
 /Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../libexec/gcc/x86_64-apple-darwin18.7.0/14.1.0/cc1 -E -quiet -v -v -iprefix /Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/ -D__DYNAMIC__ simple-hello.c -o simple-hello-c-one.c.h -fPIC -feliminate-unused-debug-symbols -mmacosx-version-min=14.0.0 -mtune=core2 -g -fworking-directory -dumpbase simple-hello-c-one.c.c -dumpbase-ext .c
ignoring nonexistent directory "/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/../../../../x86_64-apple-darwin18.7.0/include"
ignoring duplicate directory "/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../lib/gcc/../../lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring duplicate directory "/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../lib/gcc/../../lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed"
ignoring nonexistent directory "/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../lib/gcc/../../lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/../../../../x86_64-apple-darwin18.7.0/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include
 /Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/bin/../lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks
End of search list.
In file included from simple-hello.c:10:
/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:374:153: error: macro "__API_AVAILABLE6" requires 6 arguments, but only 4 given
  374 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
      |                                                                                                                                                         ^
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h:177,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:69,
                 from /Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:78:
/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/AvailabilityInternal.h:52046:13: note: macro "__API_AVAILABLE6" defined here
52046 |     #define __API_AVAILABLE6(x,y,z,t,b,m) __API_A(x) __API_A(y) __API_A(z) __API_A(t) __API_A(b) __API_A(m)
      |             ^~~~~~~~~~~~~~~~
/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:375:119: error: macro "__API_AVAILABLE6" requires 6 arguments, but only 4 given
  375 | FILE *open_memstream(char **__bufp, size_t *__sizep) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
      |                                                                                                                       ^
/Users/ilg/Work/xpack-dev-tools-build/gcc-14.1.0-1/darwin-x64/x86_64-apple-darwin23.3.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/AvailabilityInternal.h:52046:13: note: macro "__API_AVAILABLE6" defined here
52046 |     #define __API_AVAILABLE6(x,y,z,t,b,m) __API_A(x) __API_A(y) __API_A(z) __API_A(t) __API_A(b) __API_A(m)
      |             ^~~~~~~~~~~~~~~~
[test_case_trap_handler simple-hello-c-one 1 407 3]

FAIL: simple-hello-c-one

If I understand this right, the fixed stdio.h invokes the __API_AVAILABLE macro with 4 arguments, and, after a sequence of headers, the call ends somehow in a more recent header which expects 6 arguments.

To make things worse, the same binaries are no longer functional even on a macOS 10.13 but having a different SDK (xcode10.1), for example the one available on Travis CI:

In file included from simple-hello.c:10:

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:374:153: error: macro "__API_AVAILABLE3" passed 4 arguments, but takes just 3

  374 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));

      |                                                                                                                                                         ^

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h:206,

                 from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:69,

                 from /Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:78:

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/AvailabilityInternal.h:52043:13: note: macro "__API_AVAILABLE3" defined here

52043 |     #define __API_AVAILABLE3(x,y,z)  __API_A(x) __API_A(y) __API_A(z)

      |             ^~~~~~~~~~~~~~~~

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h: In function 'fmemopen':

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:374:88: error: expected declaration specifiers before '__API_AVAILABLE3'

  374 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));

      |                                                                                        ^~~~~~~~~~~~~~~

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:375:119: error: macro "__API_AVAILABLE3" passed 4 arguments, but takes just 3

  375 | FILE *open_memstream(char **__bufp, size_t *__sizep) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));

      |                                                                                                                       ^

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/AvailabilityInternal.h:52043:13: note: macro "__API_AVAILABLE3" defined here

52043 |     #define __API_AVAILABLE3(x,y,z)  __API_A(x) __API_A(y) __API_A(z)

      |             ^~~~~~~~~~~~~~~~

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:375:54: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__API_AVAILABLE3'

  375 | FILE *open_memstream(char **__bufp, size_t *__sizep) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));

      |                                                      ^~~~~~~~~~~~~~~

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:385:20: error: storage class specified for parameter 'sys_nerr'

  385 | extern __const int sys_nerr;            /* perror(3) external variables */

      |                    ^~~~~~~~

/Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:386:30: error: storage class specified for parameter 'sys_errlist'

  386 | extern __const char *__const sys_errlist[];

      |                              ^~~~~~~~~~~

In file included from /Users/travis/build/xpack-dev-tools/gcc-xpack/build/darwin-x64/x86_64-apple-darwin17.7.0/tests/xpack-gcc-14.1.0-1/lib/gcc/x86_64-apple-darwin18.7.0/14.1.0/include-fixed/stdio.h:425:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:42:12: error: storage class specified for parameter '__sprintf_chk'

   42 | extern int __sprintf_chk (char * __restrict, int, size_t,

      |            ^~~~~~~~~~~~~

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:52:12: error: storage class specified for parameter '__snprintf_chk'
...

Here the system header expects 3 arguments, and receives 4, plus other errors.

Did I misconfigured my build or is this a compatibility issue with older systems, that was introduced with the recent changes in 14.x?

For the xPack distribution this issue is a show stopper; all other binaries (Windows, Linux Intel, Linux aarch64, Linux arm, macOS arm64) are functional, only the macOS Intel, which is expected to run on everything from macOS 10.13 up, is failing.

Any suggestions?

@iains
Copy link
Owner

iains commented May 30, 2024

does the patch I pushed onto the 14.1 branch fix this?
75ff8c3

edit: The availability handling was on trunk and also on the pre-releases - so there was a chance to catch this before we shipped .. but such is life ...

@ilg-ul
Copy link
Author

ilg-ul commented May 30, 2024

The current Homebrew patch for 14.1 is https://raw.githubusercontent.com/Homebrew/formula-patches/82b5c1cd38826ab67ac7fc498a8fe74376a40f4a/gcc/gcc-14.1.0.diff.

I tried some quick searches and apparently your patch was not included.

If so, @fxcoudert, can you update the Homebrew patch to include it?

@iains
Copy link
Owner

iains commented May 31, 2024

The current Homebrew patch for 14.1 is https://raw.githubusercontent.com/Homebrew/formula-patches/82b5c1cd38826ab67ac7fc498a8fe74376a40f4a/gcc/gcc-14.1.0.diff.

I tried some quick searches and apparently your patch was not included.

If so, @fxcoudert, can you update the Homebrew patch to include it?

it would be a good idea to check that it fixes your issue first, perhaps?

@ilg-ul
Copy link
Author

ilg-ul commented May 31, 2024

You mean to append a patch based on 75ff8c3 to the large homebrew patch?

I'll try to do this today and report the result.

@iains
Copy link
Owner

iains commented May 31, 2024

You mean to append a patch based on 75ff8c3 to the large homebrew patch?

I'll try to do this today and report the result.

yes, that would be great; thanks!

@ilg-ul
Copy link
Author

ilg-ul commented May 31, 2024

The new macOS Intel binaries built on 10.14 with TARGET 10.13 passed all tests on:

  • my 10.14 and 14.3
  • GitHub 12.7
  • Travis 10.13, 10.15, 11.6, 12.6

The macOS arm64 binaries built on 11.7 with TARGET 11.0 also passed the tests on GitHub 14.5.

From my point of view I would say that the problem was fixed.

Thank you for your quick reply.


When do you plan to add a gcc-14.1-darwin-r1 tag? Should I wait for more commits, or I can proceed with the release with only this single commit added to Homebrew patches?

@iains
Copy link
Owner

iains commented May 31, 2024

this is the only report against the r0 so far - so I am happy to tag an r1.

as for whether homebrew / macports etc. update - I cannot comment (but note: @fxcoudert)

@ilg-ul
Copy link
Author

ilg-ul commented May 31, 2024

so I am happy to tag an r1 ...

ok, please do it, for now I'll assume there will be no further immediate commits and I'll proceed with my 14.1 release.

@ilg-ul ilg-ul closed this as completed May 31, 2024
@ilg-ul
Copy link
Author

ilg-ul commented May 31, 2024

I think I was a bit too hasty, the arm64 tests were not performed on the GitHub 14.5, but on my own 11.7, and thus passed.

When I tried on GitHub 14.5, some of the tests failed; I'll open a separate issue with the findings.

But this issue related to the availability macros seems fixed.

@ilg-ul
Copy link
Author

ilg-ul commented Jun 1, 2024

I'm in the middle of releasing 13.3, using the official archive and the Homebrew patch, I encountered the following error while running the binaries generated for 10.13 on a more recent macOS:

In file included from simple-hello.c:10:
/Users/runner/work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin21.6.0/tests/xpack-gcc-13.3.0-1/lib/gcc/x86_64-apple-darwin18.7.0/13.3.0/include-fixed/stdio.h:374:153: error: macro "__API_AVAILABLE6" requires 6 arguments, but only 4 given
  374 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
      |                                                                                                                                                         ^
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h:166,
                 from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:69,
                 from /Users/runner/work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin21.6.0/tests/xpack-gcc-13.3.0-1/lib/gcc/x86_64-apple-darwin18.7.0/13.3.0/include-fixed/stdio.h:78:
/Users/runner/work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin21.6.0/tests/xpack-gcc-13.3.0-1/lib/gcc/x86_64-apple-darwin18.7.0/13.3.0/include-fixed/AvailabilityInternal.h:52046: note: macro "__API_AVAILABLE6" defined here
52046 |     #define __API_AVAILABLE6(x,y,z,t,b,m) __API_A(x) __API_A(y) __API_A(z) __API_A(t) __API_A(b) __API_A(m)
      | 
/Users/runner/work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin21.6.0/tests/xpack-gcc-13.3.0-1/lib/gcc/x86_64-apple-darwin18.7.0/13.3.0/include-fixed/stdio.h: In function 'fmemopen':
/Users/runner/work/gcc-xpack/gcc-xpack/build/darwin-x64/x86_64-apple-darwin21.6.0/tests/xpack-gcc-13.3.0-1/lib/gcc/x86_64-apple-darwin18.7.0/13.3.0/include-fixed/stdio.h:374:88: error: expected declaration specifiers before '__API_AVAILABLE6'
  374 | FILE *fmemopen(void * __restrict __buf, size_t __size, const char * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
      |                                                                                        ^~~~~~~~~~~~~~~

A similar error occurs while testing the arm64 binaries.

Is it possible to back-port the fix to the 13 branch?

@ilg-ul ilg-ul reopened this Jun 1, 2024
@fxcoudert
Copy link
Contributor

The problem is, in my opinion, more general. The "hacking" of headers through GCC's fixincludes is fragile: it means that, for some a limited number of headers, we read the local (patched) copy generated during gcc build instead of read the system one.

The logical consequence is: if you run against a different SDK than you compiled for, you introduce a mismatch of headers. And we won't be able to guarantee that it works for most cases.

The long-term solution is: making GCC able to parse SDK headers better, and Iain has done great work on that.

@ilg-ul
Copy link
Author

ilg-ul commented Jun 1, 2024

The long-term solution is: making GCC able to parse SDK headers better, and Iain has done great work on that.

Fully agree, Iain has done a great work, and, on long term, if a more robust solution can be implemented, it is welcome.

On short term, according to my tests, the solution used in the 14 branch seems functional. It would be great to be able to back-port it to the 13 branch too.

@iains
Copy link
Owner

iains commented Jun 1, 2024

Is it possible to back-port the fix to the 13 branch?

Yes, I'm testing the back port.

as @fxcoudert says, the long-term solution is to be able to consume the SDKs without changes - or, equivalently, to provide our own SDK.

Neither of these is very easy:

  • the first means modifying GCC to behave in the same way as clang (where the SDKs exploit clang extensions - or even sometimes mistakes)
  • the second means a huge community effort in replicating the Framework headers for the closed-source components [we'd have to "white room" the solution based on the published on-line APIs for example].

We're making some progress on the first, GCC-14 has two huge steps (handing __has_extension/feature and the availability attribute)... but some things remain and some are quite hard.

@ilg-ul
Copy link
Author

ilg-ul commented Jun 3, 2024

Yes, I'm testing the back port.

Any progress on this?

@iains
Copy link
Owner

iains commented Jun 3, 2024

Yes, I'm testing the back port.

Any progress on this?

most of the runs are complete - hopefully the remainder will complete tonight.

@ilg-ul
Copy link
Author

ilg-ul commented Jun 4, 2024

As discussed in iains/gcc-13-branch#1, the issue was caused by a misunderstanding, the HB patch is not identical to tagged commits here, and the commit fixing the availability macros was not included in HB 13.3.

@ilg-ul ilg-ul closed this as completed Jun 4, 2024
iains pushed a commit that referenced this issue Jul 21, 2024
Here during overload resolution we have two strictly viable ambiguous
candidates #1 and #2, and two non-strictly viable candidates #3 and #4
which we hold on to ever since r14-6522.  These latter candidates have
an empty second arg conversion since the first arg conversion was deemed
bad, and this trips up joust when called on #3 and #4 which assumes all
arg conversions are there.

We can fix this by making joust robust to empty arg conversions, but in
this situation we shouldn't need to compare #3 and #4 at all given that
we have a strictly viable candidate.  To that end, this patch makes
tourney shortcut considering non-strictly viable candidates upon
encountering ambiguity between two strictly viable candidates (taking
advantage of the fact that the candidates list is sorted according to
viability via splice_viable).

	PR c++/115239

gcc/cp/ChangeLog:

	* call.cc (tourney): Don't consider a non-strictly viable
	candidate as the champ if there was ambiguity between two
	strictly viable candidates.

gcc/testsuite/ChangeLog:

	* g++.dg/overload/error7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 7fed7e9bbc57d502e141e079a6be2706bdbd4560)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants