ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.94k stars 2.55k forks source link

compiler-rt port does not support Objective-C @available expressions #10227

Closed slimsag closed 2 years ago

slimsag commented 2 years ago

Zig Version

0.9.0-dev.1713+07cc51e04

Steps to Reproduce

(Apologies for not having a minimal reproduction ready, I will update the issue to include one very soon.)

When using Zig to compile any Objective-C code which includes an @available check, as many serious Objective-C codebases do, such as Google's Dawn WebGPU implementation, clang will emit calls to ___isPlatformVersionAtLeast and __isOSVersionAtLeast which, as of Oct 2020, are expected to be provided by compiler-rt: https://reviews.llvm.org/D90367

Zig's compiler-rt port however is not up-to-date with this change (see also #1504) and so it results in undefined references when attempting to cross-compile such code:

error(link): undefined reference to symbol '___isPlatformVersionAtLeast'
error(link):   first referenced in '/Users/slimsag/Desktop/hexops/mach/gpu/zig-cache/o/a4898ce0dd88be1c63f03f62251f9adb/libdawn-native.a(/Users/slimsag/Desktop/hexops/mach/gpu/zig-cache/o/22c50fc6233f5284bfe9a440d8943d61/BackendMTL.o)'
thread 7413503 panic: attempt to unwrap error: UndefinedSymbolReference

Expected Behavior

compiler-rt includes ___isPlatformVersionAtLeast and __isOSVersionAtLeast definitions so Objective-C code using @available OS version checks links successfully.

Actual Behavior

Missing symbols

slimsag commented 2 years ago

I am working on a PR to port this from clang's compiler-rt implementation, with hope of it landing in the next Zig release (but I totally understand if that's not possible!)

andrewrk commented 2 years ago

Slotted for 0.11.0 milestone but if you get a PR up soon I will be sure to review it in time for it to land into 0.9.0.

slimsag commented 2 years ago

Sent #10232