Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/internal-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ jobs:
sudo apt-get -qq install \
build-essential \
libbrotli-dev \
libbz2-dev \
libclang-${{ matrix.clang-version }}-dev \
libdb-dev \
libgcrypt20 \
libgdbm-dev \
libreadline-dev \
libidn2-dev \
libldap2-dev \
Expand All @@ -111,6 +114,8 @@ jobs:
python3-setuptools \
python3-wheel \
rcs \
tcl-dev \
tk-dev \
zlib1g-dev

# installs intercept-build to $HOME/.local/bin
Expand All @@ -130,7 +135,7 @@ jobs:
find testsuite -type f -name compile_commands.json -delete
export PATH=$PWD/target/release:$HOME/.local/bin:$PATH
echo "PATH=$PATH"
python3 testsuite/test.py curl json-c lua nginx zstd libxml2
python3 testsuite/test.py curl json-c lua nginx zstd libxml2 python2

- uses: actions/upload-artifact@v4
with:
Expand Down
12 changes: 10 additions & 2 deletions c2rust-transpile/src/translator/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ fn tied_output_operand_idx(
/// {0:y} (and wrapping mem-only references in square brackets).
fn rewrite_asm<F: Fn(&str) -> bool, M: Fn(usize) -> usize>(
asm: &str,
att_syntax: bool,
input_op_mapper: M,
is_mem_only: F,
arch: Arch,
Expand Down Expand Up @@ -647,7 +648,10 @@ fn rewrite_asm<F: Fn(&str) -> bool, M: Fn(usize) -> usize>(
}
let mem_only = is_mem_only(index_str);
// Push the reference wrapped in {}, or in [{}] if mem-only
out.push_str(if mem_only { "[{" } else { "{" });
if mem_only {
out.push(if att_syntax { '(' } else { '[' });
};
out.push('{');
let idx: usize = index_str
.parse()
.map_err(|_| TranslationError::generic("could not parse operand idx"))?;
Expand All @@ -656,7 +660,10 @@ fn rewrite_asm<F: Fn(&str) -> bool, M: Fn(usize) -> usize>(
out.push(':');
out.push_str(&new_modifiers);
}
out.push_str(if mem_only { "}]" } else { "}" });
out.push('}');
if mem_only {
out.push(if att_syntax { ')' } else { ']' });
};
// Push the rest of the chunk
out.push_str(&chunk[end_idx..]);
continue;
Expand Down Expand Up @@ -832,6 +839,7 @@ impl<'c> Translation<'c> {
// Rewrite arg references in assembly template
let rewritten_asm = rewrite_asm(
asm,
att_syntax,
|idx: usize| {
new_idx_for_orig(tied_output_operand_idx(idx, outputs.len(), &tied_operands))
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub unsafe extern "C" fn VM_CallCompiled(
*opStack = 0 as core::ffi::c_int;
opStackOfs = 0 as core::ffi::c_int;
asm!(
"movq [{2}], %rax\n", "movq [{0}], %r8\n", "movq [{1}], %r9\n", "push %r15\n",
"movq ({2}), %rax\n", "movq ({0}), %r8\n", "movq ({1}), %r9\n", "push %r15\n",
"push %r14\n", "push %r13\n", "push %r12\n", "callq *%rax\n", "pop %r12\n",
"pop %r13\n", "pop %r14\n", "pop %r15\n", "\n", "mov {restmp0:x}, %bx\n", in
(reg) & (* vm).instructionPointers, in (reg) & (* vm).dataBase, in (reg) &
Expand Down