MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / parse_cmdline_target

Method parse_cmdline_target

cranelift/reader/src/parser.rs:1038–1080  ·  view source on GitHub ↗

Parse a target spec. Accept the target from the command line for pass command.

(&mut self, target_pass: Option<&str>)

Source from the content-addressed store, hash-verified

1036 /// Accept the target from the command line for pass command.
1037 ///
1038 fn parse_cmdline_target(&mut self, target_pass: Option<&str>) -> ParseResult<isaspec::IsaSpec> {
1039 // Were there any `target` commands specified?
1040 let mut specified_target = false;
1041
1042 let mut targets = Vec::new();
1043 let flag_builder = settings::builder();
1044
1045 if let Some(targ) = target_pass {
1046 let loc = self.loc;
1047 let triple = match Triple::from_str(targ) {
1048 Ok(triple) => triple,
1049 Err(err) => return err!(loc, err),
1050 };
1051 let isa_builder = match isa::lookup(triple) {
1052 Err(isa::LookupError::SupportDisabled) => {
1053 return err!(loc, "support disabled target '{}'", targ);
1054 }
1055 Err(isa::LookupError::Unsupported) => {
1056 return warn!(loc, "unsupported target '{}'", targ);
1057 }
1058 Ok(b) => b,
1059 };
1060 specified_target = true;
1061
1062 // Construct a trait object with the aggregate settings.
1063 targets.push(
1064 isa_builder
1065 .finish(settings::Flags::new(flag_builder.clone()))
1066 .map_err(|e| ParseError {
1067 location: loc,
1068 message: format!("invalid ISA flags for '{targ}': {e:?}"),
1069 is_warning: false,
1070 })?,
1071 );
1072 }
1073
1074 if !specified_target {
1075 // No `target` commands.
1076 Ok(isaspec::IsaSpec::None(settings::Flags::new(flag_builder)))
1077 } else {
1078 Ok(isaspec::IsaSpec::Some(targets))
1079 }
1080 }
1081
1082 /// Parse a list of target specs.
1083 ///

Callers 1

parse_testFunction · 0.80

Calls 7

OkFunction · 0.85
newFunction · 0.50
builderFunction · 0.50
lookupFunction · 0.50
pushMethod · 0.45
finishMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected