mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
add ROC_LINK_FLAGS support to linux
This commit is contained in:
parent
966c893abf
commit
bdbbfb36d1
1 changed files with 14 additions and 13 deletions
|
@ -848,6 +848,17 @@ fn strs_to_path(strs: &[&str]) -> PathBuf {
|
|||
strs.iter().collect()
|
||||
}
|
||||
|
||||
fn extra_link_flags() -> Vec<String> {
|
||||
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(),
|
||||
}.split_whitespace().map(|x| x.to_owned()).collect()
|
||||
}
|
||||
|
||||
fn link_linux(
|
||||
target: &Triple,
|
||||
output_path: PathBuf,
|
||||
|
@ -1037,6 +1048,7 @@ fn link_linux(
|
|||
.args(&base_args)
|
||||
.args(["-dynamic-linker", ld_linux])
|
||||
.args(input_paths)
|
||||
.args(extra_link_flags())
|
||||
// ld.lld requires this argument, and does not accept --arch
|
||||
// .args(&["-L/usr/lib/x86_64-linux-gnu"])
|
||||
.args([
|
||||
|
@ -1108,7 +1120,8 @@ fn link_macos(
|
|||
"-macos_version_min",
|
||||
&get_macos_version(),
|
||||
])
|
||||
.args(input_paths);
|
||||
.args(input_paths)
|
||||
.args(extra_link_flags());
|
||||
|
||||
let sdk_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib";
|
||||
if Path::new(sdk_path).exists() {
|
||||
|
@ -1116,18 +1129,6 @@ fn link_macos(
|
|||
ld_command.arg(format!("-L{sdk_path}/swift"));
|
||||
};
|
||||
|
||||
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(roc_link_flag);
|
||||
}
|
||||
|
||||
ld_command.args([
|
||||
// Libraries - see https://github.com/roc-lang/roc/pull/554#discussion_r496392274
|
||||
// for discussion and further references
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue