MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / compile

Method compile

src/execution/mod.rs:155–191  ·  view source on GitHub ↗

compile programs into binary.

(&self, programs: Vec<&Path>, out: &Path, kind: Compile)

Source from the content-addressed store, hash-verified

153
154 /// compile programs into binary.
155 pub fn compile(&self, programs: Vec<&Path>, out: &Path, kind: Compile) -> Result<()> {
156 let (cflags, lib) = self.get_compile_flags(&kind);
157
158 let mut cmd = Command::new("clang++");
159 for program in &programs {
160 cmd.arg(*program);
161 }
162 if kind == Compile::Minimize {
163 cmd.arg(Deopt::get_fuzz_wrapper()?);
164 }
165 let include_fdp = "-I".to_owned() + Deopt::get_fdp_path()?.to_str().unwrap();
166
167 let cmd = cmd
168 .stdin(Stdio::null())
169 .stdout(Stdio::null())
170 .stderr(Stdio::piped())
171 .args(cflags.as_slice())
172 .arg(&self.header_cmd)
173 .arg(include_fdp)
174 .arg("-g")
175 .arg("-o")
176 .arg(out)
177 .arg(lib);
178 self.deopt.add_extra_c_flags(cmd)?;
179
180 let output = cmd
181 .output()
182 .expect("failed to execute the syntax check process");
183 let success = output.status.success();
184 if !success {
185 eyre::bail!(
186 "fail to compile {programs:?}\n, {}",
187 String::from_utf8_lossy(&output.stderr)
188 );
189 }
190 Ok(())
191 }
192
193 pub fn spawn<S: AsRef<OsStr> + Debug>(
194 &self,

Callers 8

fuse_fuzzerFunction · 0.45
evolve_corpusMethod · 0.45
compile_lib_fuzzersMethod · 0.45
compile_seedMethod · 0.45

Calls 2

get_compile_flagsMethod · 0.80
add_extra_c_flagsMethod · 0.80

Tested by

no test coverage detected