From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7684 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Build process uses script to add CFI directives to x86 asm Date: Mon, 18 May 2015 15:34:40 +0200 Message-ID: <20150518133440.GE11258@port70.net> References: <1431784471-24517-1-git-send-email-alexinbeijing@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1431956099 22416 80.91.229.3 (18 May 2015 13:34:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 May 2015 13:34:59 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7696-gllmg-musl=m.gmane.org@lists.openwall.com Mon May 18 15:34:55 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YuLC2-0001gs-C8 for gllmg-musl@m.gmane.org; Mon, 18 May 2015 15:34:54 +0200 Original-Received: (qmail 29886 invoked by uid 550); 18 May 2015 13:34:52 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 29868 invoked from network); 18 May 2015 13:34:52 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <1431784471-24517-1-git-send-email-alexinbeijing@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:7684 Archived-At: * Alex Dowad [2015-05-16 15:54:31 +0200]: > > configure script now checks whether debugging is enabled, whether the assembler > understands CFI directives, whether it understands '-x assembler', and whether > there the AWK script is present for the current arch. > > aswrap.sh is gone -- the problem is that the arguments it wants (and the order it > wants them in) is different from $(CC). So it's hard to use an AS_CMD variable > as suggested by RF to run whichever command is appropriate. > > Suggestions from shell/Makefile scripting wizards on how to do this better > are appreciated! > it is possible to parse the options but not trivial may be have the arguments in an order that's good for the wrapper > The processed asm now contains .file and .loc directives, so when you debug it in > GDB, it will show you the original source file, and highlight the correct lines. > nice > I haven't tested with busybox awk yet, just with GNU awk. If there are no further > issues with the code, I will do that next. > i see one issue: \s, \w may not be supported (eg mawk does not have them nor [[:space:]] char classes) > > Makefile | 10 ++- > configure | 13 ++++ > tools/add-cfi.awk.i386 | 207 +++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 229 insertions(+), 1 deletion(-) > create mode 100644 tools/add-cfi.awk.i386 > > diff --git a/Makefile b/Makefile > index 6559295..6f17cc7 100644 > --- a/Makefile > +++ b/Makefile > @@ -118,7 +118,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.awk.$(ARCH) $< | $(CC) $(CFLAGS_ALL_STATIC) -x assembler -c -o $@ - > +else > $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $< > +endif > this may work, with a reasonably simple aswrap script: %.o: $(ARCH)/%.s $(ASWRAP) $(ARCH) $< $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ i don't know which approach is less ugly. the %.sub rules should be handled too.. > diff --git a/configure b/configure > index 143dc92..72349a2 100755 > --- a/configure > +++ b/configure > @@ -317,6 +317,18 @@ 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. > +# > +if (test "$debug" = yes) && > + (test -f "tools/add-cfi.awk.$ARCH") && > + (echo ".cfi_startproc\n.cfi_endproc" | $CC -x assembler -c -o /dev/null -) > +then > + ADD_CFI=yes > +fi > + else ADD_CFI=no (otherwise an ADD_CFI env var may influence configure behaviour) > +# > # Possibly add a -O option to CFLAGS and select modules to optimize with > # -O3 based on the status of --enable-optimize and provided CFLAGS. > # > @@ -570,6 +582,7 @@ LDFLAGS = $LDFLAGS_AUTO $LDFLAGS > CROSS_COMPILE = $CROSS_COMPILE > LIBCC = $LIBCC > OPTIMIZE_GLOBS = $OPTIMIZE_GLOBS > +ADD_CFI = $ADD_CFI > EOF > test "x$static" = xno && echo "STATIC_LIBS =" > test "x$shared" = xno && echo "SHARED_LIBS ="