* [RFA/commit] Work around Solaris bourne shell limitation when building the sim
@ 2011-12-18 16:35 Joel Brobecker
2011-12-18 16:53 ` Andreas Schwab
0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2011-12-18 16:35 UTC (permalink / raw)
To: gdb-patches; +Cc: Mike Frysinger, Joel Brobecker
Hello,
Building the sim on a sparc-solaris 2.8 machine fails when configured
with no extra sim hardware:
> for hw in ; do \
> echo "extern const struct hw_descriptor
> dv_${hw}_descriptor[];" ; \
> done >> tmp-hw.h
> echo 'const char version[] = "'"`sed q
> /[...]/../../gdb/version.in`"'";'
> >> version.c-tmp
> /bin/sh: -c: line 1: syntax error near unexpected token `;'
> /bin/sh: -c: line 1: `for hw in ; do \'
> make[3]: *** [hw-config.h] Error 2
The same thing happens with the version of bash that we got from
Sun as well (which is very old: 2.03.0(1)-release).
The problems comes from the fact that both shells are buggy, and
reject the following script:
for hw in ; do
[...]
done
The above is what sim/common/Makefile.in tries to execute when
generating hw-config.h.
In order to allow users to build out of the box on these machines,
this patch works around this bug. It does rely on the fact that
none of the tokens in SIM_HW contain whitespaces. I don't think
that this is going to be a problem in practice.
sim/common/ChangeLog:
* Make-common.in (hw-config.h): Work around bug in Solaris 2.8
system bourne shell.
Tested on sparc-solaris with both /bin/sh and /bin/bash.
Would that be OK?
PS: An alternate approach, which I think might be better (although
this might depend on taste), is to do use config.h and define
macros there depending on which hw capability is being configured
in. Then hw-config.h no longer needs to be generated. It becomes
a regular source file with #ifdef's in them. I didn't do it
because it's probably a significant amount of work, and I am
not convinced that it's that better.
---
sim/common/Make-common.in | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index c12d155..7c76f50 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -459,14 +459,17 @@ sim-inline.c: $(srccom)/sim-inline.c
$(SHELL) $(srcdir)/../../move-if-change tmp-$@ $@
# FIXME This is one very simple-minded way of generating the file hw-config.h
+# The use of the "`echo $(SIM_HW)`" in the for loops below is to work around
+# bugs in certain system shells (such as the Solaris 2.8 bourne shell)
+# which break when the for list is empty.
hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
rm -f tmp-hw.h
echo "/* generated by Makefile */" > tmp-hw.h
- for hw in $(SIM_HW) ; do \
+ for hw in `echo $(SIM_HW)` ; do \
echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \
done >> tmp-hw.h
echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h
- for hw in $(SIM_HW) ; do \
+ for hw in `echo $(SIM_HW)` ; do \
echo " dv_$${hw}_descriptor," ; \
done >> tmp-hw.h
echo " NULL," >> tmp-hw.h
--
1.7.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Work around Solaris bourne shell limitation when building the sim
2011-12-18 16:35 [RFA/commit] Work around Solaris bourne shell limitation when building the sim Joel Brobecker
@ 2011-12-18 16:53 ` Andreas Schwab
2011-12-18 18:02 ` Joel Brobecker
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2011-12-18 16:53 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Mike Frysinger
Joel Brobecker <brobecker@adacore.com> writes:
> hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
> rm -f tmp-hw.h
> echo "/* generated by Makefile */" > tmp-hw.h
> - for hw in $(SIM_HW) ; do \
sim_hw="$(SIM_HW)"; \
for hw in $$sim_hw ; do \
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Work around Solaris bourne shell limitation when building the sim
2011-12-18 16:53 ` Andreas Schwab
@ 2011-12-18 18:02 ` Joel Brobecker
2011-12-18 19:09 ` Mike Frysinger
2011-12-18 19:13 ` Andreas Schwab
0 siblings, 2 replies; 8+ messages in thread
From: Joel Brobecker @ 2011-12-18 18:02 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gdb-patches, Mike Frysinger
> > hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
> > rm -f tmp-hw.h
> > echo "/* generated by Makefile */" > tmp-hw.h
> > - for hw in $(SIM_HW) ; do \
> sim_hw="$(SIM_HW)"; \
> for hw in $$sim_hw ; do \
I had already tried that:
Makefile:473: *** commands commence before first target. Stop.
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Work around Solaris bourne shell limitation when building the sim
2011-12-18 18:02 ` Joel Brobecker
@ 2011-12-18 19:09 ` Mike Frysinger
2011-12-19 3:48 ` Joel Brobecker
2011-12-18 19:13 ` Andreas Schwab
1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2011-12-18 19:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Joel Brobecker, Andreas Schwab
[-- Attachment #1: Type: Text/Plain, Size: 1037 bytes --]
On Sunday 18 December 2011 12:57:19 Joel Brobecker wrote:
> > > hw-config.h: Makefile.in $(srccom)/Make-common.in config.status
> > > Makefile
> > >
> > > rm -f tmp-hw.h
> > > echo "/* generated by Makefile */" > tmp-hw.h
> > >
> > > - for hw in $(SIM_HW) ; do \
> > >
> > sim_hw="$(SIM_HW)"; \
> >
> > for hw in $$sim_hw ; do \
>
> I had already tried that:
>
> Makefile:473: *** commands commence before first target. Stop.
that seems weird ... i just tried it locally and it seems to work for me ...
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -462,7 +462,8 @@
hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
rm -f tmp-hw.h
echo "/* generated by Makefile */" > tmp-hw.h
- for hw in $(SIM_HW) ; do \
+ sim_hw="$(SIM_HW)"; \
+ for hw in $$sim_hw ; do \
echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \
done >> tmp-hw.h
echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Work around Solaris bourne shell limitation when building the sim
2011-12-18 18:02 ` Joel Brobecker
2011-12-18 19:09 ` Mike Frysinger
@ 2011-12-18 19:13 ` Andreas Schwab
1 sibling, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2011-12-18 19:13 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Mike Frysinger
Joel Brobecker <brobecker@adacore.com> writes:
>> > hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
>> > rm -f tmp-hw.h
>> > echo "/* generated by Makefile */" > tmp-hw.h
>> > - for hw in $(SIM_HW) ; do \
>> sim_hw="$(SIM_HW)"; \
>> for hw in $$sim_hw ; do \
>
> I had already tried that:
>
> Makefile:473: *** commands commence before first target. Stop.
What did you try?
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Work around Solaris bourne shell limitation when building the sim
2011-12-18 19:09 ` Mike Frysinger
@ 2011-12-19 3:48 ` Joel Brobecker
2011-12-19 4:43 ` Mike Frysinger
0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2011-12-19 3:48 UTC (permalink / raw)
To: Mike Frysinger; +Cc: gdb-patches
> that seems weird ... i just tried it locally and it seems to work for me ...
Weird indeed. I thought it was related to the Solaris shell
misunderstanding the variable assignment as a command, or something
like that. Your diff looks almost identical to mine, and yet mine
doesn't work, and I can't figure out why.
No matter, if you prefer this solution, here is a new complete diff.
sim/common/ChangeLog:
* Make-common.in (hw-config.h): Work around bug in Solaris 2.8
system bourne shell.
Tested on sparc-solaris with both /bin/sh and /bin/bash.
Thanks,
--
Joel
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index c12d155..606e595 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -462,11 +462,13 @@ sim-inline.c: $(srccom)/sim-inline.c
hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
rm -f tmp-hw.h
echo "/* generated by Makefile */" > tmp-hw.h
- for hw in $(SIM_HW) ; do \
+ sim_hw="$(SIM_HW)"; \
+ for hw in $$sim_hw ; do \
echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \
done >> tmp-hw.h
echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h
- for hw in $(SIM_HW) ; do \
+ sim_hw="$(SIM_HW)"; \
+ for hw in $$sim_hw ; do \
echo " dv_$${hw}_descriptor," ; \
done >> tmp-hw.h
echo " NULL," >> tmp-hw.h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Work around Solaris bourne shell limitation when building the sim
2011-12-19 3:48 ` Joel Brobecker
@ 2011-12-19 4:43 ` Mike Frysinger
2011-12-19 6:04 ` Joel Brobecker
0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2011-12-19 4:43 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
[-- Attachment #1: Type: Text/Plain, Size: 285 bytes --]
On Sunday 18 December 2011 22:34:26 Joel Brobecker wrote:
> No matter, if you prefer this solution, here is a new complete diff.
>
> sim/common/ChangeLog:
>
> * Make-common.in (hw-config.h): Work around bug in Solaris 2.8
> system bourne shell.
LGTM
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Work around Solaris bourne shell limitation when building the sim
2011-12-19 4:43 ` Mike Frysinger
@ 2011-12-19 6:04 ` Joel Brobecker
0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2011-12-19 6:04 UTC (permalink / raw)
To: Mike Frysinger; +Cc: gdb-patches
> > sim/common/ChangeLog:
> >
> > * Make-common.in (hw-config.h): Work around bug in Solaris 2.8
> > system bourne shell.
>
> LGTM
Thank you. Checked in, HEAD + 7.4.
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-12-19 4:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-18 16:35 [RFA/commit] Work around Solaris bourne shell limitation when building the sim Joel Brobecker
2011-12-18 16:53 ` Andreas Schwab
2011-12-18 18:02 ` Joel Brobecker
2011-12-18 19:09 ` Mike Frysinger
2011-12-19 3:48 ` Joel Brobecker
2011-12-19 4:43 ` Mike Frysinger
2011-12-19 6:04 ` Joel Brobecker
2011-12-18 19:13 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox