Skip to content

Commit c0599de

Browse files
committed
---
yaml --- r: 131838 b: refs/heads/dist-snap c: 5539349 h: refs/heads/master v: v3
1 parent 2c2d7f9 commit c0599de

File tree

6 files changed

+75
-58
lines changed

6 files changed

+75
-58
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 457a3c991d79b971be07fce75f9d0c12848fb37c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 7f6a66f77ef362059328524d54b6b987322d2c36
9+
refs/heads/dist-snap: 55393493e1b61aaf1b91ab6bbce442d857d7b42d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/back/archive.rs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010

1111
//! A helper class for dealing with static archives
1212
13-
use llvm::{ArchiveRef, llvm};
14-
15-
use libc;
1613
use std::io::process::{Command, ProcessOutput};
1714
use std::io::{fs, TempDir};
1815
use std::io;
19-
use std::mem;
2016
use std::os;
21-
use std::raw;
2217
use std::str;
2318
use syntax::abi;
2419
use ErrorHandler = syntax::diagnostic::Handler;
@@ -41,10 +36,6 @@ pub struct Archive<'a> {
4136
maybe_ar_prog: Option<String>
4237
}
4338

44-
pub struct ArchiveRO {
45-
ptr: ArchiveRef,
46-
}
47-
4839
fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
4940
args: &str, cwd: Option<&Path>,
5041
paths: &[&Path]) -> ProcessOutput {
@@ -238,49 +229,3 @@ impl<'a> Archive<'a> {
238229
}
239230
}
240231

241-
impl ArchiveRO {
242-
/// Opens a static archive for read-only purposes. This is more optimized
243-
/// than the `open` method because it uses LLVM's internal `Archive` class
244-
/// rather than shelling out to `ar` for everything.
245-
///
246-
/// If this archive is used with a mutable method, then an error will be
247-
/// raised.
248-
pub fn open(dst: &Path) -> Option<ArchiveRO> {
249-
unsafe {
250-
let ar = dst.with_c_str(|dst| {
251-
llvm::LLVMRustOpenArchive(dst)
252-
});
253-
if ar.is_null() {
254-
None
255-
} else {
256-
Some(ArchiveRO { ptr: ar })
257-
}
258-
}
259-
}
260-
261-
/// Reads a file in the archive
262-
pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> {
263-
unsafe {
264-
let mut size = 0 as libc::size_t;
265-
let ptr = file.with_c_str(|file| {
266-
llvm::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
267-
});
268-
if ptr.is_null() {
269-
None
270-
} else {
271-
Some(mem::transmute(raw::Slice {
272-
data: ptr,
273-
len: size as uint,
274-
}))
275-
}
276-
}
277-
}
278-
}
279-
280-
impl Drop for ArchiveRO {
281-
fn drop(&mut self) {
282-
unsafe {
283-
llvm::LLVMRustDestroyArchive(self.ptr);
284-
}
285-
}
286-
}

branches/dist-snap/src/librustc/back/lto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use super::archive::ArchiveRO;
1211
use super::link;
1312
use driver::session;
1413
use driver::config;
14+
use llvm::archive_ro::ArchiveRO;
1515
use llvm::{ModuleRef, TargetMachineRef, llvm, True, False};
1616
use metadata::cstore;
1717
use util::common::time;

branches/dist-snap/src/librustc/metadata/loader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@
212212
//! no means all of the necessary details. Take a look at the rest of
213213
//! metadata::loader or metadata::creader for all the juicy details!
214214
215-
use back::archive::{ArchiveRO, METADATA_FILENAME};
215+
use back::archive::{METADATA_FILENAME};
216216
use back::svh::Svh;
217217
use driver::session::Session;
218218
use lib::llvm::{False, llvm, ObjectFile, mk_section_iter};
219+
use lib::llvm::archive_ro::ArchiveRO;
219220
use metadata::cstore::{MetadataBlob, MetadataVec, MetadataArchive};
220221
use metadata::decoder;
221222
use metadata::encoder;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! A wrapper around LLVM's archive (.a) code
12+
13+
use libc;
14+
use ArchiveRef;
15+
use llvm;
16+
17+
use std::raw;
18+
use std::mem;
19+
20+
pub struct ArchiveRO {
21+
ptr: ArchiveRef,
22+
}
23+
24+
impl ArchiveRO {
25+
/// Opens a static archive for read-only purposes. This is more optimized
26+
/// than the `open` method because it uses LLVM's internal `Archive` class
27+
/// rather than shelling out to `ar` for everything.
28+
///
29+
/// If this archive is used with a mutable method, then an error will be
30+
/// raised.
31+
pub fn open(dst: &Path) -> Option<ArchiveRO> {
32+
unsafe {
33+
let ar = dst.with_c_str(|dst| {
34+
llvm::LLVMRustOpenArchive(dst)
35+
});
36+
if ar.is_null() {
37+
None
38+
} else {
39+
Some(ArchiveRO { ptr: ar })
40+
}
41+
}
42+
}
43+
44+
/// Reads a file in the archive
45+
pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> {
46+
unsafe {
47+
let mut size = 0 as libc::size_t;
48+
let ptr = file.with_c_str(|file| {
49+
llvm::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
50+
});
51+
if ptr.is_null() {
52+
None
53+
} else {
54+
Some(mem::transmute(raw::Slice {
55+
data: ptr,
56+
len: size as uint,
57+
}))
58+
}
59+
}
60+
}
61+
}
62+
63+
impl Drop for ArchiveRO {
64+
fn drop(&mut self) {
65+
unsafe {
66+
llvm::LLVMRustDestroyArchive(self.ptr);
67+
}
68+
}
69+
}

branches/dist-snap/src/librustc_llvm/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ extern crate libc;
3232
use std::c_str::ToCStr;
3333
use libc::{c_uint, c_ushort, uint64_t, c_int, size_t};
3434

35+
pub mod archive_ro;
36+
3537
pub type Opcode = u32;
3638
pub type Bool = c_uint;
3739

0 commit comments

Comments
 (0)