> build on sierra failed...
Because the replacement needs to happen on 10.12 too (`HAVE_CLOCK_GETTIME` isn't set there thanks to looking for `clock_gettime` in the nonexistent librt). Now that there's an official patch though, let's just use that one (at the expense of having to regenerate configure).
I've opened #7734 to bump moc devel so that we don't need to keep rebuilding everything else here. Might as well rebase after #7734 is merged; berkeley-db 6.2.23 has already been delayed for the better part of a year anyway.
moc 2.6-alpha3 (devel)
======================
- [x] Have you followed the [guidelines for contributing](https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md)?
- [x] Have you checked that there aren't other open [pull requests](https://github.com/Homebrew/homebrew-core/pulls) for the same formula update/change?
- [x] Have you built your formula locally with `brew install --build-from-source <formula>`, where `<formula>` is the name of the formula you're submitting?
- [x] Does your build pass `brew audit --strict <formula>` (after doing `brew install <formula>`)?
-----
**Please merge https://github.com/Homebrew/formula-patches/pull/95 first, then the commit hash c02ec96 needs to be updated to the one in formula-patches' master branch.**
By the way, the `clock_gettime` issue is subtle in moc. Even if `clock_gettime` is linked on 10.11, running `mocp` won't fail immediately; only if you actually play a song in it and try to seek forward or backward will it error out with the dreaded
```
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
```
Of course we can't test that.
The only reliable test that I know of is
```rb
system "/usr/bin/nm #{bin}/mocp | grep clock_gettime"
```
> Probably worth noting a specific version or even adding a test or this will get left indefinitely.
My patch is only meant for testing... I think
```rb
inreplace Dir["{*.c,compat.h}"], "clock_gettime", "moc_clock_gettime", false
```
is good enough for now.
@ilovezfs Never mind, got the patch: https://raw.githubusercontent.com/Homebrew/patches/b7814c0/moc/moc-r2935%2Bclock_gettime-3.patch
Basically:
```
dnl OSX / MacOS doesn't provide clock_gettime(3) prior to darwin-16.0.0
dnl so fall back to gettimeofday(2).
case "$host_os" in
[*darwin[1-9].*] | [*darwin1[0-5].*])
HAVE_CLOCK_GETTIME="no"
;;
*darwin*)
HAVE_CLOCK_GETTIME="yes"
;;
*)
AC_CHECK_LIB([rt], [clock_gettime],
[HAVE_CLOCK_GETTIME="yes"],
[HAVE_CLOCK_GETTIME="no"])
;;
esac
```
```diff
diff --git a/Formula/moc.rb b/Formula/moc.rb
index 12c9aa70cd..0756bae400 100644
--- a/Formula/moc.rb
+++ b/Formula/moc.rb
@@ -11,9 +11,18 @@ class Moc < Formula
end
devel do
- url "http://ftp.daper.net/pub/soft/moc/unstable/moc-2.6-alpha2.tar.xz"
- sha256 "0a3a4fb11227ec58025f7177a3212aca9c9955226a2983939e8db662af13434b"
+ url "http://ftp.daper.net/pub/soft/moc/unstable/moc-2.6-alpha3.tar.xz"
+ sha256 "a27b8888984cf8dbcd758584961529ddf48c237caa9b40b67423fbfbb88323b1"
+ patch do
+ url "https://raw.githubusercontent.com/Homebrew/patches/b7814c0/moc/moc-r2935%2Bclock_gettime-3.patch"
+ sha256 "601b5cdf59db67f180f1aaa6cc90804c1cb69c44cdecb2e8149338782e4f21a8"
+ end
+
+ # Remove build deps when next devel release comes out
+ depends_on "autoconf" => :build
+ depends_on "automake" => :build
+ depends_on "gettext" => :build
depends_on "popt"
end
@@ -45,7 +54,8 @@ class Moc < Formula
depends_on "homebrew/dupes/ncurses" => :optional
def install
- system "autoreconf", "-fvi" if build.head?
+ # Remove build.devel? when next devel release comes out
+ system "autoreconf", "-fvi" if build.head? || build.devel?
system "./configure", "--disable-debug", "--prefix=#{prefix}"
system "make", "install"
end
```
@ilovezfs Well, if you could "pretend elsewhere (i.e. interface.c) that you have unfettered access to realtime extensions", then you would just call `clock_gettime`, not `moc_clock_gettime`...
@ilovezfs You will have cpp conditionals anyway. A point can be made to limit tweaks to `compat.{c,h}` and pretend elsewhere (i.e. `interface.c`) that you have unfettered access to realtime extensions.
@ilovezfs
> ... pretty uncontroversial, no?
To me it's pretty uncontroversial. However, I wrote
> 3. Ignore Darwin's clock_gettime. Something like the patch attached at
the end.
and John wrote
> Yeah, I did come up with a similar patch, but decided it got too cryptic.
A little bit of context: a while ago John discarded a lot of compat stuff and tried to make the code base as POSIX as possible. It's understandable he doesn't want something like `moc_clock_gettime` in the C code. But then you into all the problems with the heavily contended symbol `clock_gettime`.
zsh 5.2-test-3 (devel)
======================
Created with `brew bump-formula-pr`.
---
http://www.zsh.org/mla/users/2016/msg01020.html
This is the final testing release before 5.3 (scheduled for this Sunday).
By the way, re rpm @maxim-belkin: are you sure `/var/lib/rpm/sqldb` is the correct replacement for `/var/lib/rpm/Packages`? Last time I looked at this I thought it might be due to a subtly broken build, but I don't know enough about rpm (well, I know almost nothing) to tell either way.
@ilovezfs John considered that (there's only one clock_gettime call after all, and it's not even essential, it's only called when seeking forward/backward), but he had concerns over precision of alternate implementations.
I feel bad for all these poor Linux souls who are now forced to clean after Apple's mess.
@ilovezfs We've already discussed `AC_LINK_IFELSE` and such, I'm sure he won't be thrilled to carry that `ofi_clock_gettime.m4` in moc's codebase. However, feel like contributing to Autoconf Archive, or asking Jeff Squyres to do that?
I've been having some back-and-forth with upstream maintainer John Fitzgerald (over private email), with me explaining the clock_gettime clusterfuck and both of us trying to come up ways to fix this in upstream code base satisfactorily. For instance, I've suggested `AC_CHECK_FUNCS` or `AC_SEARCH_LIBS` (reminding him of `SDKROOT` and our `ac_cv_func_clock_gettime` and `ac_cv_search_clock_gettime`); or renaming the function and defining it unconditionally for Darwin:
```diff
diff --git a/compat.c b/compat.c
index df02a1d..5b0bcc5 100644
--- a/compat.c
+++ b/compat.c
@@ -49,13 +49,13 @@ char *strcasestr (const char *haystack, const char *needle)
#endif
/* OSX doesn't provide clock_gettime(3) so fall back to gettimeofday(2). */
-#ifndef HAVE_CLOCK_GETTIME
+#if !defined HAVE_CLOCK_GETTIME || defined __APPLE__
#include <sys/time.h>
#include <assert.h>
#include "common.h"
-int clock_gettime (int clk_id ASSERT_ONLY, struct timespec *ts)
+int my_clock_gettime (int clk_id ASSERT_ONLY, struct timespec *ts)
{
int result;
struct timeval tv;
diff --git a/compat.h b/compat.h
index 71a011e..27c0283 100644
--- a/compat.h
+++ b/compat.h
@@ -50,10 +50,12 @@ extern "C" {
char *strcasestr (const char *haystack, const char *needle);
#endif
-#ifndef HAVE_CLOCK_GETTIME
+#if !defined HAVE_CLOCK_GETTIME || defined __APPLE__
#define CLOCK_REALTIME 0
struct timespec;
-int clock_gettime (int clk_id, struct timespec *ts);
+int my_clock_gettime (int clk_id, struct timespec *ts);
+#else
+#define my_clock_gettime clock_gettime
#endif
#ifdef __cplusplus
diff --git a/interface.c b/interface.c
index e8c3e08..976f023 100644
--- a/interface.c
+++ b/interface.c
@@ -2581,7 +2581,7 @@ static time_t rounded_time ()
struct timespec exact_time;
time_t curr_time;
- if (clock_gettime (CLOCK_REALTIME, &exact_time) == -1)
+ if (my_clock_gettime (CLOCK_REALTIME, &exact_time) == -1)
interface_fatal ("clock_gettime() failed: %s", xstrerror (errno));
curr_time = exact_time.tv_sec;
```
He was unsatisfied with both approaches and decided that he would use a `host_os` based check (no no to me) in his latest email to me (from yesterday).
Whatever the outcome is, rest assured that upstream really wants to fix this.