From: Cyrus H. <ch...@bo...> - 2007-11-27 15:00:12
|
Hi Sidney, I'm guessing that you have roughly half of the Leopard/ppc port done now :), besides working around any bugs introduced in leopard (which I think, at least for x86/x86-64, I managed to file radar bugs on the ones I found during the beta phase and that they were fixed so hopefully this is a non-issue). The second part, thanks to Apple for the continuing quest to make the life of the maintenance programmer hell, is to fix the ldso stubs so that foreign symbols get a _ in front of them as the linker now silently drops symbols without a leading _, at least on x86/x86-64. That would explain the malloc lossage below. Here's the patch for x86/x86-64. A similar treatment for ppc should do the trick. Cyrus Index: src/code/foreign.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/code/foreign.lisp,v retrieving revision 1.40 diff -u -r1.40 foreign.lisp --- src/code/foreign.lisp 23 Nov 2006 15:11:27 -0000 1.40 +++ src/code/foreign.lisp 7 Oct 2007 21:51:44 -0000 @@ -34,7 +34,10 @@ (let ((extern (extern-alien-name name))) (values (or (gethash extern table) - (gethash (concatenate 'base-string "ldso_stub__" extern) table))))) + (gethash (concatenate 'base-string + #!+(and darwin (or x86 x86-64)) "_ldso_stub__" + #!-(and darwin (or x86 x86-64)) "ldso_stub__" + extern) table))))) Index: tools-for-build/ldso-stubs.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/tools-for-build/ldso-stubs.lisp,v retrieving revision 1.17 diff -u -r1.17 ldso-stubs.lisp --- tools-for-build/ldso-stubs.lisp 9 Sep 2007 07:46:18 -0000 1.17 +++ tools-for-build/ldso-stubs.lisp 7 Oct 2007 21:51:48 -0000 @@ -117,8 +117,8 @@ #define LDSO_STUBIFY(fct) \\ .text ; \\ .align 4 ; \\ -.globl ldso_stub___ ## fct ; \\ -ldso_stub___ ## fct: ; \\ +.globl _ldso_stub___ ## fct ; \\ +_ldso_stub___ ## fct: ; \\ jmp L ## fct ## $stub ; \\ .section __IMPORT,__jump_table,symbol_stubs,self_modifying_code +pure_instructions,5 ; \\ L ## fct ## $stub: ; \\ @@ -134,8 +134,8 @@ #!+(and darwin x86-64) " #define LDSO_STUBIFY(fct) \\ .align 4 ; \\ -.globl ldso_stub___ ## fct ; \\ -ldso_stub___ ## fct: ; \\ +.globl _ldso_stub___ ## fct ; \\ +_ldso_stub___ ## fct: ; \\ jmp _ ## fct ; \\ .L ## fct ## e1: ; " On Nov 27, 2007, at 5:38 AM, Sidney Markowitz wrote: > Cyrus Harmon wrote, On 27/11/07 3:46 PM: >> Feel free to ape what I >> did for ppc and submit a patch or, if nobody does it sooner, I'll try >> to do this weekend. > > I tried to do this, using the attached patch, and got through the > compilation ok, but here is what I get later in the build when it is > in > the "Beginning GENESIS, creating core "output/cold-sbcl.core" step. > Any > ideas what is still wrong? In the attached patch I give all of the > symbols I #define a prefix of _PPC_ to make sure that the problem was > not caused by defining a symbol that is used for something else. > Please > excuse the lengh, but the PPC has many more regiaters than the x86, > which makes the list of names longer. > > The following is the error I get when building with the attached > patch, > which is diffed against current cvs: > > unhandled SIMPLE-ERROR: The foreign symbol "malloc" is undefined. > > 0: (SB-DEBUG:BACKTRACE 128 #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDERR* > {100E85F1}>) > 1: (SB-DEBUG::DEBUGGER-DISABLED-HOOK > #<SIMPLE-ERROR {12247779}> > #<unavailable argument>) > 2: (INVOKE-DEBUGGER #<SIMPLE-ERROR {12247779}>) > 3: (INVOKE-DEBUGGER #<SIMPLE-ERROR {12247779}>) > 4: (ERROR "The foreign symbol ~S is undefined.") > 5: (SB!FASL::COLD-FOREIGN-SYMBOL-ADDRESS "malloc") > 6: (SB!FASL::COLD-FOP-FOREIGN-FIXUP) > 7: (SB!FASL::LOAD-FASL-GROUP > #<SB-SYS:FD-STREAM for "file > /Users/ari/OpenSource/sbcl-1.0.12/obj/from-xc/src/code/target- > alieneval.lisp-obj" > {11A47049}>) > 8: (SB!FASL::LOAD-AS-FASL > #<SB-SYS:FD-STREAM for "file > /Users/ari/OpenSource/sbcl-1.0.12/obj/from-xc/src/code/target- > alieneval.lisp-obj" > {11A47049}> > NIL > #<unavailable argument>) > 9: (SB!FASL::COLD-LOAD #P"obj/from-xc/src/code/target-alieneval.lisp- > obj") > 10: (NIL) > 11: (SB-INT:SIMPLE-EVAL-IN-LEXENV > (SB!VM:GENESIS :OBJECT-FILE-NAMES *TARGET-OBJECT-FILE-NAMES* > :C-HEADER-DIR-NAME "output/genesis-2" ...) > #<NULL-LEXENV>) > 12: (SB-EXT:INTERACTIVE-EVAL > (SB!VM:GENESIS :OBJECT-FILE-NAMES *TARGET-OBJECT-FILE-NAMES* > :C-HEADER-DIR-NAME "output/genesis-2" ...)) > 13: (SB-IMPL::REPL-FUN NIL) > 14: (SB-IMPL::REPL-FUN NIL) > 15: ((LAMBDA ())) > 16: ((LAMBDA ())) > 17: (SB-IMPL::%WITH-REBOUND-IO-SYNTAX #<CLOSURE (LAMBDA #) > {11A62135}>) > 18: (SB-IMPL::TOPLEVEL-REPL NIL) > 19: (SB-IMPL::TOPLEVEL-INIT) > 20: ((LABELS SB-IMPL::RESTART-LISP)) > > unhandled condition in --disable-debugger mode, quitting > Index: src/runtime/ppc-darwin-os.c > =================================================================== > RCS file: /cvsroot/sbcl/sbcl/src/runtime/ppc-darwin-os.c,v > retrieving revision 1.9 > diff -u -r1.9 ppc-darwin-os.c > --- src/runtime/ppc-darwin-os.c 18 Jun 2007 16:18:36 -0000 1.9 > +++ src/runtime/ppc-darwin-os.c 27 Nov 2007 13:21:36 -0000 > @@ -38,78 +38,78 @@ > os_context_register_t * > os_context_register_addr(os_context_t *context, int offset) > { > - ppc_saved_state_t *state = &context->uc_mcontext->ss; > + _PPC_SS_STRUCT_TYPE *state = &context->uc_mcontext->_PPC_SS; > switch(offset) { > case 0: > - return (os_context_register_t *) &state->r0; > + return (os_context_register_t *) &state->_PPC_R0; > case 1: > - return (os_context_register_t *) &state->r1; > + return (os_context_register_t *) &state->_PPC_R1; > case 2: > - return (os_context_register_t *) &state->r2; > + return (os_context_register_t *) &state->_PPC_R2; > case 3: > - return (os_context_register_t *) &state->r3; > + return (os_context_register_t *) &state->_PPC_R3; > case 4: > - return (os_context_register_t *) &state->r4; > + return (os_context_register_t *) &state->_PPC_R4; > case 5: > - return (os_context_register_t *) &state->r5; > + return (os_context_register_t *) &state->_PPC_R5; > case 6: > - return (os_context_register_t *) &state->r6; > + return (os_context_register_t *) &state->_PPC_R6; > case 7: > - return (os_context_register_t *) &state->r7; > + return (os_context_register_t *) &state->_PPC_R7; > case 8: > - return (os_context_register_t *) &state->r8; > + return (os_context_register_t *) &state->_PPC_R8; > case 9: > - return (os_context_register_t *) &state->r9; > + return (os_context_register_t *) &state->_PPC_R9; > case 10: > - return (os_context_register_t *) &state->r10; > + return (os_context_register_t *) &state->_PPC_R10; > case 11: > - return (os_context_register_t *) &state->r11; > + return (os_context_register_t *) &state->_PPC_R11; > case 12: > - return (os_context_register_t *) &state->r12; > + return (os_context_register_t *) &state->_PPC_R12; > case 13: > - return (os_context_register_t *) &state->r13; > + return (os_context_register_t *) &state->_PPC_R13; > case 14: > - return (os_context_register_t *) &state->r14; > + return (os_context_register_t *) &state->_PPC_R14; > case 15: > - return (os_context_register_t *) &state->r15; > + return (os_context_register_t *) &state->_PPC_R15; > case 16: > - return (os_context_register_t *) &state->r16; > + return (os_context_register_t *) &state->_PPC_R16; > case 17: > - return (os_context_register_t *) &state->r17; > + return (os_context_register_t *) &state->_PPC_R17; > case 18: > - return (os_context_register_t *) &state->r18; > + return (os_context_register_t *) &state->_PPC_R18; > case 19: > - return (os_context_register_t *) &state->r19; > + return (os_context_register_t *) &state->_PPC_R19; > case 20: > - return (os_context_register_t *) &state->r20; > + return (os_context_register_t *) &state->_PPC_R20; > case 21: > - return (os_context_register_t *) &state->r21; > + return (os_context_register_t *) &state->_PPC_R21; > case 22: > - return (os_context_register_t *) &state->r22; > + return (os_context_register_t *) &state->_PPC_R22; > case 23: > - return (os_context_register_t *) &state->r23; > + return (os_context_register_t *) &state->_PPC_R23; > case 24: > - return (os_context_register_t *) &state->r24; > + return (os_context_register_t *) &state->_PPC_R24; > case 25: > - return (os_context_register_t *) &state->r25; > + return (os_context_register_t *) &state->_PPC_R25; > case 26: > - return (os_context_register_t *) &state->r26; > + return (os_context_register_t *) &state->_PPC_R26; > case 27: > - return (os_context_register_t *) &state->r27; > + return (os_context_register_t *) &state->_PPC_R27; > case 28: > - return (os_context_register_t *) &state->r28; > + return (os_context_register_t *) &state->_PPC_R28; > case 29: > - return (os_context_register_t *) &state->r29; > + return (os_context_register_t *) &state->_PPC_R29; > case 30: > - return (os_context_register_t *) &state->r30; > + return (os_context_register_t *) &state->_PPC_R30; > case 31: > - return (os_context_register_t *) &state->r31; > + return (os_context_register_t *) &state->_PPC_R31; > case 41: > /* PT_DAR */ > - return (os_context_register_t *) &context->uc_mcontext- > >es.dar; > + return (os_context_register_t *) &context->uc_mcontext- > >_PPC_ES._PPC_DAR; > case 42: > /* PT_DSISR */ > - return (os_context_register_t *) &context->uc_mcontext- > >es.dsisr; > + return (os_context_register_t *) &context->uc_mcontext- > >_PPC_ES._PPC_DSISR; > default: > lose("bad offset to os_context_register_addr"); > } > @@ -118,13 +118,13 @@ > os_context_register_t * > os_context_lr_addr(os_context_t *context) > { > - return (os_context_register_t *) &context->uc_mcontext->ss.lr; > + return (os_context_register_t *) &context->uc_mcontext- > >_PPC_SS._PPC_LR; > } > > os_context_register_t * > os_context_pc_addr(os_context_t *context) > { > - return &context->uc_mcontext->ss.srr0; > + return &context->uc_mcontext->_PPC_SS._PPC_SRR0; > } > > void > Index: src/runtime/ppc-darwin-os.h > =================================================================== > RCS file: /cvsroot/sbcl/sbcl/src/runtime/ppc-darwin-os.h,v > retrieving revision 1.4 > diff -u -r1.4 ppc-darwin-os.h > --- src/runtime/ppc-darwin-os.h 25 Jul 2007 21:37:31 -0000 1.4 > +++ src/runtime/ppc-darwin-os.h 27 Nov 2007 13:21:36 -0000 > @@ -7,6 +7,129 @@ > { > return (os_context_t *) *void_context; > } > +/* As of XCode 3.0, the field names for the thread state have changed > + * and now are prepended with __. Use some #define hackery to deal > + * with this. MAC_OS_X_VERSION_10_5 seems to be a good test to see if > + * we need the new style field names. > + */ > +#if MAC_OS_X_VERSION_10_5 > + > +#define _PPC_ES __es > +#define _PPC_FS __fs > +#define _PPC_SS __ss > +#define _PPC_VS __vs > + > +#define _PPC_SRR0 __srr0 > +#define _PPC_SRR1 __srr1 > +#define _PPC_R0 __r0 > +#define _PPC_R1 __r1 > +#define _PPC_R2 __r2 > +#define _PPC_R3 __r3 > +#define _PPC_R4 __r4 > +#define _PPC_R5 __r5 > +#define _PPC_R6 __r6 > +#define _PPC_R7 __r7 > +#define _PPC_R8 __r8 > +#define _PPC_R9 __r9 > +#define _PPC_R10 __r10 > +#define _PPC_R11 __r11 > +#define _PPC_R12 __r12 > +#define _PPC_R13 __r13 > +#define _PPC_R14 __r14 > +#define _PPC_R15 __r15 > +#define _PPC_R16 __r16 > +#define _PPC_R17 __r17 > +#define _PPC_R18 __r18 > +#define _PPC_R19 __r19 > +#define _PPC_R20 __r20 > +#define _PPC_R21 __r21 > +#define _PPC_R22 __r22 > +#define _PPC_R23 __r23 > +#define _PPC_R24 __r24 > +#define _PPC_R25 __r25 > +#define _PPC_R26 __r26 > +#define _PPC_R27 __r27 > +#define _PPC_R28 __r28 > +#define _PPC_R29 __r29 > +#define _PPC_R30 __r30 > +#define _PPC_R31 __r31 > +#define _PPC_CR __cr > +#define _PPC_XER __xer > +#define _PPC_LR __lr > +#define _PPC_CTR __ctr > +#define _PPC_MQ __mq > +#define _PPC_VRSAVE __vrsave > + > +#define _PPC_FPREGS __fpregs > +#define _PPC_FPSCR __fpscr > +#define _PPC_SAVE_VR __save_vr > +#define _PPC_SAVE_VSCR __save_vscr > +#define _PPC_DAR __dar > +#define _PPC_DSISR __dsisr > +#define _PPC_EXCEPTION __exception > + > +#define _PPC_SS_STRUCT_TYPE ppc_thread_state_t > + > +#else > + > +#define _PPC_ES es > +#define _PPC_FS fs > +#define _PPC_SS ss > +#define _PPC_VS vs > + > +#define _PPC_SRR0 srr0 > +#define _PPC_SRR1 srr1 > +#define _PPC_R0 r0 > +#define _PPC_R1 r1 > +#define _PPC_R2 r2 > +#define _PPC_R3 r3 > +#define _PPC_R4 r4 > +#define _PPC_R5 r5 > +#define _PPC_R6 r6 > +#define _PPC_R7 r7 > +#define _PPC_R8 r8 > +#define _PPC_R9 r9 > +#define _PPC_R10 r10 > +#define _PPC_R11 r11 > +#define _PPC_R12 r12 > +#define _PPC_R13 r13 > +#define _PPC_R14 r14 > +#define _PPC_R15 r15 > +#define _PPC_R16 r16 > +#define _PPC_R17 r17 > +#define _PPC_R18 r18 > +#define _PPC_R19 r19 > +#define _PPC_R20 r20 > +#define _PPC_R21 r21 > +#define _PPC_R22 r22 > +#define _PPC_R23 r23 > +#define _PPC_R24 r24 > +#define _PPC_R25 r25 > +#define _PPC_R26 r26 > +#define _PPC_R27 r27 > +#define _PPC_R28 r28 > +#define _PPC_R29 r29 > +#define _PPC_R30 r30 > +#define _PPC_R31 r31 > +#define _PPC_CR cr > +#define _PPC_XER xer > +#define _PPC_LR lr > +#define _PPC_CTR ctr > +#define _PPC_MQ mq > +#define _PPC_VRSAVE vrsave > + > +#define _PPC_FPREGS fpregs > +#define _PPC_FPSCR fpscr > +#define _PPC_SAVE_VR save_vr > +#define _PPC_SAVE_VSCR save_vscr > +#define _PPC_DAR dar > +#define _PPC_DSISR dsisr > +#define _PPC_EXCEPTION exception > + > +#define _PPC_SS_STRUCT_TYPE ppc_saved_state_t > + > +#endif /* MAC_OS_X_VERSION_10_5 */ > + > +#define DARWIN_FIX_CONTEXT(c) (c->uc_mcontext- > >_PPC_SS._PPC_XER)^=0x80; > > -#define DARWIN_FIX_CONTEXT(c) (c->uc_mcontext->ss.xer)^=0x80; > #endif /* _PPC_DARWIN_OS_H */ > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Sbcl-devel mailing list > Sbc...@li... > https://lists.sourceforge.net/lists/listinfo/sbcl-devel |