paulgazz / kmax

A collection of analysis tools for Kconfig and Kbuild constraints.
42 stars 21 forks source link

kismet fails for some specific commits on arch x86_64 #147

Closed Yujie-Liu closed 2 years ago

Yujie-Liu commented 2 years ago

kismet -a=x86_64 fails for some specific commits (especially old commits) on arch x86_64.

Tested on v5.0, v4.20, v4.19, v4.18, v4.17 respectively, v5.0 and v4.17 work well, while others raise below error:

$ kismet -a=x86_64 INFO: Kismet will analyze the select constructs of the architecture "x86_64" for unmet direct dependency. INFO: All times reported are measured using Python's time.perf_counter() utility. INFO: Prefetching the architecture kclause formulas. ERROR:Arch(x86_64): Error running kextract: kextract file couldn't be generated. Traceback (most recent call last): File "/env_kmax/bin/kismet", line 386, in if sample_models: arch.get_kextract() # for sampling File "/env_kmax/lib/python3.9/site-packages/kmax/arch.py", line 579, in get_kextract self.__ensure_formulas(self.kextract, self.kextract_file_delayed_load, self.load_kextract, self.generate_kextract) File "/env_kmax/lib/python3.9/site-packages/kmax/arch.py", line 494, in __ensure_formulas formula_generation_method() File "/env_kmax/lib/python3.9/site-packages/kmax/arch.py", line 786, in generate_kextract raise Arch.KextractFormulaGenerationError() kmax.arch.Arch.KextractFormulaGenerationError: kextract formulas couldn't be generated.

paulgazz commented 2 years ago

The problem is that kismet currently assumes the latest version of Kconfig is being used. There is, however, functionality already created for selecting older versions of Kconfig to use for another tool (klocalizer). The fix is to use this functionality in kismet as well.

paulgazz commented 2 years ago

kismet has been updated to detect the kernel version and pick a Kconfig parser from a close version of the Linux kernel (these are the python extensions in kextractors/). The error (kextract formulas couldn't be generated) now no longer appears when testing the referenced versions:

for version in v5.0 v4.20 v4.19 v4.18 v4.17; do git checkout $version; kismet -a=x86_64 --selectees CONF
IG_SND_SOC_MAX98357A --selectors CONFIG_SND_SOC_INTEL_DA7219_MAX98357A_GENERIC; cat kismet_summary_x86_64.{csv,txt}; done |& tee tryall.txt

The latest linux master (torvalds branch) has also been tested. Note that this fix isn't completely foolproof, since the Kconfig language may change in the future, and older versions of the kernel (particularly those prior to v3.19) may trigger the error. In this case, the Kconfig parser from the new version will need to supported with a new instance of kextract.

Yujie-Liu commented 2 years ago

Thanks for the fix. We have upgraded to v4.1 release and the issue is gone.