I just tried to build Vim 9.0.1442 on macOS 10.13.6. It fails with a bunch of gibberish about clocks. There was a similar problem with MacVim recently, but @ychin fixed it.
Here is what happens. First there is a warning emitted:
profiler.c:27:5: warning: implicit declaration of function 'clock_gettime' is
invalid in C99 [-Wimplicit-function-declaration]
PROF_GET_TIME(tm);
^
./vim.h:1878:30: note: expanded from macro 'PROF_GET_TIME'
# define PROF_GET_TIME(tm) clock_gettime(CLOCK_MONOTONIC, tm)
^
1 warning generated.
Then the build fails later:
Undefined symbols for architecture x86_64:
"_clock_gettime", referenced from:
_profile_start in profiler.o
_profile_end in profiler.o
_profile_setlimit in profiler.o
_profile_passed_limit in profiler.o
_ex_profile in profiler.o
_prof_inchar_enter in profiler.o
_prof_inchar_exit in profiler.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [vim] Error 1
make: *** [first] Error 2
Vim should build on macOS 10.13.6.
9.0.1442
macOS 10.13.6
Terminal: iTerm2
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I git-bisected and found the offending patch:
076de79ad832558267b3ff903c048df2f4c1a5d6 is the first bad commit
commit 076de79ad832558267b3ff903c048df2f4c1a5d6
Author: Ernie Rael <err...@raelity.com>
Date: Thu Mar 16 21:43:15 2023 +0000
patch 9.0.1411: accuracy of profiling is not optimal
Problem: Accuracy of profiling is not optimal.
Solution: Use CLOCK_MONOTONIC if possible. (Ernie Rael, closes #12129)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@chdiza can you make sure to include Xcode version (including the minor version) when filing issues on macOS compilation issues? It makes a big difference because different versions of Xcode uses different versions of Mac SDKs, and it's more important to include Xcode version than macOS version (but you should probably include both).
In this case, I think Vim added dependency on clock_gettime in #12129, which was only added for macOS 10.12. If you use a newer Xcode to build your code, it should work since you are using macOS 10.13.
From looking at #12129 itself, seems like it's making an erroneous assumption that HAVE_TIMER_CREATE means you have clock_gettime available, which is a somewhat lazy assumption, because timer_create and clock_gettime are different functions and they aren't guaranteed to always exist together (the configure.ac script actually tests for existence of timer_create in order for it to set HAVE_TIMER_CREATE to 1). If we don't want to set up a configure.ac script to properly detect clock_gettime availability, we can do a quick fix by requiring this condition when deciding to use clock_gettime on macOS: defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@ychin It's whatever the newest Xcode that works with El Capitan is. I have no idea what the number is, sorry.
I'm using 10.11, not 10.13. Sorry, I typoed that in the issue text, even though I did it right in the title. I'll edit it now.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I'll add a configure check for clock_gettime(). And use the defined macro to decide how to define PROF_GET_TIME().
Please try it out and reopen the issue (with relevant information) if it doesn't work.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Closed #12242 as completed via 08210f8.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Circling back to this, the new code does work, but it only works when the build environment matches the runtime environment. This is usually the case when you are building code locally or when for a specific OS version, but in MacVim we build a binary in CI and it is designed to work on older OSes. When run as-is, the binary would crash in older macOS (10.9 - 10.11) because the required clock_gettime() function doesn't exist in the runtime.
I fixed that in downstream MacVim in macvim-dev/macvim#1411 by basically doing the following:
# if !defined(MAC_OS_X_VERSION_10_12) \ || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12) // This happens when building on a newer machine for a min deployment lower // than 10.12. The build environment supports clock_gettime(), but the target // runtime doesn't. # undef HAVE_CLOCK_GETTIME # endif
There really isn't an automatic way to detect this in a configure script unfortunately, because it requires knowledge of the runtime environment (in this case macOS historic versions) that you are deploying to rather than just the local build environment.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
I probably could have fixed it to do a runtime version check and split the behavior on an if statement as well, but that seems a little too complicated and not worth that much change (since this seems specific to macOS and the issue only happens on the "legacy" binary build for 10.9 to 10.13 anyway).
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()