Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/hyperlight_host/src/hyperlight_surrogate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ limitations under the License.
*/

fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
panic!("hyperlight_surrogate can only be built for Windows targets");
}

let target_env = std::env::var("CARGO_CFG_TARGET_ENV")
.expect("CARGO_CFG_TARGET_ENV should be set for Windows targets");
// The surrogate is a #![no_std] binary with a custom entry point.
// We need to tell the MSVC linker the entry point and subsystem.
println!("cargo:rustc-link-arg=/ENTRY:mainCRTStartup");
println!("cargo:rustc-link-arg=/SUBSYSTEM:CONSOLE");
if target_env == "gnu" {
// useful for `just clippyw` (targeting x86_64-pc-windows-gnu on linux host)
Comment thread
ludfjig marked this conversation as resolved.
println!("cargo:rustc-link-arg-bin=hyperlight_surrogate=-nostartfiles");
println!("cargo:rustc-link-arg-bin=hyperlight_surrogate=-Wl,-e,mainCRTStartup");
println!("cargo:rustc-link-arg-bin=hyperlight_surrogate=-Wl,--subsystem,console");
} else {
println!("cargo:rustc-link-arg-bin=hyperlight_surrogate=/ENTRY:mainCRTStartup");
println!("cargo:rustc-link-arg-bin=hyperlight_surrogate=/SUBSYSTEM:CONSOLE");
}
}
Loading