{"action":"created","issue":{"url":"https://api.github.com/repos/waf-project/waf/issues/2151","repository_url":"https://api.github.com/repos/waf-project/waf","labels_url":"https://api.github.com/repos/waf-project/waf/issues/2151/labels{/name}","comments_url":"https://api.github.com/repos/waf-project/waf/issues/2151/comments","events_url":"https://api.github.com/repos/waf-project/waf/issues/2151/events","html_url":"https://github.com/waf-project/waf/issues/2151","id":314633690,"number":2151,"title":"Force ordering of static libraries","user":{"login":"ytimenkov","id":7413219,"avatar_url":"https://avatars3.githubusercontent.com/u/7413219?v=4","gravatar_id":"","url":"https://api.github.com/users/ytimenkov","html_url":"https://github.com/ytimenkov","followers_url":"https://api.github.com/users/ytimenkov/followers","following_url":"https://api.github.com/users/ytimenkov/following{/other_user}","gists_url":"https://api.github.com/users/ytimenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/ytimenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ytimenkov/subscriptions","organizations_url":"https://api.github.com/users/ytimenkov/orgs","repos_url":"https://api.github.com/users/ytimenkov/repos","events_url":"https://api.github.com/users/ytimenkov/events{/privacy}","received_events_url":"https://api.github.com/users/ytimenkov/received_events","type":"User","site_admin":false},"labels":[{"id":195504991,"url":"https://api.github.com/repos/waf-project/waf/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-16T12:43:17Z","updated_at":"2018-04-17T03:47:38Z","closed_at":null,"author_association":"NONE","body":"I'm trying to build a binary with Waf 2.0.7 with g++ and I can't find way to force waf to produce command line I want.\r\n\r\nI have a static library `A` which depends on `boost_program_options` (also static) and then it is consumed by binary.\r\n\r\nUnfortunately gcc (with some optimization flags) generates code so that \"vtable for boost::program_options::abstract_variables_map\" is defined in library `A` so when I link with `ld -lA -lboost_program_options` I get unresolved external from **`boost_program_options`**.\r\n\r\nThe solution (or workaround) is to link with `-lboost_program_options -lA` (and it works), but I can't force waf to produce such line without breaking dependency of `A` on `boost_program_options` which needs to be moved to every consumer of `A`.\r\n\r\nI know that `-Wl,--whole-archive` could help but I can't use it.\r\n\r\nIn a way it's a circular dependency A <- program_options <- A and I know CMake tries to resolve it by adding library A multiple times into linker command line, but I can't easily see such logic in waf."},"comment":{"url":"https://api.github.com/repos/waf-project/waf/issues/comments/381828101","html_url":"https://github.com/waf-project/waf/issues/2151#issuecomment-381828101","issue_url":"https://api.github.com/repos/waf-project/waf/issues/2151","id":381828101,"user":{"login":"ytimenkov","id":7413219,"avatar_url":"https://avatars3.githubusercontent.com/u/7413219?v=4","gravatar_id":"","url":"https://api.github.com/users/ytimenkov","html_url":"https://github.com/ytimenkov","followers_url":"https://api.github.com/users/ytimenkov/followers","following_url":"https://api.github.com/users/ytimenkov/following{/other_user}","gists_url":"https://api.github.com/users/ytimenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/ytimenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ytimenkov/subscriptions","organizations_url":"https://api.github.com/users/ytimenkov/orgs","repos_url":"https://api.github.com/users/ytimenkov/repos","events_url":"https://api.github.com/users/ytimenkov/events{/privacy}","received_events_url":"https://api.github.com/users/ytimenkov/received_events","type":"User","site_admin":false},"created_at":"2018-04-17T03:47:38Z","updated_at":"2018-04-17T03:47:38Z","author_association":"NONE","body":"@ita1024 Thanks for response! Let me try to clarify a bit:\r\n\r\n> Make sure that static libraries are always given in reverse order for ld\r\n\r\nThat is exactly my question. How can I enforce it in waf? As I understand it does topological sort of dependencies.\r\n\r\nI need something like\r\n```python\r\ndef build(ctx):\r\n    ctx.stlib(target=\"A\")\r\n    ctx.stlib(target=\"B\", use=\"A\")\r\n    ctx.program(target=\"C\", use=\"A B\")\r\n```\r\n\r\nto produce ld command: `-lB -lA -lB`. (so first 2 items are reversed, and the last one is forced).\r\n\r\nAs for `--start-group` solution I need to check performance overhead of it. This circular dependency is very localized and I don't want it to affect build time."}}
{"actor":{"display_login":"ytimenkov"}}