Skip to content

Commit

Permalink
Fix for check_ptr_call for variadic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Jun 17, 2023
1 parent 8560b07 commit 3d7ec59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 7 additions & 6 deletions build_sysroot/build_sysroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/

# Since we can't override the sysroot for the UI tests anymore, we create a new toolchain and manually overwrite the sysroot directory.
rust_toolchain=$(cat ../rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/')
my_toolchain_dir=$HOME/.rustup/toolchains/codegen_gcc_ui_tests-$rust_toolchain-$TARGET_TRIPLE
rm -rf $my_toolchain_dir
cp -r $HOME/.rustup/toolchains/$rust_toolchain-$TARGET_TRIPLE $my_toolchain_dir
rm -rf $my_toolchain_dir/lib/rustlib/$TARGET_TRIPLE/
cp -r ../build_sysroot/sysroot/* $my_toolchain_dir
# TODO: to remove.
#rust_toolchain=$(cat ../rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/')
#my_toolchain_dir=$HOME/.rustup/toolchains/codegen_gcc_ui_tests-$rust_toolchain-$TARGET_TRIPLE
#rm -rf $my_toolchain_dir
#cp -r $HOME/.rustup/toolchains/$rust_toolchain-$TARGET_TRIPLE $my_toolchain_dir
#rm -rf $my_toolchain_dir/lib/rustlib/$TARGET_TRIPLE/
#cp -r ../build_sysroot/sysroot/* $my_toolchain_dir
9 changes: 8 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
})
.collect();

debug_assert_eq!(casted_args.len(), args.len());

Cow::Owned(casted_args)
}

Expand All @@ -207,7 +209,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {

let func_name = format!("{:?}", func_ptr);

let casted_args: Vec<_> = param_types
let mut casted_args: Vec<_> = param_types
.into_iter()
.zip(args.iter())
.enumerate()
Expand Down Expand Up @@ -237,6 +239,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
})
.collect();

// NOTE: to take into account variadic functions.
for i in casted_args.len()..args.len() {
casted_args.push(args[i]);
}

Cow::Owned(casted_args)
}

Expand Down

0 comments on commit 3d7ec59

Please sign in to comment.