{"action":"created","issue":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/1594","repository_url":"https://api.github.com/repos/ldc-developers/ldc","labels_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1594/labels{/name}","comments_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1594/comments","events_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1594/events","html_url":"https://github.com/ldc-developers/ldc/pull/1594","id":162790612,"number":1594,"title":"[WIP] cmake: Directly use (g)cc for linking on Unix-like systems","user":{"login":"klickverbot","id":19335,"avatar_url":"https://avatars.githubusercontent.com/u/19335?v=3","gravatar_id":"","url":"https://api.github.com/users/klickverbot","html_url":"https://github.com/klickverbot","followers_url":"https://api.github.com/users/klickverbot/followers","following_url":"https://api.github.com/users/klickverbot/following{/other_user}","gists_url":"https://api.github.com/users/klickverbot/gists{/gist_id}","starred_url":"https://api.github.com/users/klickverbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klickverbot/subscriptions","organizations_url":"https://api.github.com/users/klickverbot/orgs","repos_url":"https://api.github.com/users/klickverbot/repos","events_url":"https://api.github.com/users/klickverbot/events{/privacy}","received_events_url":"https://api.github.com/users/klickverbot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-06-28T21:22:07Z","updated_at":"2016-06-28T21:42:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ldc-developers/ldc/pulls/1594","html_url":"https://github.com/ldc-developers/ldc/pull/1594","diff_url":"https://github.com/ldc-developers/ldc/pull/1594.diff","patch_url":"https://github.com/ldc-developers/ldc/pull/1594.patch"},"body":"Currently, we are translating the linker flags for LLVM/libconfig and from `CMAKE_EXE_LINKER_FLAGS` into `-L` options. Since DMD/LDC prefix `-L` options by `-Xlinker` before passing them to the GCC driver (causing the latter to forward it directly to the underlying `ld`), this does not work in the general case, causing issues such as #1494.\r\n\r\nIn https://github.com/ldc-developers/ldc/pull/1468, a few driver-only flags were special-cased in LDC, so that `-Xlinker` is not applied to them. However, I don't think this is a viable strategy in the long run. First of all, there are quite a few more options which are supposed to be passed to the linker driver instead of the linker. But rather more importantly, this only works with an LDC version that contains this fix, and not DMD.\r\n\r\nThus, we need a solution that works on the build-system level. One possibility would be to white-list flags we know how to handle in the CMake scripts (e.g. all of them starting with `-Xlinker` or `-Wl,…`, where we can just strip off the prefix and pass them to the D compiler using `-L`), and just ignore all the others. However, for some common use cases, we do want to pass flags to the linker driver, such as to link against a static C++ standard library when building binary releases.\r\n\r\nSince there is no DMD flag for passing flags to the linker driver (we could of course add one in the next LDC version, but this wouldn't help with DMD or older versions), this PR changes the build system to again use the system linker directly from CMake instead of going through the D compiler for linking. Compared to @JohanEngelen's earlier version (sorry!), this now parses the `-v` output to determine the default linker flags used internally by the D compiler instead of trying to guess them.\r\n\r\nFixes #1494, #1544.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/comments/229193100","html_url":"https://github.com/ldc-developers/ldc/pull/1594#issuecomment-229193100","issue_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1594","id":229193100,"user":{"login":"JohanEngelen","id":10983051,"avatar_url":"https://avatars.githubusercontent.com/u/10983051?v=3","gravatar_id":"","url":"https://api.github.com/users/JohanEngelen","html_url":"https://github.com/JohanEngelen","followers_url":"https://api.github.com/users/JohanEngelen/followers","following_url":"https://api.github.com/users/JohanEngelen/following{/other_user}","gists_url":"https://api.github.com/users/JohanEngelen/gists{/gist_id}","starred_url":"https://api.github.com/users/JohanEngelen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohanEngelen/subscriptions","organizations_url":"https://api.github.com/users/JohanEngelen/orgs","repos_url":"https://api.github.com/users/JohanEngelen/repos","events_url":"https://api.github.com/users/JohanEngelen/events{/privacy}","received_events_url":"https://api.github.com/users/JohanEngelen/received_events","type":"User","site_admin":false},"created_at":"2016-06-28T21:42:37Z","updated_at":"2016-06-28T21:42:37Z","body":"This could actually speed-up re-builds quite a bit when the D-source hasn't changed! :-)"}}
{"actor":{"display_login":"JohanEngelen"}}