dwarves icon indicating copy to clipboard operation
dwarves copied to clipboard

Option parsing: btf_features=default is not the default?

Open martinetd opened this issue 1 year ago • 0 comments

This might be a feature but I'm surprised, the output with --btf_features=default and without any --btf_features seem different:

for opt in "" --btf_features=default; do
   cp .tmp_vmlinux.orig .tmp_vmlinux.btf
   LLVM_OBJCOPY=objcopy pahole -J --btf_gen_floats --lang_exclude=rust --skip_encoding_btf_inconsistent_proto --btf_gen_optimized .tmp_vmlinux.btf $opt
  echo -n "$opt: "
  sha1sum .tmp_vmlinux.btf
done

: 58fcc73788cc9700d4e5ee136334e51b6b9ad601  .tmp_vmlinux.btf
--btf_features=default: 926851f26c73a3014220764f7a1299598afeb11f  .tmp_vmlinux.btf
(ran twice to confirm it's reproducible: there's no threading enabled in the above command)

Looking at the code it's because init_btf_features() is only called when the option is actively parsed; so the default values as per btf_features defaults aren't set unless the option is called.

This also has the side effect that --reproducible_build is unset by a following --btf_features option, e.g. --reproducible_build --btf_features=default will have reproducible build unset, but --btf_features=default --reproducible_build has it set. (If the delayed init is on purpose, this could be resolved by making the default value an enum true/false/don't-touch, but I'd rather ask first)

Thanks!

martinetd avatar Jun 12 '24 22:06 martinetd