Ticket #502 (closed bug: fixed)

Opened 6 years ago

Last modified 4 years ago

[PATCH] build on OpenBSD/ppc

Reported by: smallm Owned by:
Priority: normal Milestone:
Component: core Version: trunk
Severity: medium Keywords: build
Cc: Language:
Patch status: Platform: openbsd

Description

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.

Attachments

src_exec_save_c_openbsd_ppc.patch Download (413 bytes) - added by smallm 6 years ago.
supply a couple of elf constants from binutils include/elf/ppc.h
src_exec_openbsd_include_reloc_h.patch Download (451 bytes) - added by smallm 5 years ago.

Change History

Changed 6 years ago by smallm

supply a couple of elf constants from binutils include/elf/ppc.h

  Changed 6 years ago by wiml

See also #454 and #421

follow-up: ↓ 3   Changed 6 years ago by Infinoid

  • status changed from new to closed
  • resolution set to fixed

Thanks, this should be fixed in r38186. Please reopen this ticket if the issue persists.

Changed 5 years ago by smallm

in reply to: ↑ 2   Changed 5 years ago by smallm

Replying to Infinoid:

Thanks, this should be fixed in r38186. Please reopen this ticket if the issue persists.

Sorry for taking so long to try this out.

I now get this compilation error:

perl tools/build/jit2c.pl ppc src/exec_cpu.c
jit2c: JITed 144 (+ 206 vtable) of 1260 ops
src/exec_cpu.c
src/exec_dep.c
src/exec_save.c
src/exec_save.c: In function `Parrot_exec_save':
src/exec_save.c:363: error: `RELOC_REL24' undeclared (first use in this function)
src/exec_save.c:363: error: (Each undeclared identifier is reported only once
src/exec_save.c:363: error: for each function it appears in.)
src/exec_save.c:370: error: `RELOC_16_HI' undeclared (first use in this function)
src/exec_save.c:382: error: `RELOC_16_LO' undeclared (first use in this function)
gmake: *** [src/exec_save.o] Error 1

I think NetBSD must pull in a machine/reloc.h file that doesn't get swept in on OpenBSD.
The patch below (src_exec_openbsd_include_reloc_h.patch) lets it compile and all tests
pass for me on OpenBSD 4.5/ppc. I tried in on OpenBSD 4.5/i386 to check, and it was
okay there too.

follow-up: ↓ 6   Changed 5 years ago by smallm

Seems like I can't reopen tickets. I get a warning at the top saying I don't have permission to change fields. Hopefully you'll see this and reopen it.

  Changed 5 years ago by coke

  • status changed from closed to reopened
  • resolution fixed deleted

in reply to: ↑ 4 ; follow-up: ↓ 7   Changed 5 years ago by jkeenan

Replying to smallm:

Seems like I can't reopen tickets. I get a warning at the top saying I don't have permission to change fields. Hopefully you'll see this and reopen it.

smallm:

Do you submit smoke reports to our Smolder server? If not, could you begin to do so from OpenBSD on both PPC and x86?

The reason I ask this is that the most expeditious way for us to evaluate your patch is to examine Smolder reports on this OS on each platform *before* we apply your patch, and then observe results *after* you apply this patch. I suggest this approach because the number of our developers who have OpenBSD *directly* available is, um, not as large as it should be. So, since it's several weeks to the next release, we can take a chance on applying a patch to trunk and seeing if anything breaks.

This is my suggestion; others may differ.

Thanks for continuing to look at this issue.
kid51

in reply to: ↑ 6 ; follow-up: ↓ 8   Changed 5 years ago by smallm

Replying to jkeenan:

smallm: Do you submit smoke reports to our Smolder server? If not, could
you begin to do so from OpenBSD on both PPC and x86?
The reason I ask this is that the most expeditious way for us to
evaluate your patch is to examine Smolder reports on this OS
on each platform *before* we apply your patch, and then
observe results *after* you apply this patch. ...

No, I hadn't been. I'll try to make a point of submitting one from
time to time, at the least for openbsd/macppc -- looks like
someone is submitting regular openbsd/i386 tests. But for
this bug gmake smoke on powerpc can't get to the smolder
target because of the build error. Should I manually run
t/harness to submit the many failing tests resulting from the
build not completing? Or would it be better only to send an
*after* smoke test on powerpc, and send a before and
after on i386 to show I didn't break that?

in reply to: ↑ 7 ; follow-up: ↓ 9   Changed 5 years ago by jkeenan

I'll try to make a point of submitting one from time to time, at the least for openbsd/macppc -- looks like someone is submitting regular openbsd/i386 tests. But for this bug gmake smoke on powerpc can't get to the smolder target because of the build error. Should I manually run t/harness to submit the many failing tests resulting from the build not completing?

No.

Or would it be better only to send an *after* smoke test on powerpc, and send a before and after on i386 to show I didn't break that?

Yes. Post the Smolder report number for the i386-before when you've completed it. I'll apply your patch sometime tomorrow and we'll cross our fingers.

Thank you very much.
kid51

in reply to: ↑ 8   Changed 5 years ago by smallm

Replying to jkeenan: ....

Yes. Post the Smolder report number for the i386-before when you've completed it. I'll apply your patch sometime tomorrow and we'll cross our fingers.

Alright, it is 24120:  http://smolder.plusthree.com/app/public_projects/report_details/24120

  Changed 4 years ago by smallm

This ticket could be closed I think. The file with the compilation problem (src/exec_save.c) no longer exists, and a smolder test succeeds:  http://smolder.parrot.org/app/projects/report_details/138

  Changed 4 years ago by cotto

  • status changed from reopened to closed
  • resolution set to fixed

Sounds good. I'll mark this as fixed.

Note: See TracTickets for help on using tickets.