Skip to content

Commit c939e13

Browse files
vecchiot-awstedinski
authored andcommitted
Added v0 mangler as default for rmc, and added --mangler option. (rust-lang#170)
1 parent f8ebea9 commit c939e13

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

scripts/cargo-rmc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def main():
2121
parser.add_argument("--quiet", "-q", action="store_true")
2222
parser.add_argument("--debug", action="store_true")
2323
parser.add_argument("--keep-temps", action="store_true")
24+
parser.add_argument("--mangler", default="v0")
2425
parser.add_argument("crate", help="crate to verify")
2526
parser.add_argument("cbmc_args", nargs=argparse.REMAINDER,
2627
default=[], help="Pass through directly to CBMC")
@@ -31,7 +32,7 @@ def main():
3132
if not rmc.dependencies_in_path():
3233
return 1
3334

34-
rmc.cargo_build(args.crate, args.verbose, args.debug)
35+
rmc.cargo_build(args.crate, args.verbose, args.debug, args.mangler)
3536

3637
pattern = f"target/debug/deps/*.json"
3738
jsons = glob.glob(pattern)

scripts/rmc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def main():
2323
parser.add_argument("--gen-c", action="store_true")
2424
parser.add_argument("--gen-symbols", action="store_true")
2525
parser.add_argument("--allow-cbmc-verification-failure", action="store_true")
26+
parser.add_argument("--mangler", default="v0")
2627
parser.add_argument("cbmc_args", nargs=argparse.REMAINDER,
2728
default=[], help="Pass through directly to CBMC")
2829
args = parser.parse_args()
@@ -41,7 +42,7 @@ def main():
4142
c_filename = base + ".c"
4243
symbols_filename = base + ".symbols"
4344

44-
if EXIT_CODE_SUCCESS != rmc.compile_single_rust_file(args.input, json_filename, args.verbose, args.debug, args.keep_temps):
45+
if EXIT_CODE_SUCCESS != rmc.compile_single_rust_file(args.input, json_filename, args.verbose, args.debug, args.keep_temps, args.mangler):
4546
return 1
4647

4748
if EXIT_CODE_SUCCESS != rmc.symbol_table_to_gotoc(json_filename, goto_filename, args.verbose, args.keep_temps):

scripts/rmc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def print_rmc_step_status(step_name, completed_process, verbose=False):
4444
print(f"[RMC] cmd: {' '.join(completed_process.args)}")
4545

4646

47-
def compile_single_rust_file(input_filename, output_filename, verbose=False, debug=False, keep_temps=False):
47+
def compile_single_rust_file(input_filename, output_filename, verbose=False, debug=False, keep_temps=False, mangler="v0"):
4848
if not keep_temps:
4949
atexit.register(delete_file, output_filename)
50-
build_cmd = [RMC_RUSTC_EXE, "-Z", "codegen-backend=gotoc",
50+
build_cmd = [RMC_RUSTC_EXE, "-Z", "codegen-backend=gotoc", "-Z", f"symbol-mangling-version={mangler}",
5151
f"--cfg={RMC_CFG}", "-o", output_filename, input_filename]
5252
build_env = os.environ
5353
if debug:
@@ -60,8 +60,8 @@ def compile_single_rust_file(input_filename, output_filename, verbose=False, deb
6060
return process.returncode
6161

6262

63-
def cargo_build(crate, verbose=False, debug=False):
64-
rustflags = ["-Z", "codegen-backend=gotoc", f"--cfg={RMC_CFG}"]
63+
def cargo_build(crate, verbose=False, debug=False, mangler="v0"):
64+
rustflags = ["-Z", "codegen-backend=gotoc", "-Z", f"symbol-mangling-version={mangler}", f"--cfg={RMC_CFG}"]
6565
rustflags = " ".join(rustflags)
6666
if "RUSTFLAGS" in os.environ:
6767
rustflags = os.environ["RUSTFLAGS"] + " " + rustflags

0 commit comments

Comments
 (0)