Skip to content

Commit dd0c7a9

Browse files
wilsonkgraydon
authored andcommitted
---
yaml --- r: 2402 b: refs/heads/master c: b4a0d89 h: refs/heads/master v: v3
1 parent a5a48a3 commit dd0c7a9

File tree

6 files changed

+43
-15
lines changed

6 files changed

+43
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 1e03f004047668e80ea4e1469addd0484ef48fbc
2+
refs/heads/master: b4a0d891c0a5eac32896650214abfe62cc1ea5a0

trunk/src/comp/driver/rustc.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,27 @@ options:
161161
--no-typestate don't run the typestate pass (unsafe!)\n\n");
162162
}
163163

164-
fn get_os() -> session.os {
165-
auto s = std.os.target_os();
166-
if (_str.eq(s, "win32")) { ret session.os_win32; }
167-
if (_str.eq(s, "macos")) { ret session.os_macos; }
168-
if (_str.eq(s, "linux")) { ret session.os_linux; }
164+
fn get_os(str triple) -> session.os {
165+
if (_str.find(triple, "win32") > 0 ||
166+
_str.find(triple, "mingw32") > 0 ) {
167+
ret session.os_win32;
168+
} else if (_str.find(triple, "darwin") > 0) { ret session.os_macos; }
169+
else if (_str.find(triple, "linux") > 0) { ret session.os_linux; }
170+
}
171+
172+
fn get_arch(str triple) -> session.arch {
173+
if (_str.find(triple, "i386") > 0 ||
174+
_str.find(triple, "i486") > 0 ||
175+
_str.find(triple, "i586") > 0 ||
176+
_str.find(triple, "i686") > 0 ||
177+
_str.find(triple, "i786") > 0 ) {
178+
ret session.arch_x86;
179+
} else if (_str.find(triple, "x86_64") > 0) {
180+
ret session.arch_x64;
181+
} else if (_str.find(triple, "arm") > 0 ||
182+
_str.find(triple, "xscale") > 0 ) {
183+
ret session.arch_arm;
184+
}
169185
}
170186

171187
fn get_default_sysroot(str binary) -> str {
@@ -176,10 +192,12 @@ fn get_default_sysroot(str binary) -> str {
176192

177193
fn main(vec[str] args) {
178194

179-
// FIXME: don't hard-wire this.
195+
let str triple =
196+
std._str.rustrt.str_from_cstr(llvm.llvm.LLVMRustGetHostTriple());
197+
180198
let @session.config target_cfg =
181-
@rec(os = get_os(),
182-
arch = session.arch_x86,
199+
@rec(os = get_os(triple),
200+
arch = get_arch(triple),
183201
int_type = common.ty_i32,
184202
uint_type = common.ty_u32,
185203
float_type = common.ty_f64);

trunk/src/comp/lib/llvm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@ native mod llvm = llvm_lib {
848848
call. */
849849
fn LLVMRustGetLastError() -> sbuf;
850850

851+
/** Returns a string describing the hosts triple */
852+
fn LLVMRustGetHostTriple() -> sbuf;
853+
851854
/** Parses the bitcode in the given memory buffer. */
852855
fn LLVMRustParseBitcode(MemoryBufferRef MemBuf) -> ModuleRef;
853856

trunk/src/lib/sort.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ fn swap[T](vec[mutable T] arr, uint x, uint y) {
4545
arr.(y) = a;
4646
}
4747

48-
fn part[T](lteq[mutable T] compare_func, vec[mutable T] arr, uint left,
48+
fn part[T](lteq[T] compare_func, vec[mutable T] arr, uint left,
4949
uint right, uint pivot) -> uint {
5050

51-
fn compare[T](lteq[mutable T] compare_func, vec[mutable T]arr,
51+
fn compare[T](lteq[T] compare_func, vec[mutable T]arr,
5252
uint arr_idx, &T arr_value) -> bool {
5353

5454
ret compare_func(arr.(arr_idx),arr_value);
@@ -69,7 +69,7 @@ fn part[T](lteq[mutable T] compare_func, vec[mutable T] arr, uint left,
6969
ret storage_index;
7070
}
7171

72-
fn qsort[T](lteq[mutable T] compare_func, vec[mutable T] arr, uint left,
72+
fn qsort[T](lteq[T] compare_func, vec[mutable T] arr, uint left,
7373
uint right) {
7474

7575
if (right > left) {
@@ -83,12 +83,12 @@ fn qsort[T](lteq[mutable T] compare_func, vec[mutable T] arr, uint left,
8383
}
8484
}
8585

86-
fn quick_sort[T](lteq[mutable T] compare_func, vec[mutable T] arr) {
86+
fn quick_sort[T](lteq[T] compare_func, vec[mutable T] arr) {
8787

88-
if (len[mutable T](arr) == 0u) {
88+
if (len[T](arr) == 0u) {
8989
ret;
9090
}
91-
qsort[T](compare_func, arr, 0u, (len[mutable T](arr)) - 1u);
91+
qsort[T](compare_func, arr, 0u, (len[T](arr)) - 1u);
9292
}
9393

9494
// Local Variables:

trunk/src/rustllvm/RustWrapper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/Target/TargetSelect.h"
2121
#include "llvm/Target/TargetRegistry.h"
2222
#include "llvm/Target/TargetOptions.h"
23+
#include "llvm/Support/Host.h"
2324
#include "llvm-c/Core.h"
2425
#include "llvm-c/BitReader.h"
2526
#include "llvm-c/Object.h"
@@ -106,3 +107,8 @@ extern "C" LLVMModuleRef LLVMRustParseBitcode(LLVMMemoryBufferRef MemBuf) {
106107
? NULL : M;
107108
}
108109

110+
extern "C" const char *LLVMRustGetHostTriple(void)
111+
{
112+
static std::string str = llvm::sys::getHostTriple();
113+
return str.c_str();
114+
}

trunk/src/rustllvm/rustllvm.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
LLVMRustCreateMemoryBufferWithContentsOfFile
22
LLVMRustWriteOutputFile
33
LLVMRustGetLastError
4+
LLVMRustGetHostTriple
45
LLVMRustParseBitcode
56
LLVMLinkModules
67
LLVMCreateObjectFile

0 commit comments

Comments
 (0)