Bug 13160 - bfin simulator does not build on Darwin
Summary: bfin simulator does not build on Darwin
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: sim (show other bugs)
Version: 7.3
: P2 normal
Target Milestone: ---
Assignee: Mike Frysinger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 00:05 UTC by Chris Johns
Modified: 2015-03-10 05:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Johns 2011-09-07 00:05:59 UTC
The sim/bfin/Makefile.in contains a COMMON_POST_CONFIG_FRAG to do with $(srcdir)/linux-fixed-code.h. The sed part of the Makefile command does not work on Darwin. The file name needs to be at the end and it complains about the final 'p'.

I had a quick look at the command running on a recent Linux and there is no output generated. It looks like this does nothing.

Configured as:

$ ../../1.0/gdb-7.3/configure --build=i386-apple-darwin10.6.0 --host=i386-apple-darwin10.6.0 --target=bfin-elf --prefix=/Users/chris/bfin-1.0 --verbose --disable-nls --without-included-gettext --disable-win32-registry --disable-werror --with-expat --with-python
Comment 1 Mike Frysinger 2015-03-09 03:52:31 UTC
i don't know what you mean by "complains about the final p".  afaict, the code is POSIX compliant.  please post the exact command you're running and the exact error you're seeing.
Comment 2 Chris Johns 2015-03-10 01:17:15 UTC
Thanks for following up the bug report.

I have just built a git binutils-gdb with this patch https://git.rtems.org/rtems-tools/plain/tools/4.11/gdb/gdb-sim-arange-inline.diff on Marvrick with clang (Xcode) and the build completed successfully. 

I could not find linux-fixed-code.o and so I can only conclude something else has changed and error no longer exists.
Comment 3 Mike Frysinger 2015-03-10 02:18:35 UTC
(In reply to Chris Johns from comment #2)

the linux-fixed-code.h is checked in now, so it only gets regenerated in maintainer mode.  if you delete it, it should try to regen it.

as for that patch, probably should be submitting bug reports/patches to the list so i can review them.
Comment 4 Chris Johns 2015-03-10 03:47:00 UTC
Ah ok thanks. The error is:

/Users/chris/development/play/gdb/bfin-elf/./gas/as-new ../../../binutils-gdb/sim/bfin/linux-fixed-code.s -o linux-fixed-code.o
(       set -e; \
                echo "/* DO NOT EDIT: Autogenerated from linux-fixed-code.s.  */"; \
                echo "static const unsigned char bfin_linux_fixed_code[] ="; \
                echo "{"; \
                /Users/chris/development/play/gdb/bfin-elf/./binutils/objdump -d -z linux-fixed-code.o > ../../../binutils-gdb/sim/bfin/linux-fixed-code.h.dis; \
                sed -n \
                        -e 's:^[^       ]*      :0x:' \
                        -e '/^0x/{s:    .*::;s: *$:,:;s: :, 0x:g;p}' \
                        ../../../binutils-gdb/sim/bfin/linux-fixed-code.h.dis; \
                rm -f ../../../binutils-gdb/sim/bfin/linux-fixed-code.h.dis; \
                echo "};" \
        ) > ../../../binutils-gdb/sim/bfin/linux-fixed-code.h.tmp
sed: 1: "/^0x/{s:       .*::;s: *$:,:; ...": extra characters at the end of p command
make[3]: *** [../../../binutils-gdb/sim/bfin/linux-fixed-code.h] Error 1
make[2]: *** [all] Error 1
make[1]: *** [all-sim] Error 2
make: *** [all] Error 2

I have tried to run the sed script by hand on a Linux box and I get no output.
Comment 5 Mike Frysinger 2015-03-10 04:33:15 UTC
(In reply to Chris Johns from comment #4)

my guess is you're copying & pasting the command from your terminal and that isn't preserving the tabs.  instead you're pasting a command that uses spaces.  you want something like:
bfin-elf-objdump -d -z linux-fixed-code.o | \
  sed -n -e 's:^[^\t]*\t:0x:' -e '/^0x/{s:\t.*::;s: *$:,:;s: :, 0x:g;p}'

i don't know why that's failing as, afaict, the code is POSIX compliant.  maybe Darwin has a crappy implementation ?  i've tried `sed --posix` and `minised` and `busybox sed` and they all work (well, almost ... minised doesn't handle tabs correctly).

maybe it can't handle a nested print ?  what if you combine it with the s:
bfin-elf-objdump -d -z linux-fixed-code.o | \
  sed -n -e 's:^[^\t]*\t:0x:' -e '/^0x/{s:\t.*::;s: *$:,:;s: :, 0x:gp}'

if that still fails, try unrolling it:
bfin-elf-objdump -d -z linux-fixed-code.o | \
  sed -n -e 's:^[^\t]*\t:0x:' -e '/^0x/{s:\t.*::;s: *$:,:;s: :, 0x:g;
p
}'
Comment 6 Chris Johns 2015-03-10 05:09:07 UTC
(In reply to Mike Frysinger from comment #5)
> (In reply to Chris Johns from comment #4)
> 
> my guess is you're copying & pasting the command from your terminal and that
> isn't preserving the tabs.  instead you're pasting a command that uses
> spaces.  

Nice guess. Using C-v<tab> worked.

> you want something like:
> bfin-elf-objdump -d -z linux-fixed-code.o | \
>   sed -n -e 's:^[^\t]*\t:0x:' -e '/^0x/{s:\t.*::;s: *$:,:;s: :, 0x:g;p}'

I think \t is a GNU extension.

> i don't know why that's failing as, afaict, the code is POSIX compliant. 
> maybe Darwin has a crappy implementation ?  i've tried `sed --posix` and
> `minised` and `busybox sed` and they all work (well, almost ... minised
> doesn't handle tabs correctly).

The sed looks similar to FreeBSD. It also fails in the same way.

> 
> maybe it can't handle a nested print ?  what if you combine it with the s:
> bfin-elf-objdump -d -z linux-fixed-code.o | \
>   sed -n -e 's:^[^\t]*\t:0x:' -e '/^0x/{s:\t.*::;s: *$:,:;s: :, 0x:gp}'
> 
> if that still fails, try unrolling it:
> bfin-elf-objdump -d -z linux-fixed-code.o | \
>   sed -n -e 's:^[^\t]*\t:0x:' -e '/^0x/{s:\t.*::;s: *$:,:;s: :, 0x:g;
> p
> }'

Ah ok, thanks for posting this. The following seems this works on MacOS and FreeBSD ...

sed -n -e 's:^[^      ]*      :0x:' -e '/^0x/{s:      .*::;s: *$:,:g;p;}' ../../../binutils-gdb/sim/bfin/linux-fixed-code.h.dis 

This is with <tab> characters and a ';' after the 'p'.
Comment 7 Mike Frysinger 2015-03-10 05:42:49 UTC
(In reply to Chris Johns from comment #6)

\t might be a GNU extension, but you were talking about trying to run it on your linux box ;).  the Makefile.in is using an actual tab character.

at any rate, adding a trailing ; after the p command is easy enough.  i'll push that through.
Comment 8 Sourceware Commits 2015-03-10 05:44:13 UTC
The master branch has been updated by Michael Frysinger <vapier@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6defcd57e9df4f61cd0c59e3d9b66b6b071af808

commit 6defcd57e9df4f61cd0c59e3d9b66b6b071af808
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Tue Mar 10 01:41:48 2015 -0400

    sim: bfin: fix up linux-fixed-code.h generation more [PR sim/13160]
    
    Add a trailing semi-colon to the sed print command as the BSD sed
    implementation wants it.  It's a nop otherwise and works fine on
    GNU/etc... implementations too.