{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/1296","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1296/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1296/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1296/events","html_url":"https://github.com/rust-lang/rfcs/pull/1296","id":108366653,"number":1296,"title":"RFC: Add an `alias` attribute to #[link] and -l","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/final-comment-period","name":"final-comment-period","color":"207de5"},{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/T-lang","name":"T-lang","color":"bfd4f2"},{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/T-tools","name":"T-tools","color":"bfd4f2"}],"state":"open","locked":false,"assignee":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"milestone":null,"comments":18,"created_at":"2015-09-25T17:02:55Z","updated_at":"2015-11-18T17:48:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1296","html_url":"https://github.com/rust-lang/rfcs/pull/1296","diff_url":"https://github.com/rust-lang/rfcs/pull/1296.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/1296.patch"},"body":"Add a new `alias` attribute to `#[link]` and the `-l` flag which indicates that\r\nthe linkage will happen through another annotation to inform how a library is\r\nlinked. This is then leverage to inform the compiler about dllimport and\r\ndllexport with respect to native libraries on the MSVC platform.\r\n\r\n[Rendered](https://github.com/alexcrichton/rfcs/blob/link-alias/text/0000-link-alias.md)"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/157798025","html_url":"https://github.com/rust-lang/rfcs/pull/1296#issuecomment-157798025","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1296","id":157798025,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T17:48:52Z","updated_at":"2015-11-18T17:48:52Z","body":"@retep998 \r\n\r\nOK, I just wanted to drill into one other thing a bit more. The scenario that you are [describing here](https://internals.rust-lang.org/t/meaning-of-link-kinds/2686/4?u=nikomatsakis), and which you later summarized as example #2, is (iiuc) as follows:\r\n\r\n1. you have a `.lib` file with some static symbols.\r\n2. you have a Rust library linking against this `.lib` file and being compiled into a DLL.\r\n3. you do **not** want to \"bundle\" the `.lib` into this DLL, meaning to statically link the code in there.\r\n\r\nThis is where I get a bit confused. If the code is not compiled into the DLL, it seems to me it must be *dynamically* linked. And in that case, it seems like we must tell the EXE that we need them to dynamically link this dependency. So perhaps I am confused? Or perhaps my mental model of how linking works is too simplistic?\r\n\r\nYou then go on to say:\r\n\r\n5. notice that bundling foo into the .rlib is not the solution, the real solution is simply making sure foo is only passed to a single linker invocation and re-exported for use by the other binaries\r\n\r\nI do not understand what this \"re-exported\" means. It sounds to me like you ARE bundling the code of `foo` (the static, native library) into the DLL, and then you are expecting other consumers to draw the code from the DLL somehow. But why are they invoking the `foo` code directly anyway? Is it because the Rust DLL is exporting the native functions directly? Or is it because the EXE file is independently trying to use `foo`?\r\n\r\nI am guessing you have a very specific scenario in mind -- e.g., perhaps your crate that re-exports windows APIs? Can you spell it out a bit more so I understand?"}}