Skip to content

ios: Debug builds fail to link — core archive references UBSan runtime the host link never provides #429

Description

@donpark

With the archive-alignment failure worked around (sibling issue), native dev --target ios in Debug still fails at the same clang link: the scriptc runtime objects inside the Debug core archive reference ___ubsan_handle_*, but the toolkit's host link command provides no sanitizer runtime. ReleaseFast builds are unaffected (no UBSan references), which is presumably why the dev loop was never exercised against this.

Repro

Same as the sibling issue: any app, native dev --target ios, after working around the archive alignment. The link then fails with ~13 undefined-symbol families, e.g.:

Undefined symbols for architecture arm64:
  "___ubsan_handle_add_overflow", referenced from:
      _scr_bytes_from_str in libIdfon.a[8](scr_bytes.o)
  "___ubsan_handle_type_mismatch_v1", referenced from:
      _scr_arr_new in libIdfon.a[6](scr_array.o)
  ... (shift_out_of_bounds, mul/sub/negate_overflow, out_of_bounds,
       pointer_overflow, load_invalid_value, builtin_unreachable, ...)

Control

native build for the same app in ReleaseFast links fine — the UBSan references are Debug-only.

Workaround (verified)

Link the simulator ubsan runtime into the app and bundle it:

UB=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/21/lib/darwin/libclang_rt.ubsan_iossim_dynamic.dylib
xcrun lipo -thin arm64 "$UB" -output "$APP/libclang_rt.ubsan_iossim_dynamic.dylib"
# add to the host clang command:
#   $APP/libclang_rt.ubsan_iossim_dynamic.dylib -rpath @executable_path
# then codesign both the dylib and the .app

Environment

  • native 0.10.1 (064ca98), CLI reports native 0.10.1 (commit 064ca98, automation protocol 0x51f7889bbe3305e7)
  • macOS 26.6.2 (arm64), Xcode 26.6
  • Zig 0.16.0, Node v24.20.0

Notes

Suggested fixes, either works:

  • (a) link the ubsan runtime for Debug builds (the bundle assembly is already in ios.zig, so embedding the dylib + -rpath @executable_path fits the existing flow), or
  • (b) compile the scriptc runtime objects without sanitizers so Debug archives carry no UBSan references — simpler, removes the dylib dependency entirely.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions