mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Each Rust source file given to a target is considered a separate crate root. There's a concept of a "main crate root", which is the `.rs` file that is given to the final linker phase in CMake. Other Rust source file in a target are built as rlib separately. The project can still build `.rs` files into object files by setting the Rust_EMIT property on the desired source file.
40 lines
1.4 KiB
ReStructuredText
40 lines
1.4 KiB
ReStructuredText
Rust_EMIT
|
|
---------
|
|
|
|
.. versionadded:: 4.4
|
|
|
|
.. note::
|
|
Experimental. Gated by ``CMAKE_EXPERIMENTAL_RUST``.
|
|
|
|
This property controls the type of output generated by the Rust compiler. Can
|
|
be one of several values:
|
|
|
|
``link``
|
|
This is the default if the property is not set. The crate will be compiled
|
|
into an `rlib` file, e.g.: ``libfile.rs.rlib``
|
|
|
|
.. note::
|
|
CMake will automatically prefix the generated ``rlib`` file
|
|
with ``lib`` as the Rust compiler always requires such a
|
|
prefix for external crates.
|
|
|
|
``obj``
|
|
Generate a native object file, e.g.: ``file.rs.o``
|
|
|
|
``asm``
|
|
Generate an assembly file, e.g.: ``file.rs.s``
|
|
|
|
.. note::
|
|
The ``obj`` and ``asm`` output types are known to have the following
|
|
limitations:
|
|
|
|
* When enabled, the Rust compiler disables multiple codegen units and
|
|
ThinLTO. Depending on the situation, this can affect the generated code,
|
|
optimizations. It also reduce the internal parallelism inside and the
|
|
compiler and can reduce the effectiveness of incremental rebuilds.
|
|
* The generated ``obj`` files cannot be used as external crates, so other
|
|
Rust code can only use C-style API from them.
|
|
* The generated ``obj`` files cannot be linked as-is with native linkers,
|
|
additional crates from the Rust toolchain needs to linked too. The actual
|
|
crates to link depend on the code and compiler options.
|