Bug 251989

Summary: Cocoa availability macros are not working for non-WebKit sources on buildbots
Product: WebKit Reporter: Kimmo Kinnunen <kkinnunen>
Component: Tools / TestsAssignee: Kimmo Kinnunen <kkinnunen>
Status: NEW ---    
Severity: Normal CC: ap, jbedard, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   

Description Kimmo Kinnunen 2023-02-09 07:05:28 PST
Cocoa availability macros are not working for non-WebKit sources on buildbots 

After running configure-xcode-for-embedded-development, the Cocoa WebKit OpenSource SDK is left in following state:
- Correct code does not build with the WebKit OpenSource SDK
- Incorrect code builds with the SDK, but does not build on real, unmodified SDK

This is because WebKit erases the availability macros from the SDK.

Consider case:
enum A {
  CommonOption,
  MacOSOption API_UNAVAILABLE(ios)
};

bool correctFunc(A a) {
  switch (a) {
  case CommonOption:
      return true;
#if defined(TARGET_OS_MAC)
  case MacOSOption:
      return false;
#endif
  } 
}

bool incorrectFunc(A a) {
  switch (a) {
  case CommonOption:
      return true;
  case MacOSOption:
      return false;
  } 
}

bool incorrectAndConfusingButCompilingFunc(A a) {
  switch (a) {
  case CommonOption:
      return true;
#if defined(TARGET_OS_MAC)
  case MacOSOption:
      return false;
#endif
  default:
      UNREACHABLE();
      return false;
  } 
}

 - correctFunc does not compile on WebKit SDK. This the bug we want to fix.
 - WebKit code needs to use incorrectFunc. This is the bug we want to fix.
 - incorrectFunc does not compile on unmodified SDK. This is the feature we want to preserve.


This becomes a problem when contributing to ANGLE:
 - If we contribute incorrect code to ANGLE, it doesn't compile for the rest of the world.
 - If we contribute correct code to ANGLE, it doesn't compile for WebKit.
 - Currently we have to use the workaround incorrectAndConfusingButCompilingFunc
Comment 1 Radar WebKit Bug Importer 2023-02-09 07:07:25 PST
<rdar://problem/105221617>
Comment 2 Kimmo Kinnunen 2023-02-09 07:28:05 PST
Pull request: https://github.com/WebKit/WebKit/pull/9869