Re: [PATCH for review] [67/145] x86_64: Detect CFI support in the assembler at runtime

Sam Ravnborg
2006-08-11T15:17:04Z

On Fri, Aug 11, 2006 at 07:55:58AM +0200, Andi Kleen wrote:
> On Friday 11 August 2006 07:39, Sam Ravnborg wrote:
> > > +# as-instr
> > > +# Usage: cflags-y += $(call as-instr, instr, option1, option2)
> > > +
> > > +as-instr = $(shell if echo -e "$(1)" | $(AS) -Z -o /dev/null \
> > > + 2>&1 >/dev/null ; then echo "$(2)"; else echo "$(3)"; fi;)
> >
> > Have you checked that as will not delete yout /dev/null if you build as
> > root? ld do so if you specify /dev/null as output file.
>
> No. But it's probably safter to do it otherwise. Do you have an alternative?

ld-option uses this:
# ld-option
# Usage: ldflags += $(call ld-option, -Wl$(comma)--hash-style=both)
ld-option = $(shell if $(CC) $(1) \
-nostdlib -o ldtest$$$$.out -xc /dev/null \
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi; \
rm -f ldtest$$$$.out)

$$$$ becomes $$ when executed.

I have no better alternatives - except maybe for mktemp.

Sam