From b27eee7f6b0caa9a9b210244c08f8743e3bdb596 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Mon, 21 Feb 2022 14:40:07 -0300 Subject: [PATCH 1/3] Read ROC_LINK_FLAGS env var to inject more link flags Flags should not contain whitespaces since the value is split on them Update compiler/build/src/link.rs Co-authored-by: Richard Feldman --- compiler/build/src/link.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index b3d5e52062..f328ba3f0a 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -850,6 +850,18 @@ fn link_macos( ld_command.arg(format!("-L{}/swift", sdk_path)); }; + let roc_link_flags = match env::var("ROC_LINK_FLAGS") { + Ok(flags) => { + println!("⚠️ CAUTION: The ROC_LINK_FLAGS environment variable is a temporary workaround, and will no longer do anything once surgical linking lands! If you're concerned about what this means for your use case, please ask about it on Zulip."); + + flags + } + Err(_) => "".to_string() + }; + for roc_link_flag in roc_link_flags.split_whitespace() { + ld_command.arg(format!("{}", roc_link_flag)); + } + ld_command.args(&[ // Libraries - see https://github.com/rtfeldman/roc/pull/554#discussion_r496392274 // for discussion and further references From afa8d228ef88593d4c175e867d012c636210573c Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 21 Feb 2022 20:35:29 -0500 Subject: [PATCH 2/3] cargo fmt --- compiler/build/src/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index f328ba3f0a..88aef8d361 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -856,7 +856,7 @@ fn link_macos( flags } - Err(_) => "".to_string() + Err(_) => "".to_string(), }; for roc_link_flag in roc_link_flags.split_whitespace() { ld_command.arg(format!("{}", roc_link_flag)); From 7dc92fe6f4e93dea4631c576e178ece761df371f Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Mon, 21 Feb 2022 22:15:24 -0500 Subject: [PATCH 3/3] clippy --- compiler/build/src/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index 88aef8d361..eab0872161 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -859,7 +859,7 @@ fn link_macos( Err(_) => "".to_string(), }; for roc_link_flag in roc_link_flags.split_whitespace() { - ld_command.arg(format!("{}", roc_link_flag)); + ld_command.arg(roc_link_flag.to_string()); } ld_command.args(&[