After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 747187 - Make gnome-builder work on FreeBSD again
Make gnome-builder work on FreeBSD again
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: general
unspecified
Other FreeBSD
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-04-01 14:53 UTC by Ting-Wei Lan
Modified: 2015-05-12 18:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH 1/5] libide: fix "void function should not return a value" (843 bytes, patch)
2015-04-01 14:59 UTC, Ting-Wei Lan
none Details | Review
[PATCH 2/5] build: add llvm-config35 to the list of name of llvm-config (1.16 KB, patch)
2015-04-01 15:02 UTC, Ting-Wei Lan
none Details | Review
[PATCH 3/5] libide: don't attach -gnu to the local system type instead of failing (927 bytes, patch)
2015-04-01 15:08 UTC, Ting-Wei Lan
none Details | Review
[PATCH 4/5] libide: find GNU make via configure instead of hard-coding make (3.54 KB, patch)
2015-04-01 15:12 UTC, Ting-Wei Lan
none Details | Review
[PATCH 5/5] build: remove -lstdc++ (785 bytes, patch)
2015-04-01 15:17 UTC, Ting-Wei Lan
none Details | Review

Description Ting-Wei Lan 2015-04-01 14:53:29 UTC
After the libide merge, gnome-builder doesn't build on FreeBSD. I will attach 5 patches here. Please see the patches.
Comment 1 Ting-Wei Lan 2015-04-01 14:59:37 UTC
Created attachment 300756 [details] [review]
[PATCH 1/5] libide: fix "void function should not return a value"
Comment 2 Ting-Wei Lan 2015-04-01 15:02:38 UTC
Created attachment 300757 [details] [review]
[PATCH 2/5] build: add llvm-config35 to the list of name of llvm-config

This patch can fix the problem on FreeBSD, but adding a --with- option or providing an environment variable to override the default may be better.
Comment 3 Ting-Wei Lan 2015-04-01 15:08:18 UTC
Created attachment 300759 [details] [review]
[PATCH 3/5] libide: don't attach -gnu to the local system type instead of failing

I see the comment in the code, but I don't know the portability problem it says in the uname() call. POSIX standard supports uname().
Comment 4 Ting-Wei Lan 2015-04-01 15:12:36 UTC
Created attachment 300761 [details] [review]
[PATCH 4/5] libide: find GNU make via configure instead of hard-coding make

Most GNOME modules require GNU make to build. For example, Makefile.introspection can only be run using GNU make. It will be better if we can provide an option for users to set the make implemetation that they want to use.
Comment 5 Ting-Wei Lan 2015-04-01 15:17:14 UTC
Created attachment 300762 [details] [review]
[PATCH 5/5] build: remove -lstdc++

FreeBSD 10 and later uses clang and libc++ by default, so there is no libstdc++. I can build gnome-builder on Linux without using -lstdc++, so I think it can be removed.
Comment 6 Christian Hergert 2015-04-01 19:02:11 UTC
Review of attachment 300759 [details] [review]:

This needs to be a valid host triplet for the autoconf --host= or --target= parameter.
Comment 7 Christian Hergert 2015-04-01 19:11:46 UTC
Thanks for the patches!

Going to push these now, but we should figure out what the right host triplet is for FreeBSD. It very well might still be -gnu, but I'm not up to date.
Comment 8 Christian Hergert 2015-04-01 19:13:39 UTC
According to http://wiki.osdev.org/Target_Triplet, it seems that if we come up with "x86_64-freebsd", we are probably okay.
Comment 9 Ting-Wei Lan 2015-04-01 19:24:38 UTC
We use "amd64-portbld-freebsd10.1" or "x86_64-portbld-freebsd10.1" in FreeBSD ports. "amd64-freebsd" (showed by ide-list-devices) is also OK.
Comment 10 Christian Hergert 2015-05-11 21:50:04 UTC
We did a bunch of build cleanup in the last couple of weeks, any chance you could test things out and see if they are still working on FreeBSD?
Comment 11 Ting-Wei Lan 2015-05-12 03:42:56 UTC
There is a linking failure because sched_getcpu is not available on FreeBSD.

There is a sysctl wrapper function called kinfo_getproc can be used to get the number of CPU that a process run on, but it uses malloc internally. We have to link to libutil to use this function.

static unsigned int egg_get_current_cpu (void)
{
  struct kinfo_proc *proc = kinfo_getproc (getpid ());
  unsigned int cpu = proc->ki_oncpu;
  return cpu;
}

If we want to avoid malloc and linking to libutil, we can use sysctl directly.

static unsigned int egg_get_current_cpu (void)
{
  struct kinfo_proc proc;
  sysctl ((int []){ CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid () },
          4,
          &proc,
          &(size_t){ sizeof (proc) },
          NULL,
          0);
  return proc.ki_oncpu;
}
Comment 12 Ting-Wei Lan 2015-05-12 03:57:12 UTC
It seems the default compiler on FreeBSD 10.1, clang 3.4.1, doesn't support __builtin_ia32_rdtscp. Clang 3.5 has this built-in function.

I don't know whether we really want to use sysctl when compilers don't support __builtin_ia32_rdtscp, so I didn't make a patch.
Comment 13 Christian Hergert 2015-05-12 04:03:25 UTC
Yeah, we'd want to avoid the syscall altogether. Almost certainly the atomic would be faster. On Linux, sched_getcpu() uses cached information that is updated during scheduler transitions (along with information exported from the vdso). So it was okay to use as a fallback.
Comment 14 Christian Hergert 2015-05-12 04:31:55 UTC
For the time being I've just made it fallback to atomics.
Comment 15 Ting-Wei Lan 2015-05-12 04:39:40 UTC
There is another error after the sched_getcpu code is disabled:

implicit declaration of function '__sync_fetch_and_add8' is invalid in C99.
Comment 16 Christian Hergert 2015-05-12 04:44:22 UTC
Try with 76ed2c3ff7896e8fbadab7a98007807ee99a833c
Comment 17 Ting-Wei Lan 2015-05-12 05:11:18 UTC
gnome-builder can be successfully built now.
Comment 18 Ting-Wei Lan 2015-05-12 06:03:27 UTC
It crashes when 'unsaved document 1' is closed in a project placed in XDG_DOWNLOAD_DIR.

14:00:03.0655                    GLib-GObject[432164192]:  WARNING: g_object_weak_unref: couldn't find weak ref 0x800a11d80(0x822199480)
**
egg-signal-group:ERROR:egg-signal-group.c:201:egg_signal_group_unbind: assertion failed: (handler->handler_id != 0)
Comment 19 Christian Hergert 2015-05-12 17:41:43 UTC
Can you see if commit f6b132576e889c72966f804881052dbc9eb3a679 fixes this for you?
Comment 20 Ting-Wei Lan 2015-05-12 18:14:36 UTC
Yes, it is fixed now although I still get some unrelated crashes. There are also some possible glib bugs that prevent gnome-builder tests from passing. (It is expected because glib tests also fail with similar errors.)

Thanks for all fixes!
Comment 21 Christian Hergert 2015-05-12 18:32:59 UTC
Lovely. Please file bugs for those if you have time :)