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

Can't build with ios sdk version with tbd v3 #11896

Closed
maxxnino opened this issue Jun 20, 2022 · 1 comment · Fixed by #16553
Closed

Can't build with ios sdk version with tbd v3 #11896

maxxnino opened this issue Jun 20, 2022 · 1 comment · Fixed by #16553
Labels
bug Observed behavior contradicts documented or intended behavior os-ios iPhoneOS
Milestone

Comments

@maxxnino
Copy link

Zig Version

0.10.0-dev.2624+d506275a0

Steps to Reproduce

  • Download and use theos/sdks for ios dev
  • run zig init-exe
  • build.zig
const std = @import("std");
const ios14 = "iPhoneOS14.5.sdk";
const ios13 = "iPhoneOS13.7.sdk";
const ios12 = "iPhoneOS12.4.sdk";
pub fn build(b: *std.build.Builder) void {
    const target = b.standardTargetOptions(.{});
    const mode = b.standardReleaseOptions();

    const exe = b.addExecutable("Repo", "src/main.zig");
    exe.setTarget(target);
    exe.setBuildMode(mode);
    exe.install();

    exe.addFrameworkDir("D:/wsl/sdks/" ++ ios12 ++ "/System/Library/Frameworks");
    exe.addLibPath("D:/wsl/sdks/" ++ ios12 ++ "/usr/lib");
    exe.linkFramework("Foundation");

    const run_cmd = exe.run();
    run_cmd.step.dependOn(b.getInstallStep());
    if (b.args) |args| {
        run_cmd.addArgs(args);
    }

    const run_step = b.step("run", "Run the app");
    run_step.dependOn(&run_cmd.step);

    const exe_tests = b.addTest("src/main.zig");
    exe_tests.setTarget(target);
    exe_tests.setBuildMode(mode);

    const test_step = b.step("test", "Run unit tests");
    test_step.dependOn(&exe_tests.step);
}

run zig build -Dtarget=aarch64-ios --sysroot "D:\wsl\sdks\iPhoneOS12.4.sdk\"build with tbd v3 sdk. Get error.
run zig build -Dtarget=aarch64-ios --sysroot "D:\wsl\sdks\iPhoneOS14.5.sdk\"build with tbd v4 sdk. Build ok.

Expected Behavior

working as tbd v4 sdk

Actual Behavior

with old sdk got error

LLVM Emit Object... error(link): undefined reference to symbol 'dyld_stub_binder'
error: UndefinedSymbolReference
Repo...The following command exited with error code 1:
C:\Users\user\scoop\apps\zig-dev\current\zig.exe build-exe D:\Repo\applepie\src\main.zig --cache-dir D:\Repo\applepie\zig-cache --global-cache-dir C:\Users\user\AppData\Local\zig --name Repo -target aarch64-io
s -mcpu generic --pkg-begin apple D:\Repo\applepie\libs\apple_pie\src\apple_pie.zig --pkg-end --pkg-begin kit D:\Repo\applepie\libs\ZigKit\src\main.zig --pkg-end -L D:/wsl/sdks/iPhoneOS12.4.sdk/usr/lib -iframe
workwithsysroot D:/wsl/sdks/iPhoneOS12.4.sdk/System/Library/Frameworks -F D:/wsl/sdks/iPhoneOS12.4.sdk/System/Library/Frameworks -framework Foundation -framework UIKit --sysroot D:\wsl\sdks\iPhoneOS12.4.sdk\ -
-enable-cache
error: the following build command failed with exit code 1:
D:\Repo\applepie\zig-cache\o\5b0617b5fd679c2c937808f73236d6da\build.exe C:\Users\user\scoop\apps\zig-dev\current\zig.exe D:\Repo\applepie D:\Repo\applepie\zig-cache C:\Users\user\AppData\Local\zig -Dtarget=aar
ch64-ios --sysroot D:\wsl\sdks\iPhoneOS12.4.sdk\

@maxxnino maxxnino added the bug Observed behavior contradicts documented or intended behavior label Jun 20, 2022
@andrewrk andrewrk added the os-ios iPhoneOS label Jun 28, 2022
@andrewrk andrewrk added this to the 0.11.0 milestone Jun 28, 2022
@wbadart
Copy link

wbadart commented Apr 14, 2023

Found this issue after seeing a similar error message from zig cc on Mac.

mkdir wd && cd wd && cat <<EOF > foo.c && zig cc ./foo.c
#include <stdio.h>

int main(void) {
  printf("hi\n");
  return 0;
}
EOF

gives

MachO Flush... error(link): undefined reference to symbol 'dyld_stub_binder'
error: UndefinedSymbolReference

with

$ zig version
0.10.1

$ zig cc --version
Homebrew clang version 15.0.7
Target: x86_64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /usr/bin

Using the latest binary from the downloads page fixed my very simple case:

$ ~/Downloads/zig-macos-x86_64-0.11.0-dev.2563+35f9c8444/zig cc ./foo.c && ./a.out
hi

Not sure if the same applies to the error with the iOS SDK, but it could be worth checking if this was (inadvertently?) solved with some recent 0.11.x work! (Maybe the upgrade to clang 16?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-ios iPhoneOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants