Skip to content

Commit

Permalink
Bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
h1994st committed Jun 22, 2023
1 parent bfd15c3 commit a82a9e4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/bin/rllvm_get_bc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ struct ExtractionArgs {
#[arg(short = 'o', long)]
output: Option<PathBuf>,

/// Build bitcode module
/// Build bitcode archive (only used for archive files, e.g., *.a)
#[arg(short = 'b', long)]
build_bitcode_module: bool,
build_bitcode_archive: bool,

/// Save manifest of all filepaths of underlying bitcode files
#[arg(short = 'm', long)]
Expand Down Expand Up @@ -60,6 +60,7 @@ pub fn main() -> Result<(), Error> {
let input_data = fs::read(&input_filepath)?;
let mut object_files = vec![];
let mut output_file_ext = "bc";
let mut build_bitcode_archive = false;
if let Ok(input_object_file) = object::File::parse(&*input_data) {
log::info!("Input object file kind: {:?}", input_object_file.kind());
object_files = vec![input_object_file];
Expand All @@ -73,11 +74,12 @@ pub fn main() -> Result<(), Error> {
object_files.push(object_file)
}

if args.build_bitcode_module {
output_file_ext = "a.bc";
} else {
if args.build_bitcode_archive {
output_file_ext = "bca";
} else {
output_file_ext = "a.bc";
}
build_bitcode_archive = args.build_bitcode_archive;
} else {
return Err(Error::Unknown("Unsupported file format".to_string()));
};
Expand All @@ -93,14 +95,14 @@ pub fn main() -> Result<(), Error> {
let bitcode_filepaths = extract_bitcode_filepaths_from_parsed_objects(&object_files)?;

// Link or archive bitcode files
if args.build_bitcode_module {
log::info!("Link bitcode files");
if let Some(code) = link_bitcode_files(&bitcode_filepaths, output_filepath.clone())? {
if build_bitcode_archive {
log::info!("Archive bitcode files");
if let Some(code) = archive_bitcode_files(&bitcode_filepaths, output_filepath.clone())? {
std::process::exit(code);
}
} else {
log::info!("Archive bitcode files");
if let Some(code) = archive_bitcode_files(&bitcode_filepaths, output_filepath.clone())? {
log::info!("Link bitcode files");
if let Some(code) = link_bitcode_files(&bitcode_filepaths, output_filepath.clone())? {
std::process::exit(code);
}
}
Expand Down

0 comments on commit a82a9e4

Please sign in to comment.