Skip to content

Regression in linker, cross compiling for macos #17130

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

Closed
menduz opened this issue Sep 12, 2023 · 20 comments · Fixed by #18677
Closed

Regression in linker, cross compiling for macos #17130

menduz opened this issue Sep 12, 2023 · 20 comments · Fixed by #18677
Assignees
Labels
bug Observed behavior contradicts documented or intended behavior linking os-macos
Milestone

Comments

@menduz
Copy link

menduz commented Sep 12, 2023

Zig Version

0.12.0-dev.293+f33bb0228

Steps to Reproduce and Observed Behavior

https://github.com/menduz/mach-glfw/actions/runs/6164914009 <- reproduction using github actions

I'd usually dig deeper and bisect the non working versions, but I'm having trouble finding the list of releases. Instead I have two big numbers known to work and not work 0.12.0-dev.21+ac95cfe44 (works) and 0.12.0-dev.293+f33bb0228 (no works).

I'm not an expert in the compiler/linker code, but I smell that the problem may be related to this PR, #17030. That's why I'm tagging you @kubkon.

The error is the following:

node ➜ /workspaces/mach-glfw (main) $ zig version                                              
0.12.0-dev.293+f33bb0228
node ➜ /workspaces/mach-glfw (main) $ zig build -Dtarget=aarch64-macos --verbose-link --verbose
/usr/local/lib/zig/zig build-lib /home/node/.cache/zig/p/1220a8b642edf8ef522e468cfe9a1803507472461b1041be717294ca484d1361afb0/stub.c --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name vulkan-headers -static -target aarch64-macos -mcpu generic --listen=- 
/usr/local/lib/zig/zig build-lib /home/node/.cache/zig/p/12205bd95b9cc9cb08dd6b55f5842d8fae67a12eed01092c54f021060931815f711e/stub.c -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name x11-headers -static -target aarch64-macos -mcpu generic --listen=- 
/usr/local/lib/zig/zig build-lib /home/node/.cache/zig/p/12202cf6230788d948e5ee2afa26d4f6cc4994ae1bf0c1c832535b920717a1174223/stub.c --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name wayland-headers -static -target aarch64-macos -mcpu generic --listen=- 
/usr/local/lib/zig/zig build-lib -lobjc -cflags -D_GLFW_COCOA -Isrc -- /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/context.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/egl_context.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/init.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/input.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/monitor.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_init.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_joystick.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_monitor.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_window.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/osmesa_context.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/platform.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/vulkan.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/window.c -cflags -D_GLFW_COCOA -Isrc -- /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_time.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/posix_module.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/posix_thread.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_init.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_joystick.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_monitor.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_window.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/nsgl_context.m -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name glfw -static -target aarch64-macos -mcpu generic -I /workspaces/mach-glfw/zig-cache/i/dcf9574a0199c4a2d9a16e9a3e27c447/include -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include -D __kernel_ptr_semantics= -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=- 
/usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/e0c0d01eab963d7746ec0821e4966b81/libglfw.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/5fd3803e75d7ce137630d9994e8b5d98/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/a3cbd3950fdd54726e733cbce5011c1c/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include -I /workspaces/mach-glfw/zig-cache/i/dcf9574a0199c4a2d9a16e9a3e27c447/include -I /workspaces/mach-glfw/zig-cache/i/9f02276e6a0279a1ecb23bd7df2665e2/include -I /workspaces/mach-glfw/zig-cache/i/07ee617160c3200c7fa40bc5eeeb7f49/include -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=- 
zig build-exe example Debug aarch64-macos: error: zig ld -dynamic /workspaces/mach-glfw/zig-cache/o/e0c0d01eab963d7746ec0821e4966b81/libglfw.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/5fd3803e75d7ce137630d9994e8b5d98/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/a3cbd3950fdd54726e733cbce5011c1c/libwayland-headers.a /workspaces/mach-glfw/zig-cache/o/dd19ba2a0fe3ff70d7860fa1ebca28a8/example.o /home/node/.cache/zig/o/80841b5613787bda027441fe38419d0a/libcompiler_rt.a -o /workspaces/mach-glfw/zig-cache/o/dd19ba2a0fe3ff70d7860fa1ebca28a8/example -lSystem -lc -lobjc -L/home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation -F/home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks

zig build-exe example Debug aarch64-macos: error: the following command failed with 2 compilation errors:
/usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/e0c0d01eab963d7746ec0821e4966b81/libglfw.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/5fd3803e75d7ce137630d9994e8b5d98/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/a3cbd3950fdd54726e733cbce5011c1c/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include -I /workspaces/mach-glfw/zig-cache/i/dcf9574a0199c4a2d9a16e9a3e27c447/include -I /workspaces/mach-glfw/zig-cache/i/9f02276e6a0279a1ecb23bd7df2665e2/include -I /workspaces/mach-glfw/zig-cache/i/07ee617160c3200c7fa40bc5eeeb7f49/include -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=- 
Build Summary: 12/15 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install example transitive failure
   └─ zig build-exe example Debug aarch64-macos 2 errors
error: missing dynamic library dependency: '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices'
    note: tried /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices.tbd
    note: tried /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices.dylib
error: missing dynamic library dependency: '/System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork'
    note: tried /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork.tbd
    note: tried /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork.dylib

Here is a working log:

node ➜ /workspaces/mach-glfw (main) $ zig version                                                                      
0.12.0-dev.21+ac95cfe44
node ➜ /workspaces/mach-glfw (main) $ zig build -Dtarget=aarch64-macos --verbose-link --verbose                        
/usr/local/lib/zig/zig build-lib /home/node/.cache/zig/p/1220a8b642edf8ef522e468cfe9a1803507472461b1041be717294ca484d1361afb0/stub.c --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name vulkan-headers -static -target aarch64-macos -mcpu generic --listen=- 
/usr/local/lib/zig/zig build-lib /home/node/.cache/zig/p/12205bd95b9cc9cb08dd6b55f5842d8fae67a12eed01092c54f021060931815f711e/stub.c -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name x11-headers -static -target aarch64-macos -mcpu generic --listen=- 
/usr/local/lib/zig/zig build-lib /home/node/.cache/zig/p/12202cf6230788d948e5ee2afa26d4f6cc4994ae1bf0c1c832535b920717a1174223/stub.c --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name wayland-headers -static -target aarch64-macos -mcpu generic --listen=- 
/usr/local/lib/zig/zig build-lib -lobjc -cflags -D_GLFW_COCOA -Isrc -- /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/context.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/egl_context.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/init.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/input.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/monitor.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_init.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_joystick.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_monitor.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/null_window.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/osmesa_context.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/platform.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/vulkan.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/window.c -cflags -D_GLFW_COCOA -Isrc -- /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_time.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/posix_module.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/posix_thread.c /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_init.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_joystick.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_monitor.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/cocoa_window.m /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/src/nsgl_context.m -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name glfw -static -target aarch64-macos -mcpu generic -I /workspaces/mach-glfw/zig-cache/i/f237565cd8e8d1d9bdd8b82de4ae04ce/include -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include -D __kernel_ptr_semantics= -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib -iframework /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=- 
steps [12/15] zig build-lib glfw Debug aarch64-macos... /usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/639c138bb970d1d8ed2f85992cc244b2/libglfw.a /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/31a83fe8d5b388726093745432f2e756/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/e9e3d3b8e8fffa07062b4354f04babcd/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include -I /workspaces/mach-glfw/zig-cache/i/f237565cd8e8d1d9bdd8b82de4ae04ce/include -I /workspaces/mach-glfw/zig-cache/i/801083cb93794881a77d1764bc388945/include -I /workspaces/mach-glfw/zig-cache/i/45f59e6632d069fa730b125989be9996/include -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib -iframework /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=-

Expected Behavior

The compiler should receive some extra arguments for frameworks.

 # good
 /usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/639c138bb970d1d8ed2f85992cc244b2/libglfw.a /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/31a83fe8d5b388726093745432f2e756/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/e9e3d3b8e8fffa07062b4354f04babcd/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include \
   -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include \
   -I /workspaces/mach-glfw/zig-cache/i/f237565cd8e8d1d9bdd8b82de4ae04ce/include \
   -I /workspaces/mach-glfw/zig-cache/i/801083cb93794881a77d1764bc388945/include \
   -I /workspaces/mach-glfw/zig-cache/i/45f59e6632d069fa730b125989be9996/include \
   -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib \
+  -iframework /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks \
   -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks \
   -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=-

 # not good
 /usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/e0c0d01eab963d7746ec0821e4966b81/libglfw.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/5fd3803e75d7ce137630d9994e8b5d98/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/a3cbd3950fdd54726e733cbce5011c1c/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include \
   -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks \
   -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include \
   -I /workspaces/mach-glfw/zig-cache/i/dcf9574a0199c4a2d9a16e9a3e27c447/include \
   -I /workspaces/mach-glfw/zig-cache/i/9f02276e6a0279a1ecb23bd7df2665e2/include \
   -I /workspaces/mach-glfw/zig-cache/i/07ee617160c3200c7fa40bc5eeeb7f49/include \
   -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib \
   -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=- 
@menduz menduz added the bug Observed behavior contradicts documented or intended behavior label Sep 12, 2023
@menduz
Copy link
Author

menduz commented Sep 12, 2023

@slimsag this may be an outkast event, but also it may be sensible to add some basic cross-build CI to ensure that the automatic PRs aren't merged with regressions, like in the branch used to reproduce the regression. I think right now xcode_frameworks seems fragile enough to justify it

@kubkon
Copy link
Member

kubkon commented Sep 12, 2023

I wonder could this be related to #16818?

@menduz
Copy link
Author

menduz commented Sep 12, 2023

Apparently not entirely. It does include the -iframework now, but it is missing the -F

 # good
 /usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/639c138bb970d1d8ed2f85992cc244b2/libglfw.a /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/31a83fe8d5b388726093745432f2e756/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/e9e3d3b8e8fffa07062b4354f04babcd/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include \
   -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include \
   -I /workspaces/mach-glfw/zig-cache/i/f237565cd8e8d1d9bdd8b82de4ae04ce/include \
   -I /workspaces/mach-glfw/zig-cache/i/801083cb93794881a77d1764bc388945/include \
   -I /workspaces/mach-glfw/zig-cache/i/45f59e6632d069fa730b125989be9996/include \
   -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib \
   -iframework /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks \
+  -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks \
   -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=-

  # using addSystemFrameworkPath
  /usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/e0c0d01eab963d7746ec0821e4966b81/libglfw.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/5fd3803e75d7ce137630d9994e8b5d98/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/a3cbd3950fdd54726e733cbce5011c1c/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include \
   -iframework /home/node/.cache/zig/p/1220bb0bd84dbe379d5ad02c37f3a2af8da5d296f5110bf7ea788d8b6ec0d3d2727d/zig-cache/xcode_frameworks/Frameworks \
   -isystem /home/node/.cache/zig/p/1220bb0bd84dbe379d5ad02c37f3a2af8da5d296f5110bf7ea788d8b6ec0d3d2727d/zig-cache/xcode_frameworks/include \
   -I /workspaces/mach-glfw/zig-cache/i/dcf9574a0199c4a2d9a16e9a3e27c447/include \
   -I /workspaces/mach-glfw/zig-cache/i/9f02276e6a0279a1ecb23bd7df2665e2/include \
   -I /workspaces/mach-glfw/zig-cache/i/07ee617160c3200c7fa40bc5eeeb7f49/include \
   -L /home/node/.cache/zig/p/1220bb0bd84dbe379d5ad02c37f3a2af8da5d296f5110bf7ea788d8b6ec0d3d2727d/zig-cache/xcode_frameworks/lib \
   -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=-
zig build-exe example Debug aarch64-macos: error: the following command failed with 2 compilation errors:
/usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/e0c0d01eab963d7746ec0821e4966b81/libglfw.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/5fd3803e75d7ce137630d9994e8b5d98/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/a3cbd3950fdd54726e733cbce5011c1c/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include -iframework /home/node/.cache/zig/p/1220bb0bd84dbe379d5ad02c37f3a2af8da5d296f5110bf7ea788d8b6ec0d3d2727d/zig-cache/xcode_frameworks/Frameworks -isystem /home/node/.cache/zig/p/1220bb0bd84dbe379d5ad02c37f3a2af8da5d296f5110bf7ea788d8b6ec0d3d2727d/zig-cache/xcode_frameworks/include -I /workspaces/mach-glfw/zig-cache/i/dcf9574a0199c4a2d9a16e9a3e27c447/include -I /workspaces/mach-glfw/zig-cache/i/9f02276e6a0279a1ecb23bd7df2665e2/include -I /workspaces/mach-glfw/zig-cache/i/07ee617160c3200c7fa40bc5eeeb7f49/include -L /home/node/.cache/zig/p/1220bb0bd84dbe379d5ad02c37f3a2af8da5d296f5110bf7ea788d8b6ec0d3d2727d/zig-cache/xcode_frameworks/lib -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=- 
Build Summary: 12/15 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install example transitive failure
   └─ zig build-exe example Debug aarch64-macos 2 errors
error: missing dynamic library dependency: '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices'
    note: tried /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices.tbd
    note: tried /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices.dylib
error: missing dynamic library dependency: '/System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork'
    note: tried /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork.tbd
    note: tried /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork.dylib

menduz/mach-glfw@5250c09
menduz/xcode-frameworks-pkg@e319834

@kubkon
Copy link
Member

kubkon commented Sep 12, 2023

Hmm, that should not have the impact on the linker as -iframework and -F are routed to the linker as framework dirs regardless. BTW, you now have to prepend the sysroot manually to each framework search path in build.zig, like demonstrated here https://github.com/kubkon/zig-ios-example/blob/main/build.zig

@menduz
Copy link
Author

menduz commented Sep 12, 2023

The arguments for the build-exe were missleading, on a second test using both addSystemFrameworkPath + addFrameworkPath, the arguments are the same but the build is still not passing.

 # good
 /usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/639c138bb970d1d8ed2f85992cc244b2/libglfw.a /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/ffff0e5b8ab378129a9ec35b4c56c825/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/31a83fe8d5b388726093745432f2e756/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/e9e3d3b8e8fffa07062b4354f04babcd/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include \
   -isystem /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/include \
   -I /workspaces/mach-glfw/zig-cache/i/f237565cd8e8d1d9bdd8b82de4ae04ce/include \
   -I /workspaces/mach-glfw/zig-cache/i/801083cb93794881a77d1764bc388945/include \
   -I /workspaces/mach-glfw/zig-cache/i/45f59e6632d069fa730b125989be9996/include \
   -L /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/lib \
   -iframework /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks \
   -F /home/node/.cache/zig/p/1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb/zig-cache/xcode_frameworks/Frameworks \
   -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=-

  # using addSystemFrameworkPath + addFrameworkPath (still failing)
  /usr/local/lib/zig/zig build-exe /workspaces/mach-glfw/example/main.zig /workspaces/mach-glfw/zig-cache/o/e0c0d01eab963d7746ec0821e4966b81/libglfw.a /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a -lobjc /workspaces/mach-glfw/zig-cache/o/624869063b9487aa0656fffb16ad422b/libvulkan-headers.a /workspaces/mach-glfw/zig-cache/o/5fd3803e75d7ce137630d9994e8b5d98/libx11-headers.a /workspaces/mach-glfw/zig-cache/o/a3cbd3950fdd54726e733cbce5011c1c/libwayland-headers.a -lc --verbose-link --cache-dir /workspaces/mach-glfw/zig-cache --global-cache-dir /home/node/.cache/zig --name example -target aarch64-macos -mcpu generic --mod glfw::/workspaces/mach-glfw/src/main.zig --deps glfw -I /home/node/.cache/zig/p/1220fe0763e9722d56d3f93f8740e077fccf338d9697f08239d79a1ee27ae5833e62/include \
   -iframework /home/node/.cache/zig/p/122004c7fbdd891eda2a8b46ade4cb5d0f5ca07a95319f89bebdd800c835a159b67e/zig-cache/xcode_frameworks/Frameworks \
   -F /home/node/.cache/zig/p/122004c7fbdd891eda2a8b46ade4cb5d0f5ca07a95319f89bebdd800c835a159b67e/zig-cache/xcode_frameworks/Frameworks \
   -isystem /home/node/.cache/zig/p/122004c7fbdd891eda2a8b46ade4cb5d0f5ca07a95319f89bebdd800c835a159b67e/zig-cache/xcode_frameworks/include \
   -I /workspaces/mach-glfw/zig-cache/i/dcf9574a0199c4a2d9a16e9a3e27c447/include \
   -I /workspaces/mach-glfw/zig-cache/i/9f02276e6a0279a1ecb23bd7df2665e2/include \
   -I /workspaces/mach-glfw/zig-cache/i/07ee617160c3200c7fa40bc5eeeb7f49/include \
   -L /home/node/.cache/zig/p/122004c7fbdd891eda2a8b46ade4cb5d0f5ca07a95319f89bebdd800c835a159b67e/zig-cache/xcode_frameworks/lib \
   -framework CoreFoundation -framework AppKit -framework CoreServices -framework Metal -framework CoreGraphics -framework IOKit -framework Foundation --listen=- 

@menduz
Copy link
Author

menduz commented Sep 12, 2023

Hmm, that should not have the impact on the linker as -iframework and -F are routed to the linker as framework dirs regardless. BTW, you now have to prepend the sysroot manually to each framework search path in build.zig, like demonstrated here https://github.com/kubkon/zig-ios-example/blob/main/build.zig

I'm using absolute paths: https://github.com/menduz/xcode-frameworks-pkg/blob/main/build.zig#L28, I think that doesn't apply in this case

@kubkon
Copy link
Member

kubkon commented Sep 12, 2023

Hmm, I don't see the sysroot set though. It needs to be set for Zig to pass it on to the linker as -syslibroot which is then required to work out the dylib dependencies correctly.

@kubkon
Copy link
Member

kubkon commented Sep 12, 2023

No inconvenience at all. Yes, it is. You should set it to the same value to what you prepend in xSdkPath call.

@menduz
Copy link
Author

menduz commented Sep 12, 2023

Many thanks, I've got it working.

There is one subtlety, it seems that the compiler is assuming the vendor file structure of the SDK, regardless of passing custom paths for addFrameworkPath, include, lib, etc.

So I had to copy the same structure verbatim. Then, properly use the .sysroot and finally the build is now passing.

Again, many, many thanks @kubkon. Without your guidance this would have costed me a day.

CC: @slimsag FYI

@emidoots
Copy link

FYI in Mach we don't use a sysroot; instead we treat frameworks as just frameworks and just add them to the paths: https://github.com/hexops/xcode-frameworks/blob/fb8ce986a98a72cdcbb844bbcfbafeb3133564a2/build.zig#L18-L22

@emidoots
Copy link

@kubkon I realize now we're facing this issue as well:

Can you shed more light on why this behavior changed? I know this worked in 0.12.0-dev.21+ac95cfe44 and stopped working in 0.12.0-dev.389+61b70778b

Specifically, I'd like to understand why a sysroot is necessary - what's the reason these three calls are no longer sufficient?

Also, if I use a sysroot on a macOS host (in hopes users don't need to install Xcode) - does that imply frameworks cannot come from outside the sysroot? e.g. can I use the sysroot on a macOS host, can users still pull in their own custom frameworks - or would they need to fork the xcode-frameworks repository and add their frameworks to the sysroot?

@kubkon
Copy link
Member

kubkon commented Sep 18, 2023

@kubkon I realize now we're facing this issue as well:

Can you shed more light on why this behavior changed? I know this worked in 0.12.0-dev.21+ac95cfe44 and stopped working in 0.12.0-dev.389+61b70778b

Specifically, I'd like to understand why a sysroot is necessary - what's the reason these three calls are no longer sufficient?

Also, if I use a sysroot on a macOS host (in hopes users don't need to install Xcode) - does that imply frameworks cannot come from outside the sysroot? e.g. can I use the sysroot on a macOS host, can users still pull in their own custom frameworks - or would they need to fork the xcode-frameworks repository and add their frameworks to the sysroot?

With two-level namespace, dylibs are allowed to re-export other dylibs by their install name. The linker then when resolving them tries that verbatim path followed by -syslibroot plus that path. Sounds like we had a bug till now which would not flag up an unresolved dynamic dependency unresolved.

I believe there are three ways we could address this:

  • have the linker search for dependencies in all specified search and framework paths
  • implement extracting the sysroots paths from the specified search and framework paths in the linker - I guess this is ultimately the same as the above just differently worded
  • implement -flat_namespace and recommend that for cross-compilation - then the user is obliged to list all dylibs including dependencies explicitly on the linker line - the main downside of this is the runtime loading penalty of not using two-level namespace

Let me know what you think @slimsag and in the meantime I am re-opening the issue.

@kubkon kubkon reopened this Sep 18, 2023
@kubkon kubkon added this to the 0.11.1 milestone Sep 18, 2023
@kubkon kubkon self-assigned this Sep 18, 2023
@emidoots
Copy link

From my POV options 1/2 make sense, and it sounds like 3 has a runtime penalty which would be nice to avoid.

As I understand it, that means the linker would try:

  • /usr/lib/libobjc.A.* (already tried today)
  • $(-isysroot)/usr/lib/libobjc.A.* (already tried today)
  • $(addLibraryPath)libobjc.A.* (not tried today)

I've made a 'guess' here that you are also talking about addLibraryPath and libraries like /usr/lib/libobjc.a.dylib, not just strictly frameworks / addFrameworkPath - otherwise we'd face this same issue with those next I would guess

...anywho, as long as there is a way for me to ship xcode frameworks to mac users, in the direction of 'you don't have to install ~2.5G of Xcode)', but some way to still allow them to pull in their own frameworks/libraries from outside that set I ship, then that seems perfect/ideal from my POV.

@menduz
Copy link
Author

menduz commented Sep 18, 2023

@slimsag I think I've got to a good solution. It uses the b.sysroot property to cross compile to mac targets from linux.

First, the zig compiler makes some assumptions about the structure of the sysroot directory. I called that "vendor file structure" here. Silent PR here it is just renames.

We are still using the same three lines, but with a different file structure to enable the compiler to look for the objects to link. This may be a bug in the library resolver, but I don't think so.

menduz/xcode-frameworks-pkg@55f954f

+    const sdk = if (b.sysroot) |sysroot| sysroot else xSdkPath("/zig-cache/xcode_frameworks");
+    b.sysroot = sdk;

-    step.addLibraryPath(.{ .path = xSdkPath("/zig-cache/xcode_frameworks/lib") });
+    step.addSystemFrameworkPath(.{ .path = b.pathJoin(&.{ b.sysroot.?, "/System/Library/Frameworks" }) });

-    step.addSystemIncludePath(.{ .path = xSdkPath("/zig-cache/xcode_frameworks/include") });
+    step.addSystemIncludePath(.{ .path = b.pathJoin(&.{ b.sysroot.?, "/usr/include" }) });

-    step.addLibraryPath(.{ .path = xSdkPath("/zig-cache/xcode_frameworks/lib") });
+    step.addLibraryPath(.{ .path = b.pathJoin(&.{ b.sysroot.?, "/usr/lib" }) });

That does the trick. Now we can easily cross compile again.

@emidoots
Copy link

Thanks for explaining that @menduz - I think the problem with that approach is that using b.sysroot prevents you (as expected) from linking other frameworks from other places on a macOS host because it's the system root. So on a macOS host, either you require using xcode from the host machine.. or you can't use frameworks from other libraries on the system at the same time as the packaged-up xcode frameworks.

@emidoots
Copy link

Wanted to mention I've added this to Mach's Most important Zig issues tracking issue - since currently all our cross-compilation to macOS targets is broken as a result of this regression, which means most of our CI pipelines are failing since we test that.

emidoots pushed a commit to hexops-graveyard/mach-sysaudio that referenced this issue Oct 18, 2023
Signed-off-by: Stephen Gutekanst <[email protected]>
emidoots pushed a commit to hexops/mach-objc that referenced this issue Oct 18, 2023
Signed-off-by: Stephen Gutekanst <[email protected]>
emidoots pushed a commit to hexops-graveyard/mach-gpu-dawn that referenced this issue Oct 25, 2023
Signed-off-by: Stephen Gutekanst <[email protected]>
@JonathanHope
Copy link

I ran into this as well. Like the others in this thread If I go back to a Zig release from ~August my CI works great, if I move to a newer Zig the MacOS builds break.

@kubkon
Copy link
Member

kubkon commented Jan 25, 2024

FYI my comments regarding -flat_namespace are completely wrong and unrelated - dylibs are allowed to re-export dylibs in both -twolevel_namespace and -flat-namespace. Boy, it just took me rewriting the linker from scratch to realise that. Anyhow, I have a fix incoming so stay tuned!

@kubkon
Copy link
Member

kubkon commented Jan 25, 2024

@slimsag OK, confirmed locally on Linux with the following changes to glfw project:

diff --git a/build.zig b/build.zig
index e63356f3..a936d992 100644
--- a/build.zig
+++ b/build.zig
@@ -82,14 +82,6 @@ pub fn build(b: *std.Build) void {
             });
         },
         .macos => {
-            // Transitive dependencies, explicit linkage of these works around
-            // ziglang/zig#17130
-            lib.linkFramework("CFNetwork");
-            lib.linkFramework("ApplicationServices");
-            lib.linkFramework("ColorSync");
-            lib.linkFramework("CoreText");
-            lib.linkFramework("ImageIO");
-
             // Direct dependencies
             lib.linkSystemLibrary("objc");
             lib.linkFramework("IOKit");

And then, in mach-glfw:

diff --git a/build.zig.zon b/build.zig.zon
index e4908b2..a477e94 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -11,9 +11,6 @@
         "README.md",
     },
     .dependencies = .{
-        .glfw = .{
-            .url = "https://pkg.machengine.org/glfw/7b1a45feeacf876428bfbd924d4aca9a9a158cd9.tar.gz",
-            .hash = "122052f6e113bb8c74fceb80de8e92b6dce5792213ab703be2584bb638ec30f36edf",
-        },
+        .glfw = .{ .path = "../glfw" },
     },
 }

it builds successfully with #18677 applied:

$ uname -a
Linux kurosaki 5.15.85 #1-NixOS SMP Wed Dec 21 16:36:38 UTC 2022 x86_64 GNU/Linux
$ cd mach-glfw
$ zig build install -Dtarget=aarch64-macos
$ file zig-out/bin/glfw-tests
zig-out/bin/glfw-tests: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_REEXPORTED_DYLIBS|PIE|HAS_TLV_DESCRIPTORS>

@emidoots
Copy link

Amazing! You rock!

@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0 Jan 29, 2024
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 linking os-macos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants