Today I had again some energy to look at why mono fails to build on FreeBSD-current.
I decided to do a debug-build of mono. This did not work initially, I had to produce some patches. 🙁
Does this mean nobody is doing debug builds of mono on FreeBSD?
I have to say, this experience with lang/mono is completely unsatisfying.
Ok, bottom line, either the debug build seems to prevent a race condition in most cases (I had a lot less lockups for each of the two builds I did).
Whatever it is, I do not care ATM (if the configure stuff is looking at the architecture of the system, it may be the case that the i386-portbld-freebsdX does not enable some important stuff which would be enabled when run with i486-portbld-freebsdX or better). Here are the patches I used in case someone is interested (warning, copy&paste converted tabs to spaces, you also have to apply the map.c (a generated file… maybe a touch of the right file would allow to apply this patch in the normal patch stage) related stuff when the build fails, else there is some parser error in mono):
--- mcs/class/Mono.Posix/Mono.Unix/UnixProcess.cs.orig 2010-01-29 11:34:00.592323482 +0100
+++ mcs/class/Mono.Posix/Mono.Unix/UnixProcess.cs 2010-01-29 11:34:18.540607357 +0100
@@ -57,7 +57,7 @@ namespace Mono.Unix {
int r = Native.Syscall.waitpid (pid, out status,
Native.WaitOptions.WNOHANG | Native.WaitOptions.WUNTRACED);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
- return r;
+ return status;
}
public int ExitCode {
--- mono/io-layer/processes.c.orig 2010-01-29 11:36:08.904331535 +0100
+++ mono/io-layer/processes.c 2010-01-29 11:42:21.819159544 +0100
@@ -160,7 +160,7 @@ static gboolean waitfor_pid (gpointer te
ret = waitpid (process->id, &status, WNOHANG);
} while (errno == EINTR);
- if (ret <= 0) {
+ if (ret == 0 || (ret < 0 && errno != ECHILD)) {
/* Process not ready for wait */
#ifdef DEBUG
g_message ("%s: Process %d not ready for waiting for: %s",
@@ -169,6 +169,17 @@ static gboolean waitfor_pid (gpointer te
return (FALSE);
}
+
+ if (ret < 0 && errno == ECHILD) {
+#ifdef DEBUG
+ g_message ("%s: Process %d does not exist (anymore)", __func__,
+ process->id);
+#endif
+ /* Faking the return status. I do not know if it is correct
+ * to assume a successful exit.
+ */
+ status = 0;
+ }
#ifdef DEBUG
g_message ("%s: Process %d finished", __func__, ret);
--- mono/metadata/mempool.c.orig 2010-01-29 11:58:16.871052861 +0100
+++ mono/metadata/mempool.c 2010-01-29 12:30:45.143367454 +0100
@@ -212,12 +212,14 @@ mono_backtrace (int size)
EnterCriticalSection (&mempool_tracing_lock);
g_print ("Allocating %d bytes\n", size);
+#if defined(HAVE_BACKTRACE_SYMBOLS)
symbols = backtrace (array, BACKTRACE_DEPTH);
names = backtrace_symbols (array, symbols);
for (i = 1; i < symbols; ++i) {
g_print ("\t%s\n", names [i]);
}
free (names);
+#endif
LeaveCriticalSection (&mempool_tracing_lock);
}
--- mono/metadata/metadata.c.orig 2010-01-29 11:59:38.552316989 +0100
+++ mono/metadata/metadata.c 2010-01-29 12:00:43.957337476 +0100
@@ -3673,12 +3673,16 @@ mono_backtrace (int limit)
void *array[limit];
char **names;
int i;
+#if defined(HAVE_BACKTRACE_SYMBOLS)
backtrace (array, limit);
names = backtrace_symbols (array, limit);
for (i =0; i < limit; ++i) {
g_print ("\t%s\n", names [i]);
}
g_free (names);
+#else
+ g_print ("No backtrace available.\n");
+#endif
}
#endif
--- support/map.c.orig 2010-01-29 12:05:22.374653708 +0100
+++ support/map.c 2010-01-29 12:10:29.024412452 +0100
@@ -216,7 +216,7 @@
#define _cnm_dump(to_t, from) do {} while (0)
#endif /* def _CNM_DUMP */
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(__FreeBSD__)
#define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \
int uns = _cnm_integral_type_is_unsigned (to_t); \
gint64 min = (gint64) _cnm_integral_type_min (to_t); \