cyclus/cyclus — pull request #1020 by scopatz (2014-10-19 22:44:58+00:00)
Title: Fix for cyclus -a for Brightlite et al.

As you may recall, `cyclus -a` was failing for @FlanFlangan in any directory other than the Brightlite source directory. It returned the following rather unhelpful error message:

***
robert@merlin:~/lesstest$ cyclus -a
Inconsistency detected by ld.so: dl-lookup.c: 377: do_lookup_x: Assertion `!(({ __typeof (({ struct pthread *__self; asm ("mov %%fs:%c1,%0" : "=r" (__self) : "i" (__builtin_offsetof (struct pthread, header.self))); __self;})->header.rtld_must_xmm_save) __value; if (sizeof (__value) == 1) asm volatile ("movb %%fs:%P2,%b0" : "=q" (__value) : "0" (0), "i" (__builtin_offsetof (struct pthread, header.rtld_must_xmm_save))); else if (sizeof (__value) == 4) asm volatile ("movl %%fs:%P1,%0" : "=r" (__value) : "i" (__builtin_offsetof (struct pthread, header.rtld_must_xmm_save))); else { if (sizeof (__value) != 8) abort (); asm volatile ("movq %%fs:%P1,%q0" : "=r" (__value) : "i" (__builtin_offsetof (struct pthread, header.rtld_must_xmm_save))); } __value; }) != 0)' failed!
***

Oddly, Cem also experiences this error, though I could not reproduce it on my own machine, even though we are all on Ubuntu 14.04. Though this was clearly a dynamic loading issue, it *is not* related to any `*_PATH` settings since the file paths were absolute. After an hour with Robert's machine, I still had no idea.

Then, reading [the documentation for dlopen()](http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.html), I found this interesting tidbit:

While you're debugging, you'll probably want to use RTLD_NOW; using RTLD_LAZY can create
inscrutable errors if there are unresolved references. Using RTLD_NOW makes opening the
library take slightly longer (but it speeds up lookups later); if this causes a user interface
problem you can switch to RTLD_LAZY later.

The above definitely seems like an 'inscrutable error'. Switching from `RTLD_LAZY` to `RTLD_NOW` fixes the problem on Robert's machine and works on mine as well. Any extra runtime effects seem negligible. Also, I would argue that archetype development is a debugging process, and so the cyclus kernel is right to
use NOW. Unfortunately, this is basically impossible to test as it has proven elusive to even externally reproduce.

This needs to go in very very soon.