Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why use ARCHIVE_START and ARCHIVE_END in Fluid #9736

Closed
wangkuiyi opened this issue Apr 8, 2018 · 4 comments · Fixed by #9844
Closed

Why use ARCHIVE_START and ARCHIVE_END in Fluid #9736

wangkuiyi opened this issue Apr 8, 2018 · 4 comments · Fixed by #9844
Assignees

Comments

@wangkuiyi
Copy link
Collaborator

In paddle/fluid/inference/*, there are two uses of ARCHIVE_START and ARCHIVE_END:

  1. DEPS ARCHIVE_START ${GLOB_OP_LIB} ${FLUID_CORE_MODULES} ARCHIVE_END)

  2. DEPS ARCHIVE_START paddle_fluid ARCHIVE_END

ARCHIVE_START and ARCHIVE_END are not part of cmake/generic.cmake, thus is not supposed to be used in Fluid. Why do we need them in paddle/fluid/inference?

@wangkuiyi
Copy link
Collaborator Author

wangkuiyi commented Apr 8, 2018

I am suffering from this problem: #9071 (comment)

@Xreki
Copy link
Contributor

Xreki commented Apr 8, 2018

ARCHIVE_START and ARCHIVE_END is defined in https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/util.cmake#L8. It is a couple of flags needed by the linker ld. The usage is different for gcc and clang.

  • For gcc, you should use gcc -shared -o libab.so -Wl,--whole-archive liba.a -Wl,--no-whole-archive libb.a

For the effect of -Wl,--whole-archive, you can refer to https://blog.csdn.net/Aquester/article/details/49800237. Without this linking flags, user codes for inference will fail by the error: operators xxx is not registered.

It is also used in caffe2:

https://github.com/caffe2/caffe2/blob/0dd3284525079f3870df92f61bed3b94eb45ff53/cmake/public/utils.cmake#L12-L24

@wangkuiyi
Copy link
Collaborator Author

I know the purpose of -Wl,--whole-archive. I am afraid that it would prevent us from building a binary (maybe a shared object file) which contains only the operators in use?

Anyway, I see that we have the USE_OP mechanism with Fluid:

I suppose that USE_OP would make us no longer need -Wl,--whole-archive, would it?

@Xreki
Copy link
Contributor

Xreki commented Apr 10, 2018

I think you are right, I'll try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants