https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68902
Bug ID: 68902 Summary: --as-needed consider library as unneeded even when library have __init functions Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: socketpair at gmail dot com Target Milestone: --- Original bug was reported here: https://github.com/thom311/libnl/issues/93 libnl3 have such function: static void __init ct_init(void) { nl_cache_mngt_register(&nfnl_ct_ops); } so, when this library is loaded it register itself in some global variable for later access. When I link against that library, my program does not see that registration since library just is not linked! I consider gcc should not eliminate lbraries where __init functions exists.