finish up the shim approach

This commit is contained in:
Niko Matsakis 2011-11-10 15:54:31 -08:00
parent 4f28419d0c
commit d77968dd7c
2 changed files with 29 additions and 13 deletions

16
configure vendored
View File

@ -253,6 +253,7 @@ opt docs 1 "build documentation"
opt optimize 1 "build optimized rust code"
opt mingw-cross 0 "cross-compile for win32 using mingw"
opt clang 0 "prefer gcc to clang for building the runtime"
opt debug-llvm "build LLVM in debug mode"
valopt prefix "/usr/local" "set installation prefix"
valopt llvm-root "" "set LLVM root"
valopt target-triples "" "LLVM target triples (defaults to host if unset)"
@ -433,15 +434,22 @@ do
step_msg "configuring LLVM for $t"
LLVM_BUILD_DIR=$CFG_BUILD_DIR/llvm/$t
# Just use LLVM straight from its build directory to
# avoid 'make install' time
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release+Asserts
LLVM_TARGETS="--enable-targets=x86,x86_64"
LLVM_BUILD="--build=$t"
LLVM_HOST="--host=$t"
LLVM_TARGET="--target=$t"
LLVM_OPTS="--enable-optimized --disable-docs"
if [ -z "$CFG_ENABLE_DEBUG_LLVM" ]
then
LLVM_DBG_OPTS=""
# Just use LLVM straight from its build directory to
# avoid 'make install' time
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug+Asserts
else
LLVM_DBG_OPTS="--enabled-optimized"
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release+Asserts
fi
LLVM_OPTS="$LLVM_DBG_OPTS --disable-docs"
LLVM_CXX_32="g++ -m32"
LLVM_CC_32="gcc -m32"

View File

@ -3851,23 +3851,31 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
check type_has_static_size(ccx, ret_ty);
let llretty = type_of(ccx, f.span, ret_ty);
// Allocate the argument bundle.
let llargbundlety = T_struct(llargtys + [llretty]);
let llargbundlesz = llsize_of(ccx, llargbundlety);
let llrawargbundle = Call(bcx, ccx.upcalls.alloc_c_stack,
[llargbundlesz]);
let llargbundle = PointerCast(bcx, llrawargbundle, T_ptr(llargbundlety));
// Translate arguments and store into bundle.
// Translate arguments.
// n.b.: We must do this before allocating the argument
// bundle in order to avoid problems with nested function calls.
let (to_zero, to_revoke) = ([], []);
let i = 0u, n = vec::len(args);
let llargs = [];
while i < n {
let ty_arg = fn_arg_tys[i];
let arg = args[i];
let llargty = llargtys[i];
let r = trans_arg_expr(bcx, ty_arg, llargty, to_zero, to_revoke, arg);
bcx = r.bcx;
store_inbounds(bcx, r.val, llargbundle, [0, i as int]);
llargs += [r.val];
i += 1u;
}
// Allocate the argument bundle and store arguments.
let llargbundlety = T_struct(llargtys + [llretty]);
let llargbundlesz = llsize_of(ccx, llargbundlety);
let llrawargbundle = Call(bcx, ccx.upcalls.alloc_c_stack,
[llargbundlesz]);
let llargbundle = PointerCast(bcx, llrawargbundle, T_ptr(llargbundlety));
i = 0u;
while i < n {
store_inbounds(bcx, llargs[i], llargbundle, [0, i as int]);
i += 1u;
}