#502: [PATCH] build on OpenBSD/ppc
--------------------+-------------------------------------------------------
 Reporter:  smallm  |        Type:  bug    
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  core   
  Version:  trunk   |    Severity:  medium 
 Keywords:  build   |        Lang:         
    Patch:          |    Platform:  openbsd
--------------------+-------------------------------------------------------
 I see the same errors Steve Peters reported in rt.perl.org incident 40959
 when attempting to build parrot on OpenBSD/ppc:
 {{{
 src/asmfun.s: Assembler messages:
 src/asmfun.s:6: Error: unsupported relocation against f14
 src/asmfun.s:6: Error: unsupported relocation against r1
 ...
 }}}
 It looks like there was an attempt to deal with this in
 config/init/hints/openbsd.pm with this line:

   if ( ( split( m/-/, $conf->data->get_p5('archname'), 2 ) )[0] eq
 'powerpc' ) {
         $conf->data->set( as => 'as -mregnames' );
     }

 The -mregnames argument would let asmfun.s be assembled, but AS=as
 -mregnames never gets used because of this rule in the Makefile:

 # XXX probably should detect assembler, but right now this is only used on
 Sparc

 .s$(O) : # suffix rule (limited support)
         @$(PERL) tools/dev/cc_flags.pl $(CUR_DIR)/CFLAGS $(CC) ""
 $(CFLAGS) -I$(@D) -o $@ -c $<

  I tried putting the arg in CFLAGS like this (don't use this):
 {{{
 --- config/init/hints/openbsd.pm        Wed Mar 11 17:12:11 2009
 +++ config/init/hints/openbsd.pm.new    Wed Mar 25 16:41:53 2009
 @@ -13,6 +13,10 @@
      if ( $ccflags !~ /-pthread/ ) {
          $ccflags .= ' -pthread';
      }
 +    if ( ( split( m/-/, $conf->data->get_p5('archname'), 2 ) )[0] eq
 'powerpc' ) {
 +        $ccflags .= ' -mregnames';
 +    }
 +
      $conf->data->set( ccflags => $ccflags );

      my $libs = $conf->data->get('libs');
 @@ -30,11 +34,6 @@
          libparrot_shared_alias => 'libparrot$(SHARE_EXT)',
          libparrot_soname       =>
 '-Wl,-soname=libparrot$(SHARE_EXT).$(SOVERSION)',
      );
 -
 -    if ( ( split( m/-/, $conf->data->get_p5('archname'), 2 ) )[0] eq
 'powerpc' ) {
 -        $conf->data->set( as => 'as -mregnames' );
 -    }
 -
  }

  1;
 }}}

 That got it further along in the compile (but later the function in
 asmfun.o failed to be found by the linker) and I hit this error:
 {{{
 cc -I./include -fno-delete-null-pointer-checks -pipe -I/usr/local/include
 -pthread -DHASATTRIBUTE_CONST -DHASATTRIBUTE_DEPRECATED
 -DHASATTRIBUTE_MALLOC -DHASATTRIBUTE_NONNULL -DHASATTRIBUTE_NORETURN
 -DHASATTRIBUTE_PURE -DHASATTRIBUTE_UNUSED -falign-functions=16 -W -Wall
 -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment
 -Wdisabled-optimization -Wendif-labels -Wformat -Wformat-extra-args
 -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimplicit -Wimport
 -Winline -Wmissing-braces -Wno-missing-format-attribute -Wpacked
 -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wno-shadow
 -Wsign-compare -Wstrict-aliasing -Wswitch -Wswitch-default -Wtrigraphs
 -Wundef -Wunknown-pragmas -Wno-unused -Wwrite-strings -Wbad-function-cast
 -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-
 declarations -Wmissing-prototypes -Wnested-externs -Wnonnull -g -DHAS_JIT
 -DPPC -DHAVE_COMPUTED_GOTO -DPIC -fPIC -I. -o xx.o -c xx.c
 src/exec_save.c
 src/exec_save.c: In function `Parrot_exec_save':
 src/exec_save.c:343: error: `R_PPC_REL24' undeclared (first use in this
 function)
 src/exec_save.c:343: error: (Each undeclared identifier is reported only
 once
 src/exec_save.c:343: error: for each function it appears in.)
 src/exec_save.c:350: error: `R_PPC_ADDR16_HI' undeclared (first use in
 this function)
 src/exec_save.c:362: error: `R_PPC_ADDR16_LO' undeclared (first use in
 this function)
 gmake: *** [src/exec_save.o] Error 1
 }}}
 These constants can be pulled from GNU binutils (http://www.openbsd.org
 /cgi-bin/cvsweb/src/gnu/usr.bin/binutils/include/elf/ppc.h?rev=1.6
 ;content-type=text%2Fplain;only_with_tag=MAIN).  I have a diff attached
 for that.

 With that patch applied I get to the link but hit this error:
 {{{
 g++ -o miniparrot src/main.o src/null_config.o \
         -Wl,-R/home/smallm/src/external/devel/perl/parrot/blib/lib
 -L/home/smallm/src/external/devel/perl/parrot/blib/lib -lparrot -lpthread
 -lm -L/usr/local/lib  -licuuc -licudata -lpthread -lm -lm -lutil -lpthread
 -lreadline -lncurses -Wl,-E
 /home/smallm/src/external/devel/perl/parrot/blib/lib/libparrot.so:
 warning: vsprintf() is often misused, please use vsnprintf()
 /home/smallm/src/external/devel/perl/parrot/blib/lib/libparrot.so:
 warning: strcpy() is almost always misused, please use strlcpy()
 /home/smallm/src/external/devel/perl/parrot/blib/lib/libparrot.so:
 warning: sprintf() is often misused, please use snprintf()
 /home/smallm/src/external/devel/perl/parrot/blib/lib/libparrot.so:
 warning: strcat() is almost always misused, please use strlcat()
 /home/smallm/src/external/devel/perl/parrot/blib/lib/libparrot.so:
 undefined reference to `Parrot_ppc_jit_restore_nonvolatile_registers'
 gmake: *** [miniparrot] Error 1
 }}}
 src/jit/ppc/asm.s has that function name with a leading underscore.  So I
 reverted the earlier change I mentioned to openbsd.pm and copied
 src/jit/ppc/ppc-linux.s to src/jit/ppc/ppc-openbsd.s as the patch to
 parrot in the openbsd ports tree does.  That file has the function name
 without the underscore and doesn't use register names, which seems to be
 the two things it needs to keep openbsd/ppc happy.  Reconfiguring and
 building with that file in place and the patch to src/exec_save.c parrot
 builds and ''gmake test'' has all tests pass.

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/502>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to