[Nix-dev] Nix 0.13pre17232 doesn't work on i386-apple-darwin9.7.0
Peter Simons
simons at cryp.to
Tue Sep 29 17:31:25 CEST 2009
Hi,
reportedly, some people have been able to install Nix on MacOS X. It is
a mystery to me how that might have worked. On my machine, Nix produces
a lot of errors during "make check":
| installing `foo-1.0'
| dyld: Symbol not found: _environ
| Referenced from: /tmp/nix-build-igvfiq0nxgvz6r50gxzdjgg0xa1ya0i5-nix-0.13pre17232.drv-0/nix-0.13pre17232/src/libutil/.libs/libutil.dylib
| Expected in: dynamic lookup
|
| error: unexpected EOF reading a line
| FAIL: user-envs.sh
Dynamic libraries cannot access _environ on MacOS X. That pointer is
available only to executable programs, which is why the following code
in src/libutil/util.cc cannot work:
| extern char * * environ;
|
| [...]
|
| void setuidCleanup()
| {
| /* Don't trust the environment. */
| environ = 0;
|
| [...]
| }
The proper way to access _environ from a shared library is to obtain
that pointer at run-time from _NSGetEnviron(), which is defined in
<crt_externs.h>. (See "man environ" for additional detail.)
Furthermore, it's my experience on MacOS X that setting environ to NULL
is quite likely to cause core dumps. To avoid those, the pointer must be
set to a NULL-terminated array of char pointers, i.e.:
static char * empty[] = { 0 };
*_NSGetEnviron() = empty;
Anyway, fixing use of environ is trivial, but that only got me to the
next "make check" error that occurs because libutil.dylib cannot resolve
the global symbol 'ATempty' at load time.
I wonder how it's possible that I appear to be the only one who's
observing these problems?
Take care,
Peter
More information about the nix-dev
mailing list