GNOME Bugzilla – Bug 604858
Fails to build on non-linux systems that have strptime()
Last modified: 2013-09-14 16:53:47 UTC
Hi, e-d-s has this in libedataserver/e-time-utils.c: #ifdef __linux__ /* We need this to get a prototype for strptime. */ #define _GNU_SOURCE #endif /* __linux__ */ And then if HAVE_STRPTIME is not defined, its implemented locally. The problem is when you build e-d-s on a non-linux platform (such as GNU/Hurd) that has strptime. Since it doesn't define __linux__, _GNU_SOURCE isn't defined and you don't get a prototype for strptime(), but since HAVE_STRPTIME is defined, the function is not implemented and thus you get an implicit declaration error. The attached patch makes use of _XOPEN_SOURCE instead of _GNU_SOURCE since both strptime and nl_langinfo are now POSIX, and do the right checks with HAVE_FOO rather than __linux__.
Created attachment 149939 [details] [review] Fix build on GNU/Hurd
Evolution works on GNU/Hurd!? I had no idea. Can't verify this for myself but the patch and explanation seem reasonable.
GLib really ought to wrap this time stuff and deal with the portability issues so we don't have to. Might be worth filing an enhancement request for that.
I haven't tried to run evo on Hurd yet, but who knows, maybe it works... past versions were building fine, maybe somebody has already used it ;) Thanks, patch pushed: http://git.gnome.org/cgit/evolution-data-server/commit/?id=47cf221ae610bbf64bc1e328960e5812c20df41f
Now eds is failing to build in my system /opt/gnome2/lib/glib-2.0/include -I/usr/include/libsoup-2.4 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/nspr4 -pthread -I/home/akhil/opt/gnome2/include/libxml2 -I/home/akhil/opt/gnome2/include/glib-2.0 -I/home/akhil/opt/gnome2/lib/glib-2.0/include -I/usr/include/libsoup-2.4 -g -O0 -Wl,--allow-shlib-undefined -fgnu89-inline -MT libedataserver_1_2_la-eds-version.lo -MD -MP -MF .deps/libedataserver_1_2_la-eds-version.Tpo -c eds-version.c -fPIC -DPIC -o .libs/libedataserver_1_2_la-eds-version.o mv -f .deps/libedataserver_1_2_la-e-proxy.Tpo .deps/libedataserver_1_2_la-e-proxy.Plo cp libedataserver.pc libedataserver-1.2.pc mv -f .deps/libedataserver_1_2_la-e-sexp.Tpo .deps/libedataserver_1_2_la-e-sexp.Plo mv -f .deps/libedataserver_1_2_la-e-source-group.Tpo .deps/libedataserver_1_2_la-e-source-group.Plo e-time-utils.c: In function ‘e_mktime_utc’: e-time-utils.c:1965: error: ‘struct tm’ has no member named ‘tm_gmtoff’ e-time-utils.c: In function ‘e_localtime_with_offset’: e-time-utils.c:1996: error: ‘struct tm’ has no member named ‘tm_gmtoff’ make[2]: *** [libedataserver_1_2_la-e-time-utils.lo] Error 1 make[2]: *** Waiting for unfinished jobs.... mv -f .deps/libedataserver_1_2_la-e-source-list.Tpo .deps/libedataserver_1_2_la-e-source-list.Plo mv -f .deps/libedataserver_1_2_la-e-source.Tpo .deps/libedataserver_1_2_la-e-source.Plo mv -f .deps/libedataserver_1_2_la-e-url.Tpo .deps/libedataserver_1_2_la-e-url.Plo mv -f .deps/libedataserver_1_2_la-e-data-server-util.Tpo .deps/libedataserver_1_2_la-e-data-server-util.Plo mv -f .deps/test_source_list-test-source-list.Tpo .deps/test_source_list-test-source-list.Po mv -f .deps/libedataserver_1_2_la-e-trie.Tpo .deps/libedataserver_1_2_la-e-trie.Plo mv -f .deps/libedataserver_1_2_la-eds-version.Tpo .deps/libedataserver_1_2_la-eds-version.Plo mv -f .deps/libedataserver_1_2_la-e-xml-utils.Tpo .deps/libedataserver_1_2_la-e-xml-utils.Plo mv -f .deps/libedataserver_1_2_la-e-xml-hash-utils.Tpo .deps/libedataserver_1_2_la-e-xml-hash-utils.Plo make[2]: Leaving directory `/home/akhil/src/git/evolution-data-server/libedataserver' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/akhil/src/git/evolution-data-server' make: *** [all] Error 2
Guess this should be reverted first. There are a lot of definitions following - and I'm not sure if the removal of __linux is a good idea. http://www.opengroup.org/onlinepubs/009695399/basedefs/time.h.html http://www.opengroup.org/onlinepubs/009695399/functions/mktime.html I guess gmtoff isn't supported - however I had no coffee till now and I don't want to guarantee that this guess is correct.
Reverted in commit 7519d65 due to build break.
Created attachment 149980 [details] [review] Fix build on GNU/Hurd, take 2 tm_gmtoff is a BSD extension, as you can see on <time.h> or on localtime(3): The glibc version of struct tm has additional fields long tm_gmtoff; /* Seconds east of UTC */ const char *tm_zone; /* Timezone abbreviation */ defined when _BSD_SOURCE was set before including <time.h>. This is a BSD extension, present in 4.3BSD-Reno. It was defined before because _GNU_SOURCE also defines _BSD_SOURCE. The fix is to define _BSD_SOURCE to get tm_gmtoff back. The attached patch builds fine. Sorry for breaking the build on master.
Thanks for the update. It seems to wirk, at least with respect of buildability. I didn't check the functionality itself, but the change seems to be fine. Thus please commit to master and close this bug. Thanks.
Thanks, committed.