cranelift-native flags detection: fix flags on SSE2-only systems. (#4231)
In #4224 we saw that an SSE2-only x86-64 system somehow was still detecting SSE3/SSSE3/SSE4.1/SSE4.2. It turns out that we enabled these in the baseline `Flags` in #3816, because without that, a ton of other things break: default flags no longer produce a compiler backend that works with default Wasmtime settings. However the logic to set them when detected (via `CPUID`-using feature-test macros) only does an "if detected then set bit" step per feature; the bits are never *cleared*. This PR fixes that.
This commit is contained in:
@@ -58,6 +58,19 @@ pub fn builder_with_options(infer_native_flags: bool) -> Result<isa::Builder, &'
|
|||||||
return Ok(isa_builder);
|
return Ok(isa_builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These are temporarily enabled by default (see #3810 for
|
||||||
|
// more) so that a default-constructed `Flags` can work with
|
||||||
|
// default Wasmtime features. Otherwise, the user must
|
||||||
|
// explicitly use native flags or turn these on when on x86-64
|
||||||
|
// platforms to avoid a configuration panic. In order for the
|
||||||
|
// "enable if detected" logic below to work, we must turn them
|
||||||
|
// *off* (differing from the default) and then re-enable below
|
||||||
|
// if present.
|
||||||
|
isa_builder.set("has_sse3", "false").unwrap();
|
||||||
|
isa_builder.set("has_ssse3", "false").unwrap();
|
||||||
|
isa_builder.set("has_sse41", "false").unwrap();
|
||||||
|
isa_builder.set("has_sse42", "false").unwrap();
|
||||||
|
|
||||||
if std::is_x86_feature_detected!("sse3") {
|
if std::is_x86_feature_detected!("sse3") {
|
||||||
isa_builder.enable("has_sse3").unwrap();
|
isa_builder.enable("has_sse3").unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user