demanual update (was: Don't use / when applying sed with CFLAGS)
В Пнд, 27/06/2011 в 17:01 +0200, Fabian Groffen пишет:
> On 27-06-2011 14:08:52 +0000, Justin Lecher wrote:
> > Please do not use / as seperater when using sed with CFLAGS. I came
> across a bug today where it failed for crossdev. Here the toolchain
> header paths in the cflags and consowuently the seds fail.
This is already documented (see link below).
> Please also don't use ':' as separator, as some platforms have options
> for their toolchain that includes colons.
But still our documentation explicitly suggests ':' for CFLAGS cases and
example allows bash substitution.
http://devmanual.gentoo.org/ebuild-writing/functions/src_compile/building/index.html
see example in "Fixing Compiler Usage" section and text below:
sed -i -e "s:cc -O2:$(tc-getCC) ${CFLAGS} ${LDFLAGS}:" build.sh
Are there any objections to suggest '|' for CFLAGS, LDFLAGS (see
attachment)?
--
Peter.
06-28-2011, 06:24 AM
Fabian Groffen
demanual update (was: Don't use / when applying sed with CFLAGS)
On 28-06-2011 10:16:06 +0400, Peter Volkov wrote:
> Are there any objections to suggest '|' for CFLAGS, LDFLAGS (see
> attachment)?
Not from my side. It's what we've been using so far.
> <note>
> -When using <c>sed</c> with <c>CFLAGS</c> or <c>LDFLAGS</c>, it is not safe to use
> -a comma or a slash as a delimiter. The recommended character is a colon.
> +When using <c>sed</c> with <c>CFLAGS</c> or <c>LDFLAGS</c>, it is not safe to
> +use a comma, a colon or a slash as a delimiter. <c>gcc</c> options may contain
gcc -> gcc, ld, ar, etc.
> +this characters so <c>sed</c> will fail after bash expansion. The recommended
> +character is a vertical bar: '|' (the pipe).
--
Fabian Groffen
Gentoo on a different level
06-28-2011, 06:54 AM
Michał Górny
demanual update (was: Don't use / when applying sed with CFLAGS)
On Tue, 28 Jun 2011 10:16:06 +0400
Peter Volkov <pva@gentoo.org> wrote:
> But still our documentation explicitly suggests ':' for CFLAGS cases
> and example allows bash substitution.
>
> http://devmanual.gentoo.org/ebuild-writing/functions/src_compile/building/index.html
> see example in "Fixing Compiler Usage" section and text below:
> sed -i -e "s:cc -O2:$(tc-getCC) ${CFLAGS} ${LDFLAGS}:" build.sh
>
> Are there any objections to suggest '|' for CFLAGS, LDFLAGS (see
> attachment)?
I think that also a good idea may be to provide an Makefile example,
showing that often sed is unnecessary, and it's enough to do things
like:
emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"...
--
Best regards,
Michał Górny
06-28-2011, 12:25 PM
Peter Volkov
demanual update (was: Don't use / when applying sed with CFLAGS)
Thank you Fabian, Michał. Added note on Makefile and mentioned other
tools as well. Updated patch is in attachment.
--
Peter.
06-28-2011, 12:25 PM
Peter Volkov
demanual update (was: Don't use / when applying sed with CFLAGS)
Thank you Fabian, Michał. Added note on Makefile and mentioned other
tools as well. Updated patch is in attachment.
--
Peter.
06-28-2011, 04:23 PM
Mike Frysinger
demanual update (was: Don't use / when applying sed with CFLAGS)
On Tuesday, June 28, 2011 02:54:03 Michał Górny wrote:
> On Tue, 28 Jun 2011 10:16:06 +0400 Peter Volkov wrote:
> > But still our documentation explicitly suggests ':' for CFLAGS cases
> > and example allows bash substitution.
> >
> > http://devmanual.gentoo.org/ebuild-writing/functions/src_compile/building
> > /index.html see example in "Fixing Compiler Usage" section and text
> > below:
> > sed -i -e "s:cc -O2:$(tc-getCC) ${CFLAGS} ${LDFLAGS}:" build.sh
> >
> > Are there any objections to suggest '|' for CFLAGS, LDFLAGS (see
> > attachment)?
>
> I think that also a good idea may be to provide an Makefile example,
> showing that often sed is unnecessary, and it's enough to do things
> like:
>
> emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"...
this is easily dangerous when it comes to packages (and many do) that append
in the Makefile. specifying on the command line blocks those while passing
via env works fine. i'm not sure it's appropriate to provide as an example.
-mike
06-28-2011, 04:27 PM
Mike Frysinger
demanual update (was: Don't use / when applying sed with CFLAGS)
On Tuesday, June 28, 2011 08:25:50 Peter Volkov wrote:
> +Sometimes a package will not use the user's <c>${CFLAGS}</c> or
> +<c>${LDFLAGS}</c>.
there are more flag vars than this. you should use language like:
Sometimes a package will not use the user's build settings (such as CFLAGS or
LDFLAGS).
> - sed -i -e "s:cc -O2:$(tc-getCC) ${CFLAGS} ${LDFLAGS}:" build.sh
> + sed -i -e "s|cc -O2|$(tc-getCC) ${CFLAGS} ${LDFLAGS}|" build.sh
probably better to suggest delaying of the expansion in the first place.
sed -i -e "s|cc -O2|$(tc-getCC) ${CFLAGS} ${LDFLAGS}|" build.sh
also, your example ignores CPPFLAGS
-mike
06-28-2011, 06:24 PM
Peter Volkov
demanual update (was: Don't use / when applying sed with CFLAGS)
В Втр, 28/06/2011 в 12:23 -0400, Mike Frysinger пишет:
> On Tuesday, June 28, 2011 02:54:03 Michał Górny wrote:
> > emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"...
>
> this is easily dangerous when it comes to packages (and many do) that append
> in the Makefile. specifying on the command line blocks those while passing
> via env works fine. i'm not sure it's appropriate to provide as an example.
Hm, I'm not sure I understand what you are talking about here. Could you
provide example?
--
Peter.
06-28-2011, 07:04 PM
Nathan Phillip Brink
demanual update (was: Don't use / when applying sed with CFLAGS)
On Tue, Jun 28, 2011 at 10:24:26PM +0400, Peter Volkov wrote:
> ?? ??????, 28/06/2011 ?? 12:23 -0400, Mike Frysinger ??????????:
> > On Tuesday, June 28, 2011 02:54:03 Micha?? G??rny wrote:
> > > emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"...
> >
> > this is easily dangerous when it comes to packages (and many do) that append
> > in the Makefile. specifying on the command line blocks those while passing
> > via env works fine. i'm not sure it's appropriate to provide as an example.
>
> Hm, I'm not sure I understand what you are talking about here. Could you
> provide example?
but which would override the pkg-config flags if you do:
emake CFLAGS="${CFLAGS}"
--
binki
06-28-2011, 07:08 PM
Alexis Ballier
demanual update (was: Don't use / when applying sed with CFLAGS)
On Tue, 28 Jun 2011 22:24:26 +0400
Peter Volkov <pva@gentoo.org> wrote:
> В Втр, 28/06/2011 в 12:23 -0400, Mike Frysinger пишет:
> > On Tuesday, June 28, 2011 02:54:03 Michał Górny wrote:
> > > emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"...
> >
> > this is easily dangerous when it comes to packages (and many do)
> > that append in the Makefile. specifying on the command line blocks
> > those while passing via env works fine. i'm not sure it's
> > appropriate to provide as an example.
>
> Hm, I'm not sure I understand what you are talking about here. Could
> you provide example?
>
if the makefile contains something like CFLAGS+="-DMYFEATURE=1" then
'emake CFLAGS="blah"' overrides it but 'CFLAGS="blah" emake' doesnt.