Skip to content

Commit f59af75

Browse files
committed
Auto merge of #23381 - Manishearth:rollup, r=Manishearth
r? @Manishearth
2 parents 66853af + d66d0b3 commit f59af75

File tree

15 files changed

+85
-121
lines changed

15 files changed

+85
-121
lines changed

configure

+2-2
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,11 @@ then
823823
LLVM_VERSION=$($LLVM_CONFIG --version)
824824

825825
case $LLVM_VERSION in
826-
(3.[2-6]*)
826+
(3.[5-6]*)
827827
msg "found ok version of LLVM: $LLVM_VERSION"
828828
;;
829829
(*)
830-
err "bad LLVM version: $LLVM_VERSION, need >=3.0svn"
830+
err "bad LLVM version: $LLVM_VERSION, need >=3.5"
831831
;;
832832
esac
833833
fi

mk/main.mk

+1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
290290
LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
291291
LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
292292
LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
293+
LLVM_LIBDIR_RUSTFLAGS_$(1)=-L "$$(LLVM_LIBDIR_$(1))"
293294
LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
294295
LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
295296
# On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),

mk/target.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
8484
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \
8585
$$(RUST_LIB_FLAGS_ST$(1)) \
8686
-L "$$(RT_OUTPUT_DIR_$(2))" \
87-
-L "$$(LLVM_LIBDIR_$(2))" \
87+
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
8888
$$(LLVM_STDCPP_RUSTFLAGS_$(2)) \
8989
$$(RUSTFLAGS_$(4)) \
9090
--out-dir $$(@D) \

mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
372372
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
373373
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
374374
-L "$$(RT_OUTPUT_DIR_$(2))" \
375-
-L "$$(LLVM_LIBDIR_$(2))" \
375+
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
376376
$$(RUSTFLAGS_$(4))
377377

378378
endef

src/doc/trpl/closures.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ is that a moving closure always takes ownership of all variables that
6868
it uses. Ordinary closures, in contrast, just create a reference into
6969
the enclosing stack frame. Moving closures are most useful with Rust's
7070
concurrency features, and so we'll just leave it at this for
71-
now. We'll talk about them more in the "Threads" section of the guide.
71+
now. We'll talk about them more in the "Concurrency" chapter of the book.
7272

7373
## Accepting closures as arguments
7474

src/doc/trpl/concurrency.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn main() {
339339
});
340340
}
341341
342-
rx.recv().ok().expect("Could not recieve answer");
342+
rx.recv().ok().expect("Could not receive answer");
343343
}
344344
```
345345

src/doc/trpl/method-syntax.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ impl CircleBuilder {
187187
}
188188
189189
fn coordinate(&mut self, coordinate: f64) -> &mut CircleBuilder {
190-
self.coordinate = coordinate;
191-
self
190+
self.coordinate = coordinate;
191+
self
192192
}
193193
194194
fn radius(&mut self, radius: f64) -> &mut CircleBuilder {
195-
self.radius = radius;
196-
self
195+
self.radius = radius;
196+
self
197197
}
198198
199199
fn finalize(&self) -> Circle {

src/librustc/session/search_paths.rs

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use std::slice;
1212
use std::path::{Path, PathBuf};
13+
use session::early_error;
1314

1415
#[derive(Clone, Debug)]
1516
pub struct SearchPaths {
@@ -50,6 +51,9 @@ impl SearchPaths {
5051
} else {
5152
(PathKind::All, path)
5253
};
54+
if path.is_empty() {
55+
early_error("empty search path given via `-L`");
56+
}
5357
self.paths.push((kind, PathBuf::new(path)));
5458
}
5559

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ impl NonCamelCaseTypes {
811811
if i == 0 {
812812
c.to_uppercase().collect::<String>()
813813
} else {
814-
c.to_string()
814+
c.to_lowercase().collect()
815815
}
816816
)).collect::<Vec<_>>().concat()
817817
}

src/librustc_trans/trans/tvec.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
293293
}
294294
SaveIn(lldest) => {
295295
match ty::eval_repeat_count(bcx.tcx(), &**count_expr) {
296-
0 => bcx,
296+
0 => expr::trans_into(bcx, &**element, Ignore),
297297
1 => expr::trans_into(bcx, &**element, SaveIn(lldest)),
298298
count => {
299299
let elem = unpack_datum!(bcx, expr::trans(bcx, &**element));
@@ -410,8 +410,12 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
410410
F: FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>,
411411
{
412412
let _icx = push_ctxt("tvec::iter_vec_loop");
413-
let fcx = bcx.fcx;
414413

414+
if bcx.unreachable.get() {
415+
return bcx;
416+
}
417+
418+
let fcx = bcx.fcx;
415419
let loop_bcx = fcx.new_temp_block("expr_repeat");
416420
let next_bcx = fcx.new_temp_block("expr_repeat: next");
417421

src/rustllvm/RustWrapper.cpp

+12-108
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
#include "llvm/IR/DiagnosticInfo.h"
1515
#include "llvm/IR/DiagnosticPrinter.h"
1616

17-
#if LLVM_VERSION_MINOR >= 5
1817
#include "llvm/IR/CallSite.h"
19-
#else
20-
#include "llvm/Support/CallSite.h"
21-
#endif
2218

2319
//===----------------------------------------------------------------------===
2420
//
@@ -33,7 +29,6 @@ using namespace llvm::object;
3329

3430
static char *LastError;
3531

36-
#if LLVM_VERSION_MINOR >= 5
3732
extern "C" LLVMMemoryBufferRef
3833
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
3934
ErrorOr<std::unique_ptr<MemoryBuffer>> buf_or = MemoryBuffer::getFile(Path,
@@ -45,18 +40,6 @@ LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
4540
}
4641
return wrap(buf_or.get().release());
4742
}
48-
#else
49-
extern "C" LLVMMemoryBufferRef
50-
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
51-
OwningPtr<MemoryBuffer> buf;
52-
error_code err = MemoryBuffer::getFile(Path, buf, -1, false);
53-
if (err) {
54-
LLVMRustSetLastError(err.message().c_str());
55-
return NULL;
56-
}
57-
return wrap(buf.take());
58-
}
59-
#endif
6043

6144
extern "C" char *LLVMRustGetLastError(void) {
6245
char *ret = LastError;
@@ -116,7 +99,6 @@ extern "C" void LLVMAddCallSiteAttribute(LLVMValueRef Instr, unsigned index, uin
11699
}
117100

118101

119-
#if LLVM_VERSION_MINOR >= 5
120102
extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef Instr, unsigned idx, uint64_t b) {
121103
CallSite Call = CallSite(unwrap<Instruction>(Instr));
122104
AttrBuilder B;
@@ -126,9 +108,6 @@ extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef Instr, unsigned
126108
AttributeSet::get(Call->getContext(),
127109
idx, B)));
128110
}
129-
#else
130-
extern "C" void LLVMAddDereferenceableCallSiteAttr(LLVMValueRef, unsigned, uint64_t) {}
131-
#endif
132111

133112
extern "C" void LLVMAddFunctionAttribute(LLVMValueRef Fn, unsigned index, uint64_t Val) {
134113
Function *A = unwrap<Function>(Fn);
@@ -137,16 +116,12 @@ extern "C" void LLVMAddFunctionAttribute(LLVMValueRef Fn, unsigned index, uint64
137116
A->addAttributes(index, AttributeSet::get(A->getContext(), index, B));
138117
}
139118

140-
#if LLVM_VERSION_MINOR >= 5
141119
extern "C" void LLVMAddDereferenceableAttr(LLVMValueRef Fn, unsigned index, uint64_t bytes) {
142120
Function *A = unwrap<Function>(Fn);
143121
AttrBuilder B;
144122
B.addDereferenceableAttr(bytes);
145123
A->addAttributes(index, AttributeSet::get(A->getContext(), index, B));
146124
}
147-
#else
148-
extern "C" void LLVMAddDereferenceableAttr(LLVMValueRef, unsigned, uint64_t) {}
149-
#endif
150125

151126
extern "C" void LLVMAddFunctionAttrString(LLVMValueRef Fn, unsigned index, const char *Name) {
152127
Function *F = unwrap<Function>(Fn);
@@ -199,10 +174,8 @@ extern "C" LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B,
199174
AtomicOrdering order,
200175
AtomicOrdering failure_order) {
201176
return wrap(unwrap(B)->CreateAtomicCmpXchg(unwrap(target), unwrap(old),
202-
unwrap(source), order
203-
#if LLVM_VERSION_MINOR >= 5
204-
, failure_order
205-
#endif
177+
unwrap(source), order,
178+
failure_order
206179
));
207180
}
208181
extern "C" LLVMValueRef LLVMBuildAtomicFence(LLVMBuilderRef B, AtomicOrdering order) {
@@ -247,11 +220,7 @@ DIT unwrapDI(LLVMMetadataRef ref) {
247220
return DIT(ref ? unwrap<MDNode>(ref) : NULL);
248221
}
249222

250-
#if LLVM_VERSION_MINOR >= 5
251223
extern "C" const uint32_t LLVMRustDebugMetadataVersion = DEBUG_METADATA_VERSION;
252-
#else
253-
extern "C" const uint32_t LLVMRustDebugMetadataVersion = 1;
254-
#endif
255224

256225
extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M,
257226
const char *name,
@@ -383,10 +352,8 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStructType(
383352
unwrapDI<DIType>(DerivedFrom),
384353
unwrapDI<DIArray>(Elements),
385354
RunTimeLang,
386-
unwrapDI<DIType>(VTableHolder)
387-
#if LLVM_VERSION_MINOR >= 4
388-
,UniqueId
389-
#endif
355+
unwrapDI<DIType>(VTableHolder),
356+
UniqueId
390357
));
391358
}
392359

@@ -465,8 +432,8 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable(
465432
#if LLVM_VERSION_MINOR < 6
466433
if (AddrOpsCount > 0) {
467434
SmallVector<llvm::Value *, 16> addr_ops;
468-
llvm::Type *Int64Ty = Type::getInt64Ty(VMContext);
469-
for (int i = 0; i < AddrOpsCount; ++i)
435+
llvm::Type *Int64Ty = Type::getInt64Ty(unwrap<MDNode>(Scope)->getContext());
436+
for (unsigned i = 0; i < AddrOpsCount; ++i)
470437
addr_ops.push_back(ConstantInt::get(Int64Ty, AddrOps[i]));
471438

472439
return wrap(Builder->createComplexVariable(
@@ -522,7 +489,11 @@ extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(
522489
LLVMMetadataRef* Ptr,
523490
unsigned Count) {
524491
return wrap(Builder->getOrCreateArray(
492+
#if LLVM_VERSION_MINOR >= 6
525493
ArrayRef<Metadata*>(unwrap(Ptr), Count)));
494+
#else
495+
ArrayRef<Value*>(reinterpret_cast<Value**>(Ptr), Count)));
496+
#endif
526497
}
527498

528499
extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
@@ -627,19 +598,11 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateUnionType(
627598
AlignInBits,
628599
Flags,
629600
unwrapDI<DIArray>(Elements),
630-
RunTimeLang
631-
#if LLVM_VERSION_MINOR >= 4
632-
,UniqueId
633-
#endif
601+
RunTimeLang,
602+
UniqueId
634603
));
635604
}
636605

637-
#if LLVM_VERSION_MINOR < 5
638-
extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Value, LLVMBool Unnamed) {
639-
unwrap<GlobalValue>(Value)->setUnnamedAddr(Unnamed);
640-
}
641-
#endif
642-
643606
extern "C" LLVMMetadataRef LLVMDIBuilderCreateTemplateTypeParameter(
644607
DIBuilderRef Builder,
645608
LLVMMetadataRef Scope,
@@ -730,7 +693,6 @@ extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) {
730693
os << ")";
731694
}
732695

733-
#if LLVM_VERSION_MINOR >= 5
734696
extern "C" bool
735697
LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
736698
Module *Dst = unwrap(dst);
@@ -763,28 +725,7 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
763725
}
764726
return true;
765727
}
766-
#else
767-
extern "C" bool
768-
LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
769-
Module *Dst = unwrap(dst);
770-
MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
771-
std::string Err;
772-
Module *Src = llvm::getLazyBitcodeModule(buf, Dst->getContext(), &Err);
773-
if (!Src) {
774-
LLVMRustSetLastError(Err.c_str());
775-
delete buf;
776-
return false;
777-
}
778-
779-
if (Linker::LinkModules(Dst, Src, Linker::DestroySource, &Err)) {
780-
LLVMRustSetLastError(Err.c_str());
781-
return false;
782-
}
783-
return true;
784-
}
785-
#endif
786728

787-
#if LLVM_VERSION_MINOR >= 5
788729
extern "C" void*
789730
LLVMRustOpenArchive(char *path) {
790731
ErrorOr<std::unique_ptr<MemoryBuffer>> buf_or = MemoryBuffer::getFile(path,
@@ -817,23 +758,6 @@ LLVMRustOpenArchive(char *path) {
817758

818759
return ret;
819760
}
820-
#else
821-
extern "C" void*
822-
LLVMRustOpenArchive(char *path) {
823-
OwningPtr<MemoryBuffer> buf;
824-
error_code err = MemoryBuffer::getFile(path, buf, -1, false);
825-
if (err) {
826-
LLVMRustSetLastError(err.message().c_str());
827-
return NULL;
828-
}
829-
Archive *ret = new Archive(buf.take(), err);
830-
if (err) {
831-
LLVMRustSetLastError(err.message().c_str());
832-
return NULL;
833-
}
834-
return ret;
835-
}
836-
#endif
837761

838762
extern "C" const char*
839763
#if LLVM_VERSION_MINOR >= 6
@@ -844,21 +768,12 @@ LLVMRustArchiveReadSection(OwningBinary<Archive> *ob, char *name, size_t *size)
844768
LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) {
845769
#endif
846770

847-
#if LLVM_VERSION_MINOR >= 5
848771
Archive::child_iterator child = ar->child_begin(),
849772
end = ar->child_end();
850773
for (; child != end; ++child) {
851774
ErrorOr<StringRef> name_or_err = child->getName();
852775
if (name_or_err.getError()) continue;
853776
StringRef sect_name = name_or_err.get();
854-
#else
855-
Archive::child_iterator child = ar->begin_children(),
856-
end = ar->end_children();
857-
for (; child != end; ++child) {
858-
StringRef sect_name;
859-
error_code err = child->getName(sect_name);
860-
if (err) continue;
861-
#endif
862777
if (sect_name.trim(" ") == name) {
863778
StringRef buf = child->getBuffer();
864779
*size = buf.size();
@@ -877,18 +792,11 @@ LLVMRustDestroyArchive(Archive *ar) {
877792
delete ar;
878793
}
879794

880-
#if LLVM_VERSION_MINOR >= 5
881795
extern "C" void
882796
LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) {
883797
GlobalValue *V = unwrap<GlobalValue>(Value);
884798
V->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
885799
}
886-
#else
887-
extern "C" void
888-
LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) {
889-
LLVMSetLinkage(Value, LLVMDLLExportLinkage);
890-
}
891-
#endif
892800

893801
extern "C" int
894802
LLVMVersionMinor() {
@@ -918,11 +826,7 @@ inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
918826
extern "C" int
919827
LLVMRustGetSectionName(LLVMSectionIteratorRef SI, const char **ptr) {
920828
StringRef ret;
921-
#if LLVM_VERSION_MINOR >= 5
922829
if (std::error_code ec = (*unwrap(SI))->getName(ret))
923-
#else
924-
if (error_code ec = (*unwrap(SI))->getName(ret))
925-
#endif
926830
report_fatal_error(ec.message());
927831
*ptr = ret.data();
928832
return ret.size();

0 commit comments

Comments
 (0)