]> git.lizzy.rs Git - rust.git/commit
trans: Stop informing LLVM about dllexport
authorAlex Crichton <alex@alexcrichton.com>
Wed, 29 Jul 2015 00:19:08 +0000 (17:19 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 11 Aug 2015 01:20:42 +0000 (18:20 -0700)
commite648c96c5f9b69022ae416040cf0558221a11d77
tree9a00b0e642a2dfe823f6ed89f4bd18027079d39c
parent18607149fbb0836059a96981c78e10ca52d23cd5
trans: Stop informing LLVM about dllexport

Rust's current compilation model makes it impossible on Windows to generate one
object file with a complete and final set of dllexport annotations. This is
because when an object is generated the compiler doesn't actually know if it
will later be included in a dynamic library or not. The compiler works around
this today by flagging *everything* as dllexport, but this has the drawback of
exposing too much.

Thankfully there are alternate methods of specifying the exported surface area
of a dll on Windows, one of which is passing a `*.def` file to the linker which
lists all public symbols of the dynamic library. This commit removes all
locations that add `dllexport` to LLVM variables and instead dynamically
generates a `*.def` file which is passed to the linker. This file will include
all the public symbols of the current object file as well as all upstream
libraries, and the crucial aspect is that it's only used when generating a
dynamic library. When generating an executable this file isn't generated, so all
the symbols aren't exported from an executable.

To ensure that statically included native libraries are reexported correctly,
the previously added support for the `#[linked_from]` attribute is used to
determine the set of FFI symbols that are exported from a dynamic library, and
this is required to get the compiler to link correctly.
14 files changed:
mk/platform.mk
mk/target.mk
src/compiletest/procsrv.rs
src/librustc/metadata/common.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc_llvm/lib.rs
src/librustc_trans/back/link.rs
src/librustc_trans/back/linker.rs
src/librustc_trans/trans/base.rs
src/test/auxiliary/issue-25185-1.rs
src/test/compile-fail/feature-gate-linked-from.rs [new file with mode: 0644]
src/test/run-pass/variadic-ffi.rs