[LTP] [PATCH] cleanup: avoid to generate many redundant obj files
Xiao Yang
ice_yangxiao@163.com
Wed Feb 19 14:07:57 CET 2020
On 2/19/20 8:20 PM, Li Wang wrote:
> Hi Xiao,
>
> Why don't you avoid libftest.o as well if you want to build test
> by new rule?
>
>
> That should be generated because it is the local library. In LTP
> Makefile, the sequencing is to build the library first then
> compile&link to the testcase. We can avoid dumping the testname.o
> since it only exists in the last phase.
Hi Li,
Thanks for your detailed explanation.
I think you try to change the building rule, as below:
Previous rule: generate all object files and then link them at the last
phase.
---------------------------------------------
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W
-Wold-style-definition -D_FORTIFY_SOURCE=2
-I/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-I../../../../include -I../../../../include -I../../../../include/old/
-c -o swapoff01.o swapoff01.c
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W
-Wold-style-definition -D_FORTIFY_SOURCE=2
-I/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-I../../../../include -I../../../../include -I../../../../include/old/
-c -o ../swapon/libswapon.o ../swapon/libswapon.c
gcc -L/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-L../../../../lib swapoff01.o ../swapon/libswapon.o -lltp -o swapoff01
---------------------------------------------
Current rule: just generate some common object files(e.g. library) and
then mix building and link at the last phase.
---------------------------------------------
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W
-Wold-style-definition -D_FORTIFY_SOURCE=2
-I/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-I../../../../include -I../../../../include -I../../../../include/old/
-c -o ../swapon/libswapon.o ../swapon/libswapon.c
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W
-Wold-style-definition -D_FORTIFY_SOURCE=2
-I/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-I../../../../include -I../../../../include -I../../../../include/old/
-L/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-L../../../../lib swapoff01.c ../swapon/libswapon.o -lltp -o swapoff01
---------------------------------------------
Why don't you remove all object files and mix building and link at the
last phase?
---------------------------------------------
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W
-Wold-style-definition -D_FORTIFY_SOURCE=2
-I/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-I../../../../include -I../../../../include -I../../../../include/old/
-L/root/ltp/testcases/kernel/syscalls/swapoff/../swapon/
-L../../../../lib swapoff01.c ../swapon/libswapon.c -lltp -o swapoff01
---------------------------------------------
>
> And, I don't want to change too much for LTP build rule(I think it
> works correctly), especially in the case directory some of the local
> libraries are reused. e.g The swapoff test needs linking to
> ../swapon/libswapon.o, that requires libswapon.o is in the correct path.
You can build and link libswapon.c directly, as below:
---------------------------------
# grep MAKE_TARGETS Makefile
$(MAKE_TARGETS): %: ../swapon/libswapon.c
---------------------------------
Sorry, I am not sure if your improvement is the best way.
Thanks,
Xiao Yang
>
> Or, did I misunderstand your words? if yes, please correct me.
>
> --
> Regards,
> Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200219/6a4c8f15/attachment-0001.htm>
More information about the ltp
mailing list