Skip to content

Commit

Permalink
Improve backwards compatibility with old .rh files
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfeldman committed Jun 20, 2023
1 parent e6c3979 commit 638b87b
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions crates/compiler/build/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ fn build_loaded_file<'a>(
};

// the preprocessed host is stored beside the platform's main.roc
let preprocessed_host_path = if linking_strategy == LinkingStrategy::Legacy {
let mut preprocessed_host_path = if linking_strategy == LinkingStrategy::Legacy {
if let roc_target::OperatingSystem::Wasi = operating_system {
// when compiling a wasm application, we implicitly assume here that the host is in zig
// and has a file called "host.zig"
Expand Down Expand Up @@ -835,9 +835,35 @@ fn build_loaded_file<'a>(
None
} else if is_platform_prebuilt {
if !preprocessed_host_path.exists() {
invalid_prebuilt_platform(prebuilt_requested, preprocessed_host_path);
// Check for .rh and .o files using the old "x86_64" instead of the new "x64", for
// backwards compatibility with prebuilt platforms created before
// https://github.com/roc-lang/roc/pull/557 landed.
//
// Eventually (e.g. certainly after the end of 2023) this fixup can be removed.
if preprocessed_host_path.ends_with("-x64.rh")
|| preprocessed_host_path.ends_with("-x64.o")
{
// Fixup the filename to the new format.
preprocessed_host_path = preprocessed_host_path.with_file_name(
preprocessed_host_path
.file_name()
.unwrap()
.to_str()
.unwrap()
.replace("-x64.", "-x86_64."),
);

// Try again now that we've fixed the filename.
if !preprocessed_host_path.exists() {
invalid_prebuilt_platform(prebuilt_requested, preprocessed_host_path);

std::process::exit(1);
}
} else {
invalid_prebuilt_platform(prebuilt_requested, preprocessed_host_path);

std::process::exit(1);
std::process::exit(1);
}
}

if linking_strategy == LinkingStrategy::Surgical {
Expand Down

0 comments on commit 638b87b

Please sign in to comment.