fn build(opt: &Opt, package: &str, target: &str) -> CVResult<PathBuf> {
    let (mut bc_file, c_files) = compile(&opt, &package, target)?;

    // Link bc file (from all the Rust code) against the (backend-specific)
    // runtime library and any c_files generated by build scripts from any C/C++
    // build scripts
    let new_bc_file = add_pre_ext(&bc_file, "link");
    let rvt_dir = std::env::var("RVT_DIR")?;
    let rvt_dir = PathBuf::from(rvt_dir);
    let runtime = rvt_dir
        .clone()
        .append("runtime")
        .append(format!("rvt-{}.bc", opt.backend.to_string().to_lowercase()));
    let simd_emulation = rvt_dir
        .clone()
        .append("simd_emulation")
        .append("simd_emulation.bc");
    info_at!(
        &opt,
        Verbosity::Minor,
        "  Linking {}, {}, {} and [{}] to produce {}",
        bc_file.to_string_lossy(),
        runtime.to_string_lossy(),
        simd_emulation.to_string_lossy(),
        c_files
            .iter()
            .map(|p| p.to_string_lossy())
            .collect::<Vec<_>>()
            .join(", "),
        new_bc_file.to_string_lossy()
    );
    // Link multiple bitcode files together.
    Command::new(format!("llvm-link-{}", opt.llvm_version))
        .arg("-o")
        .arg(&new_bc_file)
        .arg(runtime)
        .arg(simd_emulation)
        .arg(&bc_file)
        .args(&c_files)
        .latin1_output_info(&opt, Verbosity::Major)?;
    bc_file = new_bc_file;

    if opt.backend == Backend::Seahorn {
        info_at!(&opt, Verbosity::Major, "  Patching LLVM file for Seahorn");
        let new_bc_file = add_pre_ext(&bc_file, "patch-sea");
        patch_llvm(&opt, &["--seahorn"], &bc_file, &new_bc_file)?;
        bc_file = new_bc_file;
    }

    if opt.backend == Backend::Smack {
        info_at!(&opt, Verbosity::Major, "  Patching LLVM file for Smack");
        let new_bc_file = add_pre_ext(&bc_file, "patch-smack");
        patch_llvm(&opt, &["--smack"], &bc_file, &new_bc_file)?;
        bc_file = new_bc_file;
    }

    // todo: This is probably useful with all verifiers - but
    // making it KLEE-only until we have a chance to test it.
    if opt.backend == Backend::Klee {
        info_at!(
            &opt,
            Verbosity::Major,
            "  Patching LLVM file for initializers, feature tests, and SIMD"
        );
        let new_bc_file = add_pre_ext(&bc_file, "patch-init-feat");
        patch_llvm(
            &opt,
            &["--initializers", "--features", "--intrinsics"],
            &bc_file,
            &new_bc_file,
        )?;
        bc_file = new_bc_file;
    }

    Ok(bc_file)
}
/// Compile, link and do transformations on LLVM bitcode.
Compile, link and do transformations on LLVM bitcode.
Compile link and do transformations on LLVM bitcode .
fn build(opt: &Opt, package: &str, target: &str) -> CVResult<PathBuf> {
    let (mut bc_file, c_files) = compile(&opt, &package, target)?;
    // Link bc file (from all the Rust code) against the (backend-specific)
    // runtime library and any c_files generated by build scripts from any C/C++
    // build scripts
    let new_bc_file = add_pre_ext(&bc_file, "link");
    let rvt_dir = std::env::var("RVT_DIR")?;
    let rvt_dir = PathBuf::from(rvt_dir);
    let runtime = rvt_dir
        .clone()
        .append("runtime")
        .append(format!("rvt-{}.bc", opt.backend.to_string().to_lowercase()));
    let simd_emulation = rvt_dir
        .clone()
        .append("simd_emulation")
        .append("simd_emulation.bc");
    info_at!(
        &opt,
        Verbosity::Minor,
        "  Linking {}, {}, {} and [{}] to produce {}",
        bc_file.to_string_lossy(),
        runtime.to_string_lossy(),
        simd_emulation.to_string_lossy(),
        c_files
            .iter()
            .map(|p| p.to_string_lossy())
            .collect::<Vec<_>>()
            .join(", "),
        new_bc_file.to_string_lossy()
    );
    // Link multiple bitcode files together.
    Command::new(format!("llvm-link-{}", opt.llvm_version))
        .arg("-o")
        .arg(&new_bc_file)
        .arg(runtime)
        .arg(simd_emulation)
        .arg(&bc_file)
        .args(&c_files)
        .latin1_output_info(&opt, Verbosity::Major)?;
    bc_file = new_bc_file;
    if opt.backend == Backend::Seahorn {
        info_at!(&opt, Verbosity::Major, "  Patching LLVM file for Seahorn");
        let new_bc_file = add_pre_ext(&bc_file, "patch-sea");
        patch_llvm(&opt, &["--seahorn"], &bc_file, &new_bc_file)?;
        bc_file = new_bc_file;
    }
    if opt.backend == Backend::Smack {
        info_at!(&opt, Verbosity::Major, "  Patching LLVM file for Smack");
        let new_bc_file = add_pre_ext(&bc_file, "patch-smack");
        patch_llvm(&opt, &["--smack"], &bc_file, &new_bc_file)?;
        bc_file = new_bc_file;
    }
    // todo: This is probably useful with all verifiers - but
    // making it KLEE-only until we have a chance to test it.
    if opt.backend == Backend::Klee {
        info_at!(
            &opt,
            Verbosity::Major,
            "  Patching LLVM file for initializers, feature tests, and SIMD"
        );
        let new_bc_file = add_pre_ext(&bc_file, "patch-init-feat");
        patch_llvm(
            &opt,
            &["--initializers", "--features", "--intrinsics"],
            &bc_file,
            &new_bc_file,
        )?;
        bc_file = new_bc_file;
    }
    Ok(bc_file)
}
fn build ( opt : & Opt , package : & str , target : & str ) -> CVResult < PathBuf > { let ( mut bc_file , c_files ) = compile ( & opt , & package , target ) ? ; // Link bc file (from all the Rust code) against the (backend-specific) // runtime library and any c_files generated by build scripts from any C/C++ // build scripts let new_bc_file = add_pre_ext ( & bc_file , " " ) ; let rvt_dir = std :: env :: var ( " " ) ? ; let rvt_dir = PathBuf :: from ( rvt_dir ) ; let runtime = rvt_dir . clone ( ) . append ( " " ) . append ( format ! ( " " opt backend to_string ( ) to_lowercase ( ) ) ) ; let simd_emulation = rvt_dir . clone ( ) . append ( " " ) . append ( " " ) ; info_at ! ( opt Verbosity Minor " " bc_file to_string_lossy ( ) runtime to_string_lossy ( ) simd_emulation to_string_lossy ( ) c_files iter ( ) map ( p p to_string_lossy ( ) ) collect Vec ( ) join ( " " ) new_bc_file to_string_lossy ( ) ) ; // Link multiple bitcode files together. Command :: new ( format ! ( " " opt llvm_version ) ) . arg ( " " ) . arg ( & new_bc_file ) . arg ( runtime ) . arg ( simd_emulation ) . arg ( & bc_file ) . args ( & c_files ) . latin1_output_info ( & opt , Verbosity :: Major ) ? ; bc_file = new_bc_file ; if opt . backend == Backend :: Seahorn { info_at ! ( opt Verbosity Major " " ) ; let new_bc_file = add_pre_ext ( & bc_file , " " ) ; patch_llvm ( & opt , & [ " " ] , & bc_file , & new_bc_file ) ? ; bc_file = new_bc_file ; } if opt . backend == Backend :: Smack { info_at ! ( opt Verbosity Major " " ) ; let new_bc_file = add_pre_ext ( & bc_file , " " ) ; patch_llvm ( & opt , & [ " " ] , & bc_file , & new_bc_file ) ? ; bc_file = new_bc_file ; } // todo: This is probably useful with all verifiers - but // making it KLEE-only until we have a chance to test it. if opt . backend == Backend :: Klee { info_at ! ( opt Verbosity Major " " ) ; let new_bc_file = add_pre_ext ( & bc_file , " " ) ; patch_llvm ( & opt , & [ " " , " " , " " ] , & bc_file , & new_bc_file , ) ? ; bc_file = new_bc_file ; } Ok ( bc_file ) }
Compile, link and do transformations on LLVM bitcode.
Compile link and do transformations on LLVM bitcode .
opt
&Opt
package
&str
target
&str
opt
&Opt
package
&str
target
&str