<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'><div style="text-align: left;">Oh, very good point.<br>"gcc" is Apple and resembles "man gcc", "m3cg" not..<br><br> - Jay<br></div><br><br><hr id="stopSpelling">> CC: m3devel@elegosoft.com<br>> From: hosking@cs.purdue.edu<br>> Subject: Re: [M3devel] PPC_DARWIN problems, at least config/5.2.6, maybe all moot<br>> Date: Tue, 25 Dec 2007 23:17:56 -0500<br>> To: jayk123@hotmail.com<br>> <br>> <br>> On Dec 25, 2007, at 3:32 PM, Jay wrote:<br>> <br>> > 1)<br>> ><br>> > The documentation says -fPIC is the default, so I removed it.<br>> > But it matters. It doesn't matter for gcc building C.<br>> > It matters for m3cg building Modula-3.<br>> <br>> Please note that m3cg is based on the GNU release of gcc, *not* the <br>> Darwin version. Thus, even though Darwin might have -fPIC as default <br>> for Apple's gcc, GNU gcc might not.<br>> <br>> > It is the difference between, pic:<br>> ><br>> > jbook:/dev2/j/m3 jay$ cat Hello.m3<br>> > MODULE Hello EXPORTS Main;<br>> ><br>> > IMPORT IO;<br>> > BEGIN<br>> > IO.Put("Hello\n");<br>> > END Hello.<br>> ><br>> > jbook:/dev2/j/m3 jay$ cat PPC_DARWIN/Hello.ms<br>> > ...<br>> > bl L_IO__Put$stub<br>> > ...<br>> > .data<br>> > .picsymbol_stub<br>> > L_IO__Put$stub:<br>> > .indirect_symbol _IO__Put<br>> > mflr r0<br>> > bcl 20,31,L0$_IO__Put<br>> > L0$_IO__Put:<br>> > mflr r11<br>> > addis r11,r11,ha16(L_IO__Put$lazy_ptr-L0$_IO__Put)<br>> > mtlr r0<br>> > lwz r12,lo16(L_IO__Put$lazy_ptr-L0$_IO__Put)(r11)<br>> > mtctr r12<br>> > addi r11,r11,lo16(L_IO__Put$lazy_ptr-L0$_IO__Put)<br>> > bctr<br>> > .data<br>> > .lazy_symbol_pointer<br>> > L_IO__Put$lazy_ptr:<br>> > .indirect_symbol _IO__Put<br>> > .long dyld_stub_binding_helper<br>> ><br>> > vs. non-pic just plain wow only one whole function to make a call :) :<br>> ><br>> > jbook:/dev2/j/m3 jay$ cat PPC_DARWIN/Hello.ms<br>> > ...<br>> > bl _IO__Put<br>> ><br>> > which nets you the likes of:<br>> ><br>> > jbook:/dev2/j/m3 jay$ cm3<br>> > -> linking prog<br>> > gcc -dynamic -o prog _m3main.o Hello.mo -L/cm3/pkg/libm3/ <br>> > PPC_DARWIN -lm3 -L/cm3/pkg/m3core/PPC_DARWIN -lm3core -L/cm3/bin/../ <br>> > lib -lm3gcdefs<br>> > /usr/bin/ld: _m3main.o has external relocation entries in non- <br>> > writable section (__TEXT,__text) for symbols:<br>> > _RTProcess__Exit<br>> > _RTLinker__AddUnit<br>> > _RTLinker__InitRuntime<br>> > collect2: ld returned 1 exit status<br>> ><br>> ><br>> > (Windows also only uses one instruction, through a pointer, for <br>> > dynamic calls, and the compiler often prefetches the pointer.<br>> > The difference is, perhaps, that Windows aggregates all the <br>> > pointers together, not sure about the other systems.. one instruction<br>> > through a pointer is true for x86 and AM64, not so of the former <br>> > MIPS, PowerPC, Alpha I believe or current IA64, those<br>> > require fetching/restore the GOT/TOC (same thing? I should know the <br>> > difference..)<br>> ><br>> > 2)<br>> > Splitting -L and -l off for shared libs matters.<br>> ><br>> > ld /foo/bar.a means link to bar.a, which is a static lib, not even <br>> > a stub lib or import lib like in Windows<br>> ><br>> > -L/foo -lbar probes for<br>> > /foo/bar.dylib<br>> > /foo/bar.a<br>> ><br>> > man ld:<br>> > -lx This option is an abbreviation for the library <br>> > name `libx.a',<br>> > where x is a string. If -dynamic is specified the <br>> > abbreviation<br>> > for the library name is first search as <br>> > `libx.dylib' and then<br>> > `libx.a' is searched for. ld searches for <br>> > libraries first in<br>> > any directories specified with -L options, then in <br>> > any directo-<br>> > ries specified in the colon separated set of paths in <br>> > the envi-<br>> > ronment variable LD_LIBRARY_PATH, then the standard <br>> > directories<br>> > /lib, /usr/lib, and /usr/local/lib. A library is <br>> > searched when<br>> > its name is encountered, so the placement of the -l <br>> > flag is sig-<br>> > nificant. If string x is of the form x.o, then <br>> > that file is<br>> > searched for in the same places, but without <br>> > prepending `lib' or<br>> > appending `.a' or `.dylib' to the filename.<br>> ><br>> ><br>> > 3)<br>> > lastly, setting DYLD_LIBRARY_PATH=/cm3/lib<br>> > lets the full paths from one machine not matter so much on another <br>> > machine.<br>> ><br>> > I am going to try out:<br>> ><br>> > before:<br>> > local lib_so = format ("lib%s.dylib", lib)<br>> > local lib_soxx = format ("lib%s.%s.dylib", lib, version)<br>> > local lib_pn = LIB_INSTALL & "/" & lib_soxx<br>> ><br>> > "-install_name", lib_pn,<br>> ><br>> > after:<br>> ><br>> > local lib_so = format ("lib%s.dylib", lib)<br>> > local lib_soxx = format ("lib%s.%s.dylib", lib, version)<br>> > local lib_pn = LIB_INSTALL & "/" & lib_soxx<br>> ><br>> > "-install_name", lib_soxx,<br>> ><br>> > see if a path is needed or can just use leaf names.<br>> ><br>> > - Jay<br>> ><br>> > From: jayk123@hotmail.com<br>> > To: m3devel@elegosoft.com<br>> > Subject: PPC_DARWIN problems, at least config/5.2.6, maybe all moot<br>> > Date: Tue, 25 Dec 2007 12:09:31 +0000<br>> ><br>> > PPC_DARWIN also has problems...at least in the config.<br>> ><br>> ><br>> > If you take the 5.2.6 archive, install to /dev2/cm3, accept the <br>> > defaults,<br>> > claim all the missing unused libs are in /usr/lib (opengl, <br>> > postgres, x11)<br>> ><br>> ><br>> > you end up with:<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ cat Hello.m3<br>> ><br>> ><br>> > MODULE Hello EXPORTS Main;<br>> > IMPORT IO;<br>> > BEGIN<br>> > IO.Put("Hello\n");<br>> > END Hello.<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ uname -a<br>> > Darwin jbook 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 <br>> > 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh <br>> > powerpc<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ cm3 -version<br>> > Critical Mass Modula-3 version 5.2.6<br>> > last updated: 2003-06-27<br>> > configuration: /cm3/bin/cm3.cfg<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ cm3<br>> > new source -> compiling Hello.m3<br>> > -> linking prog<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ PPC_DARWIN/prog<br>> > dyld: Library not loaded: /var/tmp/cm3/lib/libm3.5.2.dylib<br>> > Referenced from: /dev2/j/m3/PPC_DARWIN/prog<br>> > Reason: image not found<br>> > Trace/BPT trap<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ otool -L PPC_DARWIN/prog<br>> > PPC_DARWIN/prog:<br>> > /var/tmp/cm3/lib/libm3.5.2.dylib (compatibility version <br>> > 5.0.0, current version 5.2.0)<br>> > /Users/wagner/local/cm3/lib/libm3core.5.2.dylib <br>> > (compatibility version 5.0.0, current version 5.2.0)<br>> > /Users/wagner/local/cm3/lib/libm3gcdefs.5.2.dylib <br>> > (compatibility version 5.0.0, current version 5.2.0)<br>> > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, <br>> > current version 88.1.10)<br>> > /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, <br>> > current version 1.0.0)<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ ls -l PPC_DARWIN/prog<br>> > -rwxr-xr-x 1 jay admin 20264 Dec 25 04:43 PPC_DARWIN/prog<br>> ><br>> ><br>> > At the temporary cost of giving up dynamic linking, you can fix <br>> > this by removing M3_SPLIT_LIBNAMES_IF_SHARED<br>> > and/or M3_SPLIT_LIBNAMES from cm3.cfg, yielding:<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ otool -L PPC_DARWIN/prog<br>> > PPC_DARWIN/prog:<br>> > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, <br>> > current version 88.1.10)<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ ls -l PPC_DARWIN/prog<br>> > -rwxr-xr-x 1 jay admin 1388380 Dec 25 04:48 PPC_DARWIN/prog<br>> ><br>> ><br>> > jbook:/dev2/j/m3 jay$ PPC_DARWIN/prog<br>> > Hello<br>> ><br>> ><br>> > I will fix the checked in config file...even though it varies a <br>> > bunch from the 5.2.6 distributed<br>> > config, it results in the same.<br>> ><br>> ><br>> > And, um, does everyone understand what I did with Win32 and making <br>> > cminstall obsolete?<br>> > Ok to do the same on Mac OS X?<br>> > You know, it's running things out of the path and/or finding them <br>> > in their "very standard" locations.<br>> > In fact, you can hard code full paths and be ok.<br>> > That is, instead of asking the user where their compiler is, <br>> > hardcoding any of cc, gcc, /usr/bin/cc, /usr/bin/gcc all work fine.<br>> > Asking them where ar/ranlib are, similar, though the docs say that <br>> > libtool replaced those, and ar/ranlib vs. libtool is one way<br>> > in which the checked in config and the 5.2.6 distribution's config <br>> > vary. I'll try for libtool.<br>> ><br>> ><br>> > The only thing the user really needs to decide is where to install <br>> > to, and<br>> > the cfg file can discover their choice without any editing.<br>> ><br>> ><br>> > INSTALL_ROOT = path() & "/.."<br>> > BIN_INSTALL = path() % executables<br>> ><br>> ><br>> > In terms of wanting to provide some configurable redirection, well, <br>> > I think an advanced user can manage..<br>> > An indirect SYSTEM_CC = "cc" can be left, I guess.<br>> ><br>> ><br>> > You know, I dare say, that platforms have been reduced and <br>> > converged enough such that..you can get rid of<br>> > Quake and move it into cm3. Um.. do any of the Unix platforms <br>> > support other than gcc? Other than GNU ld?<br>> > Ok, Apple ld is not GNU ld. (Geez, it is just me or is Apple an <br>> > incredible hodgepodge mess these days?<br>> > I mean both in terms of their "system architecture" and their <br>> > tools. The "system architecture" reveals bunches<br>> > of similar redundant subsystems. Try reading through man ld, man <br>> > ranlib, just try to understand which<br>> > flag goes with which mode, which flags are for compatibility with <br>> > which OS version, and which of the<br>> > compatibility flags is either ignored or does something useful... <br>> > and should I say -lGL or -framework OpenGL??)<br>> ><br>> ><br>> > That I don't haven't adjusted to Modula-3 and don't mind/prefer <br>> > writing Quake instead. :)<br>> ><br>> ><br>> > Some bootstrap was provided. I should look at it, and its config.<br>> > Otherwise..I'll look into what it takes to build it all and with <br>> > dynamic linking.<br>> > Perhaps the bootstrap is just fine. But the checked in config is not.<br>> ><br>> ><br>> > - Jay<br>> ><br>> > Share life as it happens with the new Windows Live. Share now!<br>> > Share life as it happens with the new Windows Live. Share now!<br>> <br><br /><hr />The best games are on Xbox 360. Click here for a special offer on an Xbox 360 Console. <a href='http://www.xbox.com/en-US/hardware/wheretobuy/' target='_new'>Get it now!</a></body>
</html>