* [fixinc] Allow CONFIG_SHELL to override build-time shell in mkheaders
@ 2020-02-21 1:18 Alexandre Oliva
2020-02-21 20:29 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Oliva @ 2020-02-21 1:18 UTC (permalink / raw)
To: gcc-patches; +Cc: bkorb
mkheaders.in uses substitutions of @SHELL@ to run fixinc.sh and
mkinstalldirs. Problem is, SHELL comes from CONFIG_SHELL for the
build system, and it needs not match whatever is available at an
unrelated host system after installation, when mkheaders is supposed
to be run.
I considered ditching the hardcoding altogether, but decided to retain
it, but allowing CONFIG_SHELL and SHELL to override it, if any of them
can successfully run mkinstalldirs, and if those and the substituted
@SHELL@ fail, fallback to /bin/sh and to plain execution of the
script, which appears to enable at least one shell on a system that
doesn't typicall have a shell to recognize a script by #!/bin/sh and
reinvoke itself to run it.
If all of these fail, we fail, but only after telling the user to
retry after setting CONFIG_SHELL, that fixincl itself also uses.
Tested with a x86_64-linux-gnu native, and on various combinations of
build, host and targets, including cross and canadian crosses involving
host systems that don't have a built-in Bourne Shell. I'm going ahead
and checking it in as part of the build machinery, though I acknowledge
this might be stretching configury a bit. Please let me know if you
have any objections to this stretching, or to the change itself.
for fixincludes/ChangeLog
* mkheaders.in: Don't require build-time shell on host.
---
| 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
--git a/fixincludes/mkheaders.in b/fixincludes/mkheaders.in
index a293a57..4109dc6 100644
--- a/fixincludes/mkheaders.in
+++ b/fixincludes/mkheaders.in
@@ -77,11 +77,29 @@ libexecsubdir=${libexecdir}/gcc/${target_noncanonical}/${version}
itoolsdir=${libexecsubdir}/install-tools
itoolsdatadir=${libsubdir}/install-tools
incdir=${libsubdir}/include-fixed
-mkinstalldirs="@SHELL@ ${itoolsdir}/mkinstalldirs"
+mkinstalldirs="${itoolsdir}/mkinstalldirs"
cd ${itoolsdir}
rm -rf ${incdir}/*
+for shell in $CONFIG_SHELL $SHELL @SHELL@ /bin/sh ""; do
+ if { test -x $shell || test -x $shell.exe; } \
+ && $shell $mkinstalldirs > /dev/null 2>&1; then
+ mkinstalldirs="$shell $mkinstalldirs"
+ break
+ elif test x$shell = x; then
+ if $mkinstalldirs > /dev/null 2>&1; then
+ break
+ elif test ! -f $mkinstalldirs; then
+ echo mkheaders: could not find $mkinstalldirs >&2
+ exit 1
+ else
+ echo mkheaders: please rerun with CONFIG_SHELL set to a working Bourne shell >&2
+ exit 1
+ fi
+ fi
+done
+
for ml in `cat ${itoolsdatadir}/fixinc_list`; do
sysroot_headers_suffix=`echo ${ml} | sed -e 's/;.*$//'`
multi_dir=`echo ${ml} | sed -e 's/^[^;]*;//'`
@@ -91,7 +109,7 @@ for ml in `cat ${itoolsdatadir}/fixinc_list`; do
if [ x${STMP_FIXINC} != x ] ; then
TARGET_MACHINE="${target}" target_canonical="${target}" \
MACRO_LIST="${itoolsdatadir}/macro_list" \
- @SHELL@ ./fixinc.sh ${subincdir} \
+ $shell ./fixinc.sh ${subincdir} \
${isysroot}${SYSTEM_HEADER_DIR} ${OTHER_FIXINCLUDES_DIRS}
rm -f ${subincdir}/syslimits.h
if [ -f ${subincdir}/limits.h ]; then
--
Alexandre Oliva, freedom fighter he/him https://FSFLA.org/blogs/lxo/
Free Software Evangelist Stallman was right, but he's left :(
GNU Toolchain Engineer The darkest places in hell are reserved for those
who maintain their neutrality in times of moral crisis. -- Dante Alighieri
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [fixinc] Allow CONFIG_SHELL to override build-time shell in mkheaders
2020-02-21 1:18 [fixinc] Allow CONFIG_SHELL to override build-time shell in mkheaders Alexandre Oliva
@ 2020-02-21 20:29 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2020-02-21 20:29 UTC (permalink / raw)
To: Alexandre Oliva, gcc-patches; +Cc: bkorb
On Thu, 2020-02-20 at 22:17 -0300, Alexandre Oliva wrote:
> mkheaders.in uses substitutions of @SHELL@ to run fixinc.sh and
> mkinstalldirs. Problem is, SHELL comes from CONFIG_SHELL for the
> build system, and it needs not match whatever is available at an
> unrelated host system after installation, when mkheaders is supposed
> to be run.
>
> I considered ditching the hardcoding altogether, but decided to retain
> it, but allowing CONFIG_SHELL and SHELL to override it, if any of them
> can successfully run mkinstalldirs, and if those and the substituted
> @SHELL@ fail, fallback to /bin/sh and to plain execution of the
> script, which appears to enable at least one shell on a system that
> doesn't typicall have a shell to recognize a script by #!/bin/sh and
> reinvoke itself to run it.
>
> If all of these fail, we fail, but only after telling the user to
> retry after setting CONFIG_SHELL, that fixincl itself also uses.
>
> Tested with a x86_64-linux-gnu native, and on various combinations of
> build, host and targets, including cross and canadian crosses involving
> host systems that don't have a built-in Bourne Shell. I'm going ahead
> and checking it in as part of the build machinery, though I acknowledge
> this might be stretching configury a bit. Please let me know if you
> have any objections to this stretching, or to the change itself.
>
>
> for fixincludes/ChangeLog
>
> * mkheaders.in: Don't require build-time shell on host.
OK
jeff
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-21 20:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 1:18 [fixinc] Allow CONFIG_SHELL to override build-time shell in mkheaders Alexandre Oliva
2020-02-21 20:29 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).