From: Michal Suchanek Date: 2007-04-27T02:30:31+09:00 Subject: Re: [ ruby-Bugs-10303 ] miniruby loads extensions from already installed ruby On 26/04/07, Nobuyoshi Nakada wrote: > Hi, > > At Wed, 25 Apr 2007 22:40:28 +0900, > Michal Suchanek wrote in [ruby-core:11020]: > > A patch that really fixes the problem for me. It also fixes the weird > > miniruby crash while loading extensions. > > > + argvptr = strrchr(origargv[0], '/'); > > + if(!argvptr) argvptr = origargv[0]; > > + if(!strstr(argvptr, "miniruby")) { > > I do not like to include miniruby specific code and remain in > installed version. If the problem were just for extensions, > linking dmydln.o would solve it... > I do not like it either. Of course, one could ifdef the change instead of plain if, and compile the object with a define for miniruby. But I would not want to maintain such patch. As it turns out, ruby and miniruby only differ in the way libruby-static is linked in. For miniruby it is linked directly by full name, for ruby it is looked up with -l option. So linking in another file would not fix the extensions for miniruby nor prevent miniruby from loading potetntially broken and incompatible extensions that are already installed. I think the object is present in libruby anyway. Actually the crash is quite mysterious and has probably something to do with OS X linker subtleties I do not understand. Apparently it puts the same objects together in a different way when linking miniruby resulting in executable that behaves differently. gcc -g -O2 -pipe -fno-common -DRUBY_EXPORT -L. -L/sw/lib main.o libruby-static.a -ldl -lobjc -o miniruby /usr/bin/ld: warning multiple definitions of symbol _setregid libruby-static.a(process.o) definition of _setregid in section (__TEXT,__text) /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libdl.dylib(setregid.So) definition of _setregid /usr/bin/ld: warning multiple definitions of symbol _setreuid libruby-static.a(process.o) definition of _setreuid in section (__TEXT,__text) /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libdl.dylib(setreuid.So) definition of _setreuid gcc -g -O2 -pipe -fno-common -DRUBY_EXPORT -L. -L/sw/lib main.o -lruby-static -ldl -lobjc -o ruby /usr/bin/ld: warning multiple definitions of symbol _setregid ./libruby-static.a(process.o) definition of _setregid in section (__TEXT,__text) /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libdl.dylib(setregid.So) definition of _setregid /usr/bin/ld: warning multiple definitions of symbol _setreuid ./libruby-static.a(process.o) definition of _setreuid in section (__TEXT,__text) /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libdl.dylib(setreuid.So) definition of _setreuid Thanks Michal