diff --git a/program/Cargo.toml b/program/Cargo.toml index a8f8e271d..9c57fdbdc 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -127,7 +127,7 @@ all-features = true rustdoc-args = ["--cfg=docsrs"] [lib] -crate-type = ["cdylib", "rlib"] +crate-type = ["rlib"] [features] default = ["borsh"] diff --git a/program/src/lib.rs b/program/src/lib.rs index 6f5e36beb..012c8eb4b 100644 --- a/program/src/lib.rs +++ b/program/src/lib.rs @@ -94,16 +94,21 @@ //! //! ```toml //! [lib] -//! crate-type = ["cdylib", "rlib"] +//! crate-type = ["cdylib"] //! //! [features] //! no-entrypoint = [] //! ``` //! -//! Note that a Solana program must specify its crate-type as "cdylib", and -//! "cdylib" crates will automatically be discovered and built by the `cargo -//! build-bpf` command. Solana programs also often have crate-type "rlib" so -//! they can be linked to other Rust crates. +//! Note that a Solana program must specify its crate-type as "cdylib", to +//! be discovered and built by the `cargo-build-sbf` command as a deployable program. +//! Solana programs also often have crate-type "rlib" so they can be linked to other Rust crates. +//! Avoid using "rlib" and "cdylib" crates together, since their combined usage precludes +//! compiler optimizations that may decrease program size and CU usage. +//! +//! Prefer writing a separate package if it is supposed to be used as a library for other Solana +//! programs (i.e. a "rlib" only crate). When created a Rust project intended to be a program +//! ready for deployment, ues only the "cdylib" crate type. //! //! # On-chain vs. off-chain compilation targets //! diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index c28c11458..ffc11b935 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -197,7 +197,7 @@ all-features = true rustdoc-args = ["--cfg=docsrs"] [lib] -crate-type = ["cdylib", "rlib"] +crate-type = ["rlib"] [lints] workspace = true