From c839134b5f78d7dd0f5c8211ec6c7b675b0026fc Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 5 Jun 2022 14:42:25 +0200 Subject: [PATCH] Fix #40 by using different linking flags depending on rustc version --- Cargo.toml | 1 + lib.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 700bf79..16c1716 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ path = "lib.rs" [dependencies] toml = "0.5" +version_check = "0.9.4" [dev-dependencies] # used for tests diff --git a/lib.rs b/lib.rs index 0ea7ac2..133f2cf 100644 --- a/lib.rs +++ b/lib.rs @@ -609,7 +609,12 @@ impl WindowsResource { } println!("cargo:rustc-link-search=native={}", output_dir); - println!("cargo:rustc-link-lib=static=resource"); + + if version_check::is_min_version("1.61.0").unwrap_or(true) { + println!("cargo:rustc-link-lib=static:+whole-archive=resource"); + } else { + println!("cargo:rustc-link-lib=static=resource"); + } Ok(()) }