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

size issue of static library #169

Closed
lcwyylcwyy opened this issue Jul 22, 2016 · 5 comments
Closed

size issue of static library #169

lcwyylcwyy opened this issue Jul 22, 2016 · 5 comments
Labels

Comments

@lcwyylcwyy
Copy link

lcwyylcwyy commented Jul 22, 2016

I encounter an issue that
when I compile the my static library source with ndk-build V=1 ,
whether I use NDK_DEBUG=1 or 0,
the g++ alway has -g flag .

Because in every toolchain setup.mk ,
the TARGET_xxx_release_CFLAGS assignment has -g flag.

So my static library size become very large.
And I used objdump to check the .o file, It has many debug info.

How to delete the -g flag writen in setup.mk through Android.mk or Application.mk

@amartinz
Copy link

As workaround, you can specify -g0.

Taken from man gcc

Level 0 produces no debug information at all.
Thus, -g0 negates -g.

@DanAlbert
Copy link
Member

The size of a static library is irrelevant though since it isn't a part of an app. When the library gets linked into a shared library or executable, ndk-build runs strip on the output which removes all the debug info.

@lcwyylcwyy
Copy link
Author

lcwyylcwyy commented Jul 22, 2016

Thank you very much ! @Evisceration . I walk around it!

@DanAlbert Thanks a lot for your answer! I know the strip function. But if my team distribute our libs to other company, I must add -g0 flag in release version. We can not control it through NDK_DEBUG=0 that we hope to.

@vltmrkls
Copy link

vltmrkls commented Mar 12, 2021

I had to deal with the same issue... (onnxruntime)

this worked for me:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0")

@DanAlbert
Copy link
Member

(saw your comment on the other thread, but repeating a bit here for those that didn't)

If you care about the size of your static libraries (for distribution, CI artifact bills, etc) and don't care about debugging, disabling debug info will save a lot, yeah. I don't think the compilers are generally are very concerned with keeping down the size of static libraries since they're intermediate artifacts, so YMMV.

It does mean you won't be able to debug though.

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

No branches or pull requests

4 participants