Subject: newlock2 and binary compatibility
To: None <current-users@netbsd.org>
From: Martijn van Buul <pino@dohd.org>
List: current-users
Date: 03/02/2007 08:47:43
Hey;

It seems that since the merge of newlock2, -current is no longer binary
compatible with 4.0_BETA2, 3.* and 2.* binaries. With the merge, several
syscalls have been removed, and no emulation is in place. I stumbled 
across this while trying to cross-compile i386 NetBSD-4.0_BETA2 packages
on my -current amd64 host[1], using a pkg_comp chroot. This fails during
the configuration phase of databases/openldap-client, for example,
as the configure script tries to run a small pthread test program, which
fails with a "system call not implemented."

I tried to reproduce this with an amd64-4.0_BETA2 userland, using a 
small test program:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void *child_thread(void *ptr)
{
	printf("%s\n", (char *)ptr);
}

int main(void)
{
	pthread_t thread1, thread2;
	char *msg1 = "Thread 1";
	char *msg2 = "Thread 2";

	pthread_create(&thread1, NULL, child_thread, (void *)msg1);
	pthread_create(&thread2, NULL, child_thread, (void *)msg2);

	pthread_join(thread1, NULL);
	pthread_join(thread2, NULL);

	return 0;
}

This fails, with the following trace:

 12373      1 a.out    CALL  sa_register
 12373      1 a.out    RET   sa_register -1 errno 78 Function not implemented
 12373      1 a.out    PSIG  SIGSYS SIG_DFL
 12373      1 a.out    NAMI  "a.out.core"

In my specific case, I can probably work around things by trying to
shoehorn -current's libpthread into 4.0_BETA2, but it's not elegant.

Is a "true" solution actually possible? I don't know the old scheduler
activation syscall interface nor the newlock2 one well enough to figure out
if emulation would be feasible, but it would be nice of something could
be done.

Kind regards,

Martijn.

[1] Yes, I am aware that I'm probably stressing the compat32 stuff too 
    much, but it's worth the effort. So far, it works surprisingly well,
    after I removed /etc/ld.so.conf in the chroot.
-- 
Martijn van Buul - pino@dohd.org