Bake does not build on Mac OSX

Bug #1217437 reported by Chris Molozian
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bake
Triaged
Medium
Unassigned

Bug Description

I'm not sure this is a bug with bake but it would be fantastic if there was a workaround that could be implemented to allow bake to be built on Mac OS X.

I get these errors when I build the codebase:

```
$ make
valac -o bake-template --pkg=posix src/bake-template.vala
/Users/novabyte/Desktop/bake/src/bake-template.vala.c:477:2: warning: 'g_type_init' is deprecated [-Wdeprecated-declarations]
        g_type_init ();
        ^
/usr/local/Cellar/glib/2.36.4/include/glib-2.0/gobject/gtype.h:669:23: note: 'g_type_init' declared here
void g_type_init (void);
                      ^
1 warning generated.
valac -o bake-test --pkg=posix src/bake-test.vala
/Users/novabyte/Desktop/bake/src/bake-test.vala.c:448:2: warning: 'g_type_init' is deprecated [-Wdeprecated-declarations]
        g_type_init ();
        ^
/usr/local/Cellar/glib/2.36.4/include/glib-2.0/gobject/gtype.h:669:23: note: 'g_type_init' declared here
void g_type_init (void);
                      ^
1 warning generated.
valac -o bake-bootstrap --pkg=glib-2.0 --pkg=gio-2.0 --pkg=posix --Xcc='-DGETTEXT_PACKAGE="C"' --Xcc='-DLIBRARY_DIRECTORY="/usr/lib"' src/bake.vala src/builder.vala src/config-bootstrap.vala src/fixes.vapi src/module-bzip.vala src/module-bzr.vala src/module-data.vala src/module-dpkg.vala src/module-gcc.vala src/module-gettext.vala src/module-gnome.vala src/module-ghc.vala src/module-git.vala src/module-gsettings.vala src/module-gtk.vala src/module-gzip.vala src/module-java.vala src/module-launchpad.vala src/module-mallard.vala src/module-man.vala src/module-mono.vala src/module-python.vala src/module-release.vala src/module-rpm.vala src/module-script.vala src/module-vala.vala src/module-xdg.vala src/module-xzip.vala src/pkg-config.vala src/recipe.vala src/rule.vala
/Users/novabyte/Desktop/bake/src/bake.vala.c:7579:2: warning: 'g_type_init' is deprecated [-Wdeprecated-declarations]
        g_type_init ();
        ^
/usr/local/Cellar/glib/2.36.4/include/glib-2.0/gobject/gtype.h:669:23: note: 'g_type_init' declared here
void g_type_init (void);
                      ^
1 warning generated.
/Users/novabyte/Desktop/bake/src/rule.vala.c:277:25: error: no member named 'st_mtim' in 'struct stat'
                                                _tmp12_ = _tmp11_.st_mtim;
                                                          ~~~~~~~ ^
/Users/novabyte/Desktop/bake/src/rule.vala.c:291:25: error: no member named 'st_mtim' in 'struct stat'
                                                _tmp17_ = _tmp16_.st_mtim;
                                                          ~~~~~~~ ^
/Users/novabyte/Desktop/bake/src/rule.vala.c:402:25: error: no member named 'st_mtim' in 'struct stat'
                                                _tmp50_ = _tmp49_.st_mtim;
                                                          ~~~~~~~ ^
/Users/novabyte/Desktop/bake/src/rule.vala.c:416:25: error: no member named 'st_mtim' in 'struct stat'
                                                _tmp55_ = _tmp54_.st_mtim;
                                                          ~~~~~~~ ^
4 errors generated.
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
make: *** [bake-bootstrap] Error 1
```

I'm building the codebase with Vala 0.20.1 on Mac OSX 10.8.4.

The best blog post I can find on the error message is:

http://www.mauvehaus.com/index.php/a-tale-of-two-stats/

Hope this helps.

Changed in bake:
status: New → Triaged
importance: Undecided → Low
importance: Low → Medium
Revision history for this message
Chris Molozian (chris-molozian) wrote :
Download full text (19.8 KiB)

Ok,

So I did a little more digging... I ran the build process with the compiler's `--ccode` flag to inspect the generated C code.

I inspected the output as follows:

```
$ ack -i st_mtim
src/fixes.vapi
5: public Posix.timespec st_mtim;

src/rule.c
277: _tmp12_ = _tmp11_.st_mtim;
291: _tmp17_ = _tmp16_.st_mtim;
402: _tmp50_ = _tmp49_.st_mtim;
416: _tmp55_ = _tmp54_.st_mtim;

src/rule.vala
42: if (Posix.S_ISREG (file_info.st_mode) && timespec_cmp (file_info.st_mtim, max_input_time) > 0)
44: max_input_time = file_info.st_mtim;
75: if (Posix.S_ISREG (file_info.st_mode) && timespec_cmp (file_info.st_mtim, max_output_time) > 0)
77: max_output_time = file_info.st_mtim;

tests/bake/touch.vala
40: times[1] = info.st_mtim;
```

It looks like you're making use of a field in the stat struct that does not exist in the "stat.h" on Darwin systems:

```
$ cat /usr/include/sys/stat.h
/*
 * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
 *
 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. The rights granted to you under the License
 * may not be used to create, or enable the creation or redistribution of,
 * unlawful or unlicensed copies of an Apple operating system, or to
 * circumvent, violate, or enable the circumvention or violation of, any
 * terms of an Apple operating system software license agreement.
 *
 * Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 *
 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
 */
/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
/*-
 * Copyright (c) 1982, 1986, 1989, 1993
 * The Regents of the University of California. All rights reserved.
 * (c) UNIX System Laboratories, Inc.
 * All or some portions of this file are derived from material licensed
 * to the University of California by American Telephone and Telegraph
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
 * the permission of UNIX System Laboratories, Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditio...

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Hi Chris,

Thanks for the diagnosis!

Could you try lp:~robert-ancell/bake/osx-stat and see if that works for you?

Revision history for this message
Chris Molozian (chris-molozian) wrote :
Download full text (10.0 KiB)

Hi Robert,

Good morning :)

I cloned and attempted to build the branch. Initially my results were:

```
$ make
valac -o bake-template --pkg=posix src/bake-template.vala
/Users/novabyte/Desktop/osx-stat/src/bake-template.vala.c:477:2: warning: 'g_type_init' is deprecated [-Wdeprecated-declarations]
        g_type_init ();
        ^
/usr/local/Cellar/glib/2.36.4/include/glib-2.0/gobject/gtype.h:669:23: note: 'g_type_init' declared here
void g_type_init (void);
                      ^
1 warning generated.
valac -o bake-test --pkg=posix src/bake-test.vala
/Users/novabyte/Desktop/osx-stat/src/bake-test.vala.c:448:2: warning: 'g_type_init' is deprecated [-Wdeprecated-declarations]
        g_type_init ();
        ^
/usr/local/Cellar/glib/2.36.4/include/glib-2.0/gobject/gtype.h:669:23: note: 'g_type_init' declared here
void g_type_init (void);
                      ^
1 warning generated.
valac -o bake-bootstrap --pkg=glib-2.0 --pkg=gio-2.0 --pkg=posix --Xcc='-DGETTEXT_PACKAGE="C"' --Xcc='-DLIBRARY_DIRECTORY="/usr/lib"' src/bake.vala src/builder.vala src/config-bootstrap.vala src/fixes.vapi src/module-bzip.vala src/module-bzr.vala src/module-data.vala src/module-dpkg.vala src/module-gcc.vala src/module-gettext.vala src/module-gnome.vala src/module-ghc.vala src/module-git.vala src/module-gsettings.vala src/module-gtk.vala src/module-gzip.vala src/module-java.vala src/module-launchpad.vala src/module-mallard.vala src/module-man.vala src/module-mono.vala src/module-python.vala src/module-release.vala src/module-rpm.vala src/module-script.vala src/module-vala.vala src/module-xdg.vala src/module-xzip.vala src/pkg-config.vala src/recipe.vala src/rule.vala
/Users/novabyte/Desktop/osx-stat/src/bake.vala.c:7579:2: warning: 'g_type_init' is deprecated [-Wdeprecated-declarations]
        g_type_init ();
        ^
/usr/local/Cellar/glib/2.36.4/include/glib-2.0/gobject/gtype.h:669:23: note: 'g_type_init' declared here
void g_type_init (void);
                      ^
1 warning generated.
/Users/novabyte/Desktop/osx-stat/src/rule.vala.c:272:6: warning: implicit declaration of function 'stat_get_modification_time' is invalid in C99 [-Wimplicit-function-declaration]
                                        stat_get_modification_time (&_tmp7_, &_tmp8_);
                                        ^
1 warning generated.
Undefined symbols for architecture x86_64:
  "_stat_get_modification_time", referenced from:
      _rule_needs_build in rule-uvTG7Q.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
make: *** [bake-bootstrap] Error 1
```

I had a look at your changes in the branch and modified the `Makefile` to also include `fixes.c` in it's `SOURCES` list. I'm not sure if this is exactly the right place to make the change but it allowed the Vala compiler to find the new C source file when building `bake-bootstrap`. I cleaned the buildspace and rebuilt the codebase as follows:

```
$ make
valac -o bake-bootstrap -...

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Thanks, I've incorporated your changes into lp:~robert-ancell/bake/osx-stat and fixed touch to build with the same fix.

However, the last bit I can't work out is where/if UTIME_NOW is defined on OSX. Could you see if you can find what header it is in? Also please look in the apple man page for futimens - that's the function that requires it.

Revision history for this message
Chris Molozian (chris-molozian) wrote :

Hi Robert,

It appears that `futimens(...)` doesn't exist on OS X. It's a POSIX standard, but BSD systems have `futimes(...)` instead.

The best source of information I could find on this is from an old LLVM bug report:

http://llvm.org/bugs/show_bug.cgi?id=16442

There's also a bunch of patches, the most relevant I could find for you is:

http://comments.gmane.org/gmane.comp.compilers.llvm.cvs/150748

The OSX manpage for `futimes(...)` is available here:

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/futimes.2.html

Hope this helps. =)

Revision history for this message
Chris Molozian (chris-molozian) wrote :

Hey Robert,

Is there anything more I can do to help with this?

Cheers,

Chris

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Hi, sorry, haven't had the time to investigate more.

If you are able to branch and modify lp:~robert-ancell/bake/osx-stat so it compiles on OSX I think we're good to land. The last blocker is the use of futimens, I'm not sure if we strictly need this - it's only used in the mock for "touch". So we may be able to get it to work with just futimes(). Please try and see - just check that the tests work by running "bake test".

Thanks for your help!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.