I have mostly understood this problem, but not quite how to fix it. in mk/platform/Darwin.mk, we use "/usr/bin/xcrun --show-sdk-path" to find the location for the include files and libs. On a macosx10.9 machine, this prints out: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk which is great if you want to cross-build programs to run under 10.10.... But if you want them to run on 10.9, then the following: "/usr/bin/xcrun --sdk macosx10.9 --show-sdk-path" leads to a more sensible: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk (It's obvious how to write code to convert uname output to an argument for xcrun, but I haven't because it isn't obvious that is the right approach.) However, hardcoding that change in Darwin.mk fixes the substituted paths in the wrappers, but builds (cvs and tmux, to pick two examples) still end up with 10.10 paths in the .deps/ directories and cvs finds openat(), present in 10.10 but not 10.9. The problem seems to be that clang builds against the 10.10 SDK by default. Our wrappers don't pass "-nobuiltininc", nor do they pass the path found from xcrun. I'm convinced this needs fixing, but am unclear on exactly how. What I think we want is: we figure out the sdk version to use from uname, at bootstrap time, or at runtime. (In NetBSD, it's runtime, because /usr/include has headers for the current system, so runtime seems like the best approach in terms of not creating surprises.) clang is told not to search default include paths clang is told to add the SDK include paths It seems really buggy to me that apple-provided clang is behaving this way. The following program: ---------------------------------------- #include <stdlib.h> #include <sys/fcntl.h> int main() { openat(0, "/dev/null", O_RDONLY); exit(0); } ---------------------------------------- when built as "clang -o foo foo.c" builds on 10.9. But running it gives me the same error as CVS: $ ./foo dyld: lazy symbol binding failed: Symbol not found: _openat Referenced from: /Users/gdt/./foo Expected in: /usr/lib/libSystem.B.dylib dyld: Symbol not found: _openat Referenced from: /Users/gdt/./foo Expected in: /usr/lib/libSystem.B.dylib Trace/BPT trap: 5 Running it on NetBSD 6, I get the friendlier: 3242 1 foo CALL openat(0,0x80487c8,0,0xbfbfe9e0) 3242 1 foo RET openat -1 errno 78 Function not implemented When I do pass -nobuiltininc, clang still seems to find the prototype for openat.
Attachment:
pgpSmEwi_ElyW.pgp
Description: PGP signature