mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH v9] Build process uses script to add CFI directives to x86 asm
Date: Sat, 20 Jun 2015 17:11:44 -0400	[thread overview]
Message-ID: <20150620211144.GA1173@brightrain.aerifal.cx> (raw)
In-Reply-To: <1434350700-15346-1-git-send-email-alexinbeijing@gmail.com>

On Mon, Jun 15, 2015 at 08:45:00AM +0200, Alex Dowad wrote:
> diff --git a/Makefile b/Makefile
> index 2eb7b30..b4927f4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -120,7 +120,11 @@ $(foreach s,$(wildcard src/*/$(ARCH)*/*.s),$(eval $(call mkasmdep,$(s))))
>  	$(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $(dir $<)$(shell cat $<)
>  
>  %.o: $(ARCH)/%.s
> +ifeq ($(ADD_CFI),yes)
> +	LC_ALL=C awk -f tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL_STATIC) -x assembler -c -o $@ -
> +else
>  	$(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $<
> +endif
>  
>  %.o: %.c $(GENH) $(IMPH)
>  	$(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $<
> @@ -129,7 +133,11 @@ $(foreach s,$(wildcard src/*/$(ARCH)*/*.s),$(eval $(call mkasmdep,$(s))))
>  	$(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $(dir $<)$(shell cat $<)
>  
>  %.lo: $(ARCH)/%.s
> +ifeq ($(ADD_CFI),yes)
> +	LC_ALL=C awk -f tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL_SHARED) -x assembler -c -o $@ -
> +else
>  	$(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $<
> +endif
>  
>  %.lo: %.c $(GENH) $(IMPH)
>  	$(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $<

I think someone mentioned this before -- this still fails to apply CFI
to the asm files obtained via the .sub/SUBARCH system (see the rules
just above the ones you changed). Of course I don't really like
duplicating complex rules, and i386 has no SUBARCHs anyway, so perhaps
we could put off changing this if someone has an idea for how to
eliminate the extra rules for SUBARCHs when we overhaul the build
system...

Alternatively we could perhaps just put the command for asm files in a
makefile variable and set it conditionally depending on ADD_CFI. Then
it could be reused in each place.

> diff --git a/configure b/configure
> index 7b29ae4..a55acd6 100755
> --- a/configure
> +++ b/configure
> @@ -327,6 +327,22 @@ tryflag CFLAGS_MEMOPS -fno-tree-loop-distribute-patterns
>  test "$debug" = yes && CFLAGS_AUTO=-g
>  
>  #
> +# Preprocess asm files to add extra debugging information if debug is
> +# enabled, our assembler supports the needed directives, and the
> +# preprocessing script has been written for our architecture.
> +#
> +printf "checking whether we should preprocess assembly to add debugging information... "
> +if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO" &&
> +   test -f "tools/add-cfi.$ARCH.awk" &&
> +   printf ".file 1 \"srcfile.s\"\n.line 1\n.cfi_startproc\n.cfi_endproc" | $CC -g -x assembler -c -o /dev/null 2>/dev/null -
> +then
> +  ADD_CFI=yes
> +else
> +  ADD_CFI=no
> +fi
> +printf "%s\n" "$ADD_CFI"
> +
> +#

I'd still like to check $CFLAGS in addition to $CFLAGS_AUTO, since
CFLAGS=-g is the usual way I ask for debug info. (I'm sorry I ever
added the --enable-debug option to configure. :)

I haven't reviewed the awk script much at all, but as long as it seems
to work in practice I'm okay with committing it. One thing I would
like to ask though -- is it pretty robust against bad things happening
if it sees new asm constructs it's not expecting? I'd just like to
avoid regressions if we add new asm later, where it becomes necessary
to delay commits to asm in order to fix bugs in the CFI generation.

Rich


  reply	other threads:[~2015-06-20 21:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15  6:45 Alex Dowad
2015-06-20 21:11 ` Rich Felker [this message]
2015-06-21  5:00   ` Alex
2015-06-21  5:05     ` Rich Felker
2015-06-23 19:18 Alex Dowad
2015-06-23 21:52 ` Rich Felker
2015-06-24  5:33   ` Alex
2015-06-28  2:58     ` Rich Felker
2015-07-08 14:16     ` Rich Felker
2015-07-08 14:25       ` Alex
2015-07-09  5:00         ` Rich Felker
2015-07-07  3:39 ` Rich Felker
2015-07-07  5:45   ` Alex
2015-07-07 13:21     ` Rich Felker
2015-07-07 16:40       ` Alex
2015-07-07 18:15         ` Rich Felker
2015-07-07 18:27           ` Alex
     [not found]             ` <20150708023638.GJ1173@brightrain.aerifal.cx>
2015-07-08  7:13               ` Alex
2015-07-08  7:54                 ` Alex
2015-07-08 14:11                   ` Rich Felker
2015-07-08 14:24                     ` Alex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150620211144.GA1173@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).