Skip to content

Commit

Permalink
Move reference files into their own directory
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaoliello committed Apr 10, 2024
1 parent c632d0c commit 1185cf6
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
9 changes: 4 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# A writer for object file ar archives

This is a Rust port of LLVM's archive writer (`ArchiveWriter.cpp`):
* Based on commit [8ef3e895a](https://github.com/llvm/llvm-project/tree/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2) (15.0.0-rc3).
* With the following options removed:
* Deterministic: always enabled.
* Symbol tables: always enabled.
This is a Rust port of LLVM's archive writer (see [the LLVM Reference](reference/Readme.md)
for details) with the following options removed:
* Deterministic: always enabled.
* Symbol tables: always enabled.

## License

Expand Down
2 changes: 0 additions & 2 deletions src/Alignment.h → reference/Alignment.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copied from https://github.com/llvm/llvm-project/blob/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2/llvm/include/llvm/Support/Alignment.h

//===-- llvm/Support/Alignment.h - Useful alignment functions ---*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand Down
2 changes: 0 additions & 2 deletions src/Archive.h → reference/Archive.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copied from https://github.com/llvm/llvm-project/blob/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2/llvm/include/llvm/Object/Archive.h

//===- Archive.h - ar archive file format -----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand Down
2 changes: 0 additions & 2 deletions src/ArchiveWriter.cpp → reference/ArchiveWriter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copied from https://github.com/llvm/llvm-project/blob/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2/llvm/lib/Object/ArchiveWriter.cpp

//===- ArchiveWriter.cpp - ar File Format implementation --------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand Down
2 changes: 0 additions & 2 deletions src/ArchiveWriter.h → reference/ArchiveWriter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copied from https://github.com/llvm/llvm-project/blob/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2/llvm/include/llvm/Object/ArchiveWriter.h

//===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand Down
18 changes: 18 additions & 0 deletions reference/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# LLVM Reference Files

These are a copy of the relevant LLVM files that were ported to Rust from the
last time that this project was "synced" with LLVM.

Currently that sync point is 15.0.0-rc3, commit [8ef3e895a](https://github.com/llvm/llvm-project/tree/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2).

These files were originally located at:
* `llvm/include/llvm/Support/Alignment.h`
* `llvm/include/llvm/Object/Archive.h`
* `llvm/include/llvm/Object/ArchiveWriter.h`
* `llvm/lib/Object/ArchiveWriter.cpp`

When syncing, make sure to update these files and the commit above.

Additionally, `ar_archive_writer` has removed some options, so you can assume:
* `deterministic` is always `true`.
* `write_symtab` is always `true`.
2 changes: 0 additions & 2 deletions src/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// Derived from https://github.com/llvm/llvm-project/blob/8ef3e895ad8ab1724e2b87cabad1dacdc7a397a3/llvm/include/llvm/Support/Alignment.h

/// Returns a multiple of `align` needed to store `size` bytes.
pub(crate) fn align_to(size: u64, align: u64) -> u64 {
(size + align - 1) & !(align - 1)
Expand Down
2 changes: 0 additions & 2 deletions src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// Derived from https://github.com/llvm/llvm-project/blob/8ef3e895ad8ab1724e2b87cabad1dacdc7a397a3/llvm/include/llvm/Object/Archive.h

/// Size field is 10 decimal digits long
pub(crate) const MAX_MEMBER_SIZE: u64 = 9999999999;

Expand Down
4 changes: 0 additions & 4 deletions src/archive_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// Derived from:
// * https://github.com/llvm/llvm-project/blob/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2/llvm/include/llvm/Object/ArchiveWriter.h
// * https://github.com/llvm/llvm-project/blob/3d3ef9d073e1e27ea57480b371b7f5a9f5642ed2/llvm/lib/Object/ArchiveWriter.cpp

use std::collections::HashMap;
use std::io::{self, Cursor, Seek, Write};

Expand Down

0 comments on commit 1185cf6

Please sign in to comment.