public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH RFC v2] change MAKE_TARGETS's dependency to normal prerequisites and order-only prerequisites
Date: Tue, 20 May 2014 15:05:15 +0200	[thread overview]
Message-ID: <20140520130515.GC28216@rei.suse.cz> (raw)
In-Reply-To: <537B4607.3030207@cn.fujitsu.com>

Hi!
> Here I met some issues. Could you please give me some hint and  currently I
> do not know how to fix it.
> 
> When I applied the v2 Patch and according to your comments,
> make "MAKE_NORMAL_DEPS        := $(LIBLTP) $(LSN_H)" in include/mk/testcases.mk.
> 
> For this rule "$(MAKE_TARGETS): $(MAKE_NORMAL_DEPS) | $(MAKE_ORDER_ONLY_DEPS)" in
> include/mk/generic_leaf_target.inc.
> 
> The implicit rule in Makefile will also make  "MAKE_NORMAL_DEPS" in the compile command.
> 
> For example:
> gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -g -O2 -Wold-style-definition -D_FORTIFY_SOURCE=2 -I/home/lege/extern_stroage/test/ltp-dev/testcases/kernel/include -I../../../../include -I../../../../include   -L../../../../lib  access05.c /home/lege/extern_stroage/test/ltp-dev/lib/libltp.a /home/lege/extern_stroage/test/ltp-dev/testcases/kernel/include/linux_syscall_numbers.h   -lltp -o access05
> 
> But before this patch,
> the command will be:
> gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -g -O2 -Wold-style-definition -D_FORTIFY_SOURCE=2 -I/home/lege/extern_stroage/test/ltp-dev/testcases/kernel/include -I../../../../include -I../../../../include   -L../../../../lib  access05.c   -lltp -o access05
> 
> How can I remove these "MAKE_NORMAL_DEPS" from the command. I googled this issue, but
> do not find any useful, thanks.

Well that is the problem with implicit rule that pulls in all the dependencies.

The problem is that Make is confused because we don't go the *.c + *.h
-> *.o -> binary route but take shortcut *.c -> binary instead.

If you look at the list of implicit rules (make --print-data-base) there is:

LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)

%: %.c
        $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@


So the final command used to link the testcase is:

$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@

If you get choose to use the .c -> .o rule instead it uses:

%.o: %.c:
        $(COMPILE.c) $(OUTPUT_OPTION) $<

Note the $< instead of $^. In this case only first dependency is passed to the
compiler.


One solution would be to override the build-in rule with our own:

% %.c:
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LOADLIBES) $(LDLIBS) -o $@

However there may be places that will break by this change.

Or we may do a big step forward and stop using the implicit rules complety and
write our own rules (which is what quite a lot of projects does). We can even
utilize the gcc -MM and generate all testcase dependencies automatically...

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

      parent reply	other threads:[~2014-05-20 13:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15  9:43 [LTP] [PATCH RFC v2] change MAKE_TARGETS's dependency to normal prerequisites and order-only prerequisites Xiaoguang Wang
2014-05-19 12:34 ` chrubis
     [not found]   ` <537B4607.3030207@cn.fujitsu.com>
2014-05-20 13:05     ` chrubis [this message]

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=20140520130515.GC28216@rei.suse.cz \
    --to=chrubis@suse.cz \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=wangxg.fnst@cn.fujitsu.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox