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

macho: fix logic for parsing dependent dylibs aka re-exports #18677

Merged
merged 5 commits into from
Jan 27, 2024

Conversation

kubkon
Copy link
Member

@kubkon kubkon commented Jan 25, 2024

Fixes #17130

@slimsag @menduz I would appreciate if you double check this indeed fixes your issue. I did verify locally but want to make sure I didn't have to check out a specific version of mach-glfw project or something.

@andrewrk a couple of comments regarding having lib and framework search dirs available in Compilation:

  1. I have added dumping those dirs when --verbose-link is passed which I find invaluable for debugging any path-related linker issues. That said, I would like to discuss this with you if perhaps we could handle this in the frontend if possible; the point here being having the entire linker line invocation available for dumping when required. EDIT: Turns out I forgot that we already do that for ELF linker. Still, my point stands.
  2. I think with these changes landing we will be at a point when we can look at the possibility of having the frontend do the actual path resolution and searching for dylib re-exports - this is non-blocking for this issue but I think it's a good point to have this discussion and figure out what is possible and what isn't.

@kubkon
Copy link
Member Author

kubkon commented Jan 25, 2024

Oh wow, this did not go as planned for some reason. Lemme re-push the actual changes rebased on master...

@Cloudef
Copy link
Contributor

Cloudef commented Jan 30, 2024

Hmm, I still seem to get this when trying to cross-compile glfw:

glfw-aarch64-apple-darwin> zigtool: warning: cc -target aarch64-macos-none -Wl,--undefined-version -fPIC -O2 -U_FORTIFY_SOURCE -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong --param ssp-buffer-size=4 -fwrapv -mmacos-version-min=11.0 -O3 -DNDEBUG -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 3.0.0 -current_version 3.3.0 -o libglfw.3.3.dylib -install_name /build/source/build/src/libglfw.3.dylib CMakeFiles/glfw.dir/context.c.o CMakeFiles/glfw.dir/init.c.o CMakeFiles/glfw.dir/input.c.o CMakeFiles/glfw.dir/monitor.c.o CMakeFiles/glfw.dir/vulkan.c.o CMakeFiles/glfw.dir/window.c.o CMakeFiles/glfw.dir/cocoa_init.m.o CMakeFiles/glfw.dir/cocoa_joystick.m.o CMakeFiles/glfw.dir/cocoa_monitor.m.o CMakeFiles/glfw.dir/cocoa_window.m.o CMakeFiles/glfw.dir/cocoa_time.c.o CMakeFiles/glfw.dir/posix_thread.c.o CMakeFiles/glfw.dir/nsgl_context.m.o CMakeFiles/glfw.dir/egl_context.c.o CMakeFiles/glfw.dir/osmesa_context.c.o -framework Cocoa -framework IOKit -framework CoreFoundation -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -B/nix/store/kxb2c9rrndz4qy3wzg7mnv4cikjigm3n-aarch64-apple-darwin-zig-toolchain-wrapper-git+1b5cbf0+2024-01-30/bin/ -F/nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -frandom-seed=9dsk9mq3ky -iframework /nix/store/sjipssla9p011xw6vl3jfq98kkqbn0gr-apple-framework-Carbon-11.0.0/Library/Frameworks -iframework /nix/store/czwq5zd15bhim7gc3b5da8i26f46fmng-apple-framework-ApplicationServices-11.0.0/Library/Frameworks -iframework /nix/store/1zxyqh87804sq01qfnvi0f36gy7rlman-apple-framework-ColorSync-11.0.0/Library/Frameworks -iframework /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -isystem /nix/store/v3xaz3k7ccbfsfladsddlxxd4jbyws01-libobjc-11.0.0/include -iframework /nix/store/1kk4ayzp4ny1r5sqns1n97m2mxcsppnx-apple-framework-CoreGraphics-11.0.0/Library/Frameworks -iframework /nix/store/dkjd0bki3zgxyhq6vlxmmwrvxvw2nznb-apple-framework-IOKit-11.0.0/Library/Frameworks -iframework /nix/store/1iyhi4x4mi82pnl1gh9r3wgpd06vrkxz-apple-framework-SystemConfiguration-11.0.0/Library/Frameworks -iframework /nix/store/kp0qlyfimkjawa3fmc5d3x2c51apqfgc-apple-framework-Security-11.0.0/Library/Frameworks -isystem /nix/store/pkkjlf85f7y9l95rxwi92hhl98dyb6jl-apple-lib-libDER/include -iframework /nix/store/5d8l3c6m47wry0dn55hm645wx5ymw4lq-apple-framework-CoreServices-11.0.0/Library/Frameworks -iframework /nix/store/avc91zgn7342g09hb1ns2gxhflcrw0zg-apple-framework-CFNetwork-11.0.0/Library/Frameworks -iframework /nix/store/r1avv3h29gf8spx0zkwnlzwlq5p6x8gy-apple-framework-CoreAudio-11.0.0/Library/Frameworks -iframework /nix/store/4ypl7cz85s53qxkyr4hfcnv3g7xspbdh-apple-framework-CoreAudioTypes-11.0.0/Library/Frameworks -iframework /nix/store/ffrrnm7d64vd47z9bjxgp2vc2z6bf1aw-apple-framework-DiskArbitration-11.0.0/Library/Frameworks -iframework /nix/store/lx1hl53ir2dc3amygaxmrr029mdhwlyx-apple-framework-NetFS-11.0.0/Library/Frameworks -iframework /nix/store/glda73in29gpybdzcs8y2lgpfiib3h1p-apple-framework-ServiceManagement-11.0.0/Library/Frameworks -iframework /nix/store/r4isx855x52rzpl2cggxb9s6s7sbazp4-apple-framework-CoreText-11.0.0/Library/Frameworks -iframework /nix/store/hs7gyhnqbnqcaavxa0qzhca1sm06r420-apple-framework-ImageIO-11.0.0/Library/Frameworks -iframework /nix/store/z7173kk74f83lwc8s6va9jjjxriwqfg6-apple-framework-Foundation-11.0.0/Library/Frameworks -iframework /nix/store/nawkd6ih3w6ynqwa4w0k0qy4vdn7n1b5-apple-framework-Combine-11.0.0/Library/Frameworks -iframework /nix/store/x82017cfgj3pnz1s0ff3v4d0g5qcnybr-apple-framework-QuartzCore-11.0.0/Library/Frameworks -iframework /nix/store/i6iwzfak20h3fjc3znsvjc0hcrxyz217-apple-framework-CoreImage-11.0.0/Library/Frameworks -iframework /nix/store/7m76bdq7x3kvqna5a7b2dk2d6bagk7fx-apple-framework-CoreVideo-11.0.0/Library/Frameworks -iframework /nix/store/4vzbswb7pyz8fqdcl8fi55ybd0sknynf-apple-framework-IOSurface-11.0.0/Library/Frameworks -iframework /nix/store/jixrr4plz0fianl6v12p3063pmp244vj-apple-framework-Metal-11.0.0/Library/Frameworks -iframework /nix/store/bfl3dj6q6bhiqhszvgw16ry3jva378wp-apple-framework-OpenGL-11.0.0/Library/Frameworks -iframework /nix/store/bfl3dj6q6bhiqhszvgw16ry3jva378wp-apple-framework-OpenGL-11.0.0/Library/Frameworks -iframework /nix/store/v6gh1ygkmpbgcp6x95fydlphimrwlcjx-apple-framework-OpenCL-11.0.0/Library/Frameworks -iframework /nix/store/cclvvyaj5nqb5b3yvd1da39y9vxcdpwy-apple-framework-Cocoa-11.0.0/Library/Frameworks -iframework /nix/store/sgaz24rcnv3cvb6llvldq4shh7ay9by3-apple-framework-AppKit-11.0.0/Library/Frameworks -iframework /nix/store/ljziy41alj340wcy3kvf2p5b7wx4a5jb-apple-framework-AudioToolbox-11.0.0/Library/Frameworks -iframework /nix/store/7yc31sj8ax14vw6xfsycd1lhm2z845qx-apple-private-framework-AudioToolboxCore-11.0.0/Library/Frameworks -iframework /nix/store/sjipssla9p011xw6vl3jfq98kkqbn0gr-apple-framework-Carbon-11.0.0/Library/Frameworks -iframework /nix/store/y6lmsmw9n073x4ibahn6q194k8s6m298-apple-framework-CoreMIDI-11.0.0/Library/Frameworks -iframework /nix/store/sx5w4fqlz19vq92dnx2c1j865mj4hgl6-apple-framework-AudioUnit-11.0.0/Library/Frameworks -iframework /nix/store/9qjyijnhc90ysvv3mwj7wlbxc8l8cvww-apple-framework-CloudKit-11.0.0/Library/Frameworks -iframework /nix/store/fii65gmbfz5lg85k3j7psj6f0rvacp6g-apple-framework-CoreLocation-11.0.0/Library/Frameworks -iframework /nix/store/y1hq5mqfbzch644mrc08g63zm1x0vkx8-apple-framework-CoreData-11.0.0/Library/Frameworks -iframework /nix/store/32vyzaa6mjp8j8i9vzka02za3b80skq3-apple-private-framework-UIFoundation-11.0.0/Library/Frameworks -iframework /nix/store/rpcdk9rc6wnkljd5658cji6glr360ij8-apple-framework-Kernel-11.0.0/Library/Frameworks -L/nix/store/v3xaz3k7ccbfsfladsddlxxd4jbyws01-libobjc-11.0.0/lib -L/nix/store/p3jshbwxiwifm1py0yq544fmdyy98j8a-glibc-2.38-27/lib
glfw-aarch64-apple-darwin> error: unable to find framework 'Cocoa'. searched paths:
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/Cocoa.framework/Cocoa.tbd
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/Cocoa.framework/Cocoa.dylib
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/Cocoa.framework/Cocoa
glfw-aarch64-apple-darwin> error: unable to find framework 'IOKit'. searched paths:
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/IOKit.framework/IOKit.tbd
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/IOKit.framework/IOKit.dylib
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/IOKit.framework/IOKit

nix build -L github:Cloudef/zig2nix#env.git.src.cross.aarch64-macos-none.glfw

@kubkon
Copy link
Member Author

kubkon commented Jan 30, 2024

Hmm, I still seem to get this when trying to cross-compile glfw:

glfw-aarch64-apple-darwin> zigtool: warning: cc -target aarch64-macos-none -Wl,--undefined-version -fPIC -O2 -U_FORTIFY_SOURCE -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong --param ssp-buffer-size=4 -fwrapv -mmacos-version-min=11.0 -O3 -DNDEBUG -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 3.0.0 -current_version 3.3.0 -o libglfw.3.3.dylib -install_name /build/source/build/src/libglfw.3.dylib CMakeFiles/glfw.dir/context.c.o CMakeFiles/glfw.dir/init.c.o CMakeFiles/glfw.dir/input.c.o CMakeFiles/glfw.dir/monitor.c.o CMakeFiles/glfw.dir/vulkan.c.o CMakeFiles/glfw.dir/window.c.o CMakeFiles/glfw.dir/cocoa_init.m.o CMakeFiles/glfw.dir/cocoa_joystick.m.o CMakeFiles/glfw.dir/cocoa_monitor.m.o CMakeFiles/glfw.dir/cocoa_window.m.o CMakeFiles/glfw.dir/cocoa_time.c.o CMakeFiles/glfw.dir/posix_thread.c.o CMakeFiles/glfw.dir/nsgl_context.m.o CMakeFiles/glfw.dir/egl_context.c.o CMakeFiles/glfw.dir/osmesa_context.c.o -framework Cocoa -framework IOKit -framework CoreFoundation -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -B/nix/store/kxb2c9rrndz4qy3wzg7mnv4cikjigm3n-aarch64-apple-darwin-zig-toolchain-wrapper-git+1b5cbf0+2024-01-30/bin/ -F/nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -frandom-seed=9dsk9mq3ky -iframework /nix/store/sjipssla9p011xw6vl3jfq98kkqbn0gr-apple-framework-Carbon-11.0.0/Library/Frameworks -iframework /nix/store/czwq5zd15bhim7gc3b5da8i26f46fmng-apple-framework-ApplicationServices-11.0.0/Library/Frameworks -iframework /nix/store/1zxyqh87804sq01qfnvi0f36gy7rlman-apple-framework-ColorSync-11.0.0/Library/Frameworks -iframework /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks -isystem /nix/store/v3xaz3k7ccbfsfladsddlxxd4jbyws01-libobjc-11.0.0/include -iframework /nix/store/1kk4ayzp4ny1r5sqns1n97m2mxcsppnx-apple-framework-CoreGraphics-11.0.0/Library/Frameworks -iframework /nix/store/dkjd0bki3zgxyhq6vlxmmwrvxvw2nznb-apple-framework-IOKit-11.0.0/Library/Frameworks -iframework /nix/store/1iyhi4x4mi82pnl1gh9r3wgpd06vrkxz-apple-framework-SystemConfiguration-11.0.0/Library/Frameworks -iframework /nix/store/kp0qlyfimkjawa3fmc5d3x2c51apqfgc-apple-framework-Security-11.0.0/Library/Frameworks -isystem /nix/store/pkkjlf85f7y9l95rxwi92hhl98dyb6jl-apple-lib-libDER/include -iframework /nix/store/5d8l3c6m47wry0dn55hm645wx5ymw4lq-apple-framework-CoreServices-11.0.0/Library/Frameworks -iframework /nix/store/avc91zgn7342g09hb1ns2gxhflcrw0zg-apple-framework-CFNetwork-11.0.0/Library/Frameworks -iframework /nix/store/r1avv3h29gf8spx0zkwnlzwlq5p6x8gy-apple-framework-CoreAudio-11.0.0/Library/Frameworks -iframework /nix/store/4ypl7cz85s53qxkyr4hfcnv3g7xspbdh-apple-framework-CoreAudioTypes-11.0.0/Library/Frameworks -iframework /nix/store/ffrrnm7d64vd47z9bjxgp2vc2z6bf1aw-apple-framework-DiskArbitration-11.0.0/Library/Frameworks -iframework /nix/store/lx1hl53ir2dc3amygaxmrr029mdhwlyx-apple-framework-NetFS-11.0.0/Library/Frameworks -iframework /nix/store/glda73in29gpybdzcs8y2lgpfiib3h1p-apple-framework-ServiceManagement-11.0.0/Library/Frameworks -iframework /nix/store/r4isx855x52rzpl2cggxb9s6s7sbazp4-apple-framework-CoreText-11.0.0/Library/Frameworks -iframework /nix/store/hs7gyhnqbnqcaavxa0qzhca1sm06r420-apple-framework-ImageIO-11.0.0/Library/Frameworks -iframework /nix/store/z7173kk74f83lwc8s6va9jjjxriwqfg6-apple-framework-Foundation-11.0.0/Library/Frameworks -iframework /nix/store/nawkd6ih3w6ynqwa4w0k0qy4vdn7n1b5-apple-framework-Combine-11.0.0/Library/Frameworks -iframework /nix/store/x82017cfgj3pnz1s0ff3v4d0g5qcnybr-apple-framework-QuartzCore-11.0.0/Library/Frameworks -iframework /nix/store/i6iwzfak20h3fjc3znsvjc0hcrxyz217-apple-framework-CoreImage-11.0.0/Library/Frameworks -iframework /nix/store/7m76bdq7x3kvqna5a7b2dk2d6bagk7fx-apple-framework-CoreVideo-11.0.0/Library/Frameworks -iframework /nix/store/4vzbswb7pyz8fqdcl8fi55ybd0sknynf-apple-framework-IOSurface-11.0.0/Library/Frameworks -iframework /nix/store/jixrr4plz0fianl6v12p3063pmp244vj-apple-framework-Metal-11.0.0/Library/Frameworks -iframework /nix/store/bfl3dj6q6bhiqhszvgw16ry3jva378wp-apple-framework-OpenGL-11.0.0/Library/Frameworks -iframework /nix/store/bfl3dj6q6bhiqhszvgw16ry3jva378wp-apple-framework-OpenGL-11.0.0/Library/Frameworks -iframework /nix/store/v6gh1ygkmpbgcp6x95fydlphimrwlcjx-apple-framework-OpenCL-11.0.0/Library/Frameworks -iframework /nix/store/cclvvyaj5nqb5b3yvd1da39y9vxcdpwy-apple-framework-Cocoa-11.0.0/Library/Frameworks -iframework /nix/store/sgaz24rcnv3cvb6llvldq4shh7ay9by3-apple-framework-AppKit-11.0.0/Library/Frameworks -iframework /nix/store/ljziy41alj340wcy3kvf2p5b7wx4a5jb-apple-framework-AudioToolbox-11.0.0/Library/Frameworks -iframework /nix/store/7yc31sj8ax14vw6xfsycd1lhm2z845qx-apple-private-framework-AudioToolboxCore-11.0.0/Library/Frameworks -iframework /nix/store/sjipssla9p011xw6vl3jfq98kkqbn0gr-apple-framework-Carbon-11.0.0/Library/Frameworks -iframework /nix/store/y6lmsmw9n073x4ibahn6q194k8s6m298-apple-framework-CoreMIDI-11.0.0/Library/Frameworks -iframework /nix/store/sx5w4fqlz19vq92dnx2c1j865mj4hgl6-apple-framework-AudioUnit-11.0.0/Library/Frameworks -iframework /nix/store/9qjyijnhc90ysvv3mwj7wlbxc8l8cvww-apple-framework-CloudKit-11.0.0/Library/Frameworks -iframework /nix/store/fii65gmbfz5lg85k3j7psj6f0rvacp6g-apple-framework-CoreLocation-11.0.0/Library/Frameworks -iframework /nix/store/y1hq5mqfbzch644mrc08g63zm1x0vkx8-apple-framework-CoreData-11.0.0/Library/Frameworks -iframework /nix/store/32vyzaa6mjp8j8i9vzka02za3b80skq3-apple-private-framework-UIFoundation-11.0.0/Library/Frameworks -iframework /nix/store/rpcdk9rc6wnkljd5658cji6glr360ij8-apple-framework-Kernel-11.0.0/Library/Frameworks -L/nix/store/v3xaz3k7ccbfsfladsddlxxd4jbyws01-libobjc-11.0.0/lib -L/nix/store/p3jshbwxiwifm1py0yq544fmdyy98j8a-glibc-2.38-27/lib
glfw-aarch64-apple-darwin> error: unable to find framework 'Cocoa'. searched paths:
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/Cocoa.framework/Cocoa.tbd
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/Cocoa.framework/Cocoa.dylib
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/Cocoa.framework/Cocoa
glfw-aarch64-apple-darwin> error: unable to find framework 'IOKit'. searched paths:
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/IOKit.framework/IOKit.tbd
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/IOKit.framework/IOKit.dylib
glfw-aarch64-apple-darwin>  /nix/store/1jdmjp2g3nd7587c8cpzl3m6kikpyzqz-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/IOKit.framework/IOKit

nix build -L github:Cloudef/zig2nix#env.git.src.cross.aarch64-macos-none.glfw

I haven't tested this on Nix though. Feel free to submit an issue to that effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in linker, cross compiling for macos
2 participants