Skip to content

[cmake治理]删除paddle_test多余无用依赖 #60013

Closed

Description

@risemeup1

问题描述 Please describe your issue

一、需求背景

飞桨正在优化cmake代码,来减少编译时候的开发成本,目前paddle编译c++单测有多种方式,如cc_test_old(link静态库),cc_test(windows下link静态库,linux下link paddle.so),paddle_test(windows和linux下都link动态库paddle.so),现在推荐使用paddle_test,好处在于:

  1. link动态库无需手动加过多的依赖,大部分符号在paddle.so中已存在;
  2. link libpaddle.so可以大幅度减小C++单测的体积 ,从而减少build目录体积大小

二、存在的问题

paddle仓库中大概有50个使用paddle_test的代码,有一部分后面加了额外不需要的依赖,需要删除,如test/cpp/pir/shape_dialect/CMakeLists.txt中shape_struct_test单测依赖了gtest,实际上是额外的依赖,应该删掉。

三、建议步骤

1 在linux下,将paddle_test DEPS依赖全部删掉编译,如果遇到找不到一些符号,再加上必要的依赖
2 linux下报错解决后,windows下可能也会遇到一些编译问题

四、任务划分

序号 目录 认领人/状态/PR号
1 paddle/fluid/inference/utils/CMakeLists.txt @Liyulingyue
2 test/cpp/auto_parallel/CMakeLists.txt @zade23 #60274 #60348
3 test/cpp/eager/performance_tests/CMakeLists.txt @BeingGod
4 test/cpp/fluid/CMakeLists.txt @DrRyanHuang #60160
5 test/cpp/fluid/cinn/CMakeLists.txt @ccsuzzh #60235
6 test/cpp/fluid/framework/CMakeLists.txt @RedContritio
7 test/cpp/fluid/framework/details/CMakeLists.txt @RedContritio
8 test/cpp/fluid/lite/CMakeLists.txt @ccsuzzh
9 test/cpp/fluid/pscore/CMakeLists.txt @xiaoyewww #60240
10 test/cpp/pir/cinn/CMakeLists.txt @zrr1999 #60239
11 test/cpp/pir/cinn/adt/CMakeLists.txt @zrr1999
@Liyulingyue #60154
12 test/cpp/pir/core/CMakeLists.txt @DrRyanHuang #60161
13 test/cpp/pir/shape_dialect/CMakeLists.txt @sanbuphy
@Liyulingyue #60517
14 test/cpp/pir/sub_graph/CMakeLists.txt @DrRyanHuang
@xiaoyewww #60087
15 test/cpp/prim/CMakeLists.txt @enkilee
@Liyulingyue #60149

认领方式

请大家以 comment 的形式认领任务,如:

【报名】:1、3、12-13

多个任务之间需要使用中文顿号分隔,报名多个连续任务可用横线表示,如 2-5
PR 提交格式:在 PR 的标题中以 【CMake opt】 开头,注明任务编号

看板信息

任务方向 任务数量 提交作品 / 任务认领 提交率 完成 完成率
快乐开源 15 10 / 15 66.67% 10 66.67%

统计信息

排名不分先后 @zade23 (1) @DrRyanHuang (2) @ccsuzzh (1) @xiaoyewww (2) @zrr1999 (1) @Liyulingyue (3)

Activity

  1. Liyulingyue commented on Dec 14, 2023

    @Liyulingyue
    Collaborator

    【报名】:1

  2. DrRyanHuang commented on Dec 14, 2023

    @DrRyanHuang
    Collaborator

    【报名】:4、12、14

  3. zrr1999 commented on Dec 14, 2023

    @zrr1999
    Member

    【报名】:10、11

  4. RedContritio commented on Dec 14, 2023

    @RedContritio
    Contributor

    【报名】:6、7

  5. zade23 commented on Dec 14, 2023

    @zade23
    Contributor

    【报名】:2

  6. 3 remaining items

  7. ccsuzzh commented on Dec 14, 2023

    @ccsuzzh
    Contributor

    【报名】:5、8

  8. xiaoyewww commented on Dec 15, 2023

    @xiaoyewww
    Contributor

    【报名】:9、14

  9. Liyulingyue commented on Dec 19, 2023

    @Liyulingyue
    Collaborator

    Task No. 1 Finished. Nothing needs to delete.

    The error log when delete the only DEPS, benchmark:

    [ 85%] Built target test_mkldnn_cpu_quantize_pass
    /usr/local/bin/ld: CMakeFiles/test_benchmark.dir/benchmark_tester.cc.o: in function `Benchmark_basic_Test::TestBody()':
    benchmark_tester.cc:(.text._ZN20Benchmark_basic_Test8TestBodyEv+0xc8): undefined reference to `paddle::inference::Benchmark::SerializeToString[abi:cxx11]() const'
    /usr/local/bin/ld: CMakeFiles/test_benchmark.dir/benchmark_tester.cc.o: in function `Benchmark_PersistToFile_Test::TestBody()':
    benchmark_tester.cc:(.text._ZN28Benchmark_PersistToFile_Test8TestBodyEv+0xae): undefined reference to `paddle::inference::Benchmark::PersistToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
    /usr/local/bin/ld: benchmark_tester.cc:(.text._ZN28Benchmark_PersistToFile_Test8TestBodyEv+0xea): undefined reference to `paddle::inference::Benchmark::PersistToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
    /usr/local/bin/ld: benchmark_tester.cc:(.text._ZN28Benchmark_PersistToFile_Test8TestBodyEv+0x126): undefined reference to `paddle::inference::Benchmark::PersistToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
    collect2: error: ld returned 1 exit status
    paddle/fluid/inference/utils/CMakeFiles/test_benchmark.dir/build.make:113: recipe for target 'paddle/fluid/inference/utils/test_benchmark' failed
    make[2]: *** [paddle/fluid/inference/utils/test_benchmark] Error 1
    CMakeFiles/Makefile2:95109: recipe for target 'paddle/fluid/inference/utils/CMakeFiles/test_benchmark.dir/all' failed
    make[1]: *** [paddle/fluid/inference/utils/CMakeFiles/test_benchmark.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    
  10. risemeup1 commented on Dec 19, 2023

    @risemeup1
    CollaboratorAuthor

    Task No. 1 Finished. Nothing needs to delete.

    The error log when delete the only DEPS, benchmark:

    [ 85%] Built target test_mkldnn_cpu_quantize_pass
    /usr/local/bin/ld: CMakeFiles/test_benchmark.dir/benchmark_tester.cc.o: in function `Benchmark_basic_Test::TestBody()':
    benchmark_tester.cc:(.text._ZN20Benchmark_basic_Test8TestBodyEv+0xc8): undefined reference to `paddle::inference::Benchmark::SerializeToString[abi:cxx11]() const'
    /usr/local/bin/ld: CMakeFiles/test_benchmark.dir/benchmark_tester.cc.o: in function `Benchmark_PersistToFile_Test::TestBody()':
    benchmark_tester.cc:(.text._ZN28Benchmark_PersistToFile_Test8TestBodyEv+0xae): undefined reference to `paddle::inference::Benchmark::PersistToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
    /usr/local/bin/ld: benchmark_tester.cc:(.text._ZN28Benchmark_PersistToFile_Test8TestBodyEv+0xea): undefined reference to `paddle::inference::Benchmark::PersistToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
    /usr/local/bin/ld: benchmark_tester.cc:(.text._ZN28Benchmark_PersistToFile_Test8TestBodyEv+0x126): undefined reference to `paddle::inference::Benchmark::PersistToFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
    collect2: error: ld returned 1 exit status
    paddle/fluid/inference/utils/CMakeFiles/test_benchmark.dir/build.make:113: recipe for target 'paddle/fluid/inference/utils/test_benchmark' failed
    make[2]: *** [paddle/fluid/inference/utils/test_benchmark] Error 1
    CMakeFiles/Makefile2:95109: recipe for target 'paddle/fluid/inference/utils/CMakeFiles/test_benchmark.dir/all' failed
    make[1]: *** [paddle/fluid/inference/utils/CMakeFiles/test_benchmark.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    

    好的,那就不删除

  11. BeingGod commented on Dec 21, 2023

    @BeingGod
    Contributor

    Task NO.3 的common已经在 #60149 删除。

  12. ccsuzzh commented on Dec 21, 2023

    @ccsuzzh
    Contributor

    Task NO.8 的common已经在 #60149 删除。

  13. RedContritio commented on Dec 25, 2023

    @RedContritio
    Contributor

    Task 6 已在 #60149 解决
    Task 7 已在 #59995 解决

  14. luotao1 commented on Jan 3, 2024

    @luotao1
    Collaborator

    [cmake治理]删除paddle_test多余无用依赖 已全部完成,感谢参与的小伙伴们!

    @zade23 (1) @DrRyanHuang (2) @ccsuzzh (1) @xiaoyewww (2) @zrr1999 (1) @Liyulingyue (3) @BeingGod @RedContritio

    欢迎继续参与快乐开源的其他任务!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions