@@ -48,7 +48,7 @@ def edit_output(self, text):
4848def is_exe (name ):
4949 from shutil import which
5050 return which (name ) is not None
51-
51+
5252def ensure_dependencies_in_path ():
5353 for program in [RMC_RUSTC_EXE , "symtab2gb" , "cbmc" , "cbmc-viewer" , "goto-instrument" , "goto-cc" ]:
5454 ensure (is_exe (program ), f"Could not find { program } in PATH" )
@@ -116,11 +116,11 @@ def run_cmd(cmd, label=None, cwd=None, env=None, output_to=None, quiet=False, ve
116116 process = subprocess .run (
117117 cmd , universal_newlines = True , stdout = subprocess .PIPE , stderr = subprocess .STDOUT ,
118118 env = env , cwd = cwd )
119-
119+
120120 # Print status
121121 if label != None :
122122 print_rmc_step_status (label , process , verbose )
123-
123+
124124 stdout = process .stdout
125125 for scanner in scanners :
126126 if scanner .match (stdout ):
@@ -129,24 +129,26 @@ def run_cmd(cmd, label=None, cwd=None, env=None, output_to=None, quiet=False, ve
129129 # Write to stdout if specified, or if failure, or verbose or debug
130130 if (output_to == "stdout" or process .returncode != EXIT_CODE_SUCCESS or verbose or debug ) and not quiet :
131131 print (stdout )
132-
132+
133133 # Write to file if given
134134 if output_to != None and output_to != "stdout" :
135135 with open (output_to , "w" ) as f :
136136 f .write (stdout )
137-
137+
138138 return process .returncode
139139
140140# Generates a symbol table from a rust file
141141def compile_single_rust_file (input_filename , output_filename , verbose = False , debug = False , keep_temps = False , mangler = "v0" , dry_run = False , use_abs = False , abs_type = "std" , symbol_table_passes = []):
142142 if not keep_temps :
143143 atexit .register (delete_file , output_filename )
144144
145- build_cmd = [RMC_RUSTC_EXE ,
146- "-Z" , "codegen-backend=gotoc" ,
145+ build_cmd = [RMC_RUSTC_EXE ,
146+ "-Z" , "codegen-backend=gotoc" ,
147147 "-Z" , "trim-diagnostic-paths=no" ,
148- "-Z" , f"symbol-mangling-version={ mangler } " ,
148+ "-Z" , f"symbol-mangling-version={ mangler } " ,
149149 "-Z" , f"symbol_table_passes={ ' ' .join (symbol_table_passes )} " ,
150+ "--crate-type=lib" ,
151+ "-Z" , "human_readable_cgu_names" ,
150152 f"--cfg={ RMC_CFG } " ]
151153
152154 if use_abs :
@@ -165,20 +167,21 @@ def compile_single_rust_file(input_filename, output_filename, verbose=False, deb
165167 return run_cmd (build_cmd , env = build_env , label = "compile" , verbose = verbose , debug = debug , dry_run = dry_run )
166168
167169# Generates a symbol table (and some other artifacts) from a rust crate
168- def cargo_build (crate , target_dir = "target" , verbose = False , debug = False , mangler = "v0" , dry_run = False , symbol_table_passes = []):
170+ def cargo_build (crate , target_dir , verbose = False , debug = False , mangler = "v0" , dry_run = False , symbol_table_passes = []):
169171 ensure (os .path .isdir (crate ), f"Invalid path to crate: { crate } " )
170172
171173 rustflags = [
172174 "-Z" , "codegen-backend=gotoc" ,
173175 "-Z" , "trim-diagnostic-paths=no" ,
174176 "-Z" , f"symbol-mangling-version={ mangler } " ,
175- "-Z" , f"symbol_table_passes={ ' ' .join (symbol_table_passes )} " ,
177+ "-Z" , f"symbol_table_passes={ ' ' .join (symbol_table_passes )} " ,
178+ "-Z" , "human_readable_cgu_names" ,
176179 f"--cfg={ RMC_CFG } " ]
177180 rustflags = " " .join (rustflags )
178181 if "RUSTFLAGS" in os .environ :
179182 rustflags = os .environ ["RUSTFLAGS" ] + " " + rustflags
180183
181- build_cmd = ["cargo" , "build" , "--target-dir" , target_dir ]
184+ build_cmd = ["cargo" , "build" , "--lib" , "-- target-dir" , str ( target_dir ) ]
182185 build_env = {"RUSTFLAGS" : rustflags ,
183186 "RUSTC" : RMC_RUSTC_EXE ,
184187 "PATH" : os .environ ["PATH" ],
@@ -229,7 +232,7 @@ def run_visualize(cbmc_filename, prop_args, cover_args, verbose=False, quiet=Fal
229232 # 2) cbmc --xml-ui --cover location ~/rmc/library/rmc/rmc_lib.c <cbmc_filename> > coverage.xml
230233 # 3) cbmc --xml-ui --show-properties ~/rmc/library/rmc/rmc_lib.c <cbmc_filename> > property.xml
231234 # 4) cbmc-viewer --result results.xml --coverage coverage.xml --property property.xml --srcdir . --goto <cbmc_filename> --reportdir report
232-
235+
233236 def run_cbmc_local (cbmc_args , output_to , dry_run = False ):
234237 cbmc_cmd = ["cbmc" ] + cbmc_args + [cbmc_filename ]
235238 return run_cmd (cbmc_cmd , label = "cbmc" , output_to = output_to , verbose = verbose , quiet = quiet , dry_run = dry_run )
@@ -266,7 +269,7 @@ def run_goto_instrument(input_filename, output_filename, args, verbose=False, dr
266269# Generates a C program from a goto program
267270def goto_to_c (goto_filename , c_filename , verbose = False , dry_run = False ):
268271 return run_goto_instrument (goto_filename , c_filename , ["--dump-c" ], verbose , dry_run = dry_run )
269-
272+
270273# Fix remaining issues with output of --gen-c-runnable
271274def gen_c_postprocess (c_filename , dry_run = False ):
272275 if not dry_run :
0 commit comments