zentool: Fix building on a newer toolchain
Or at least try to, there are still some issues with pahole, but seems I need to contribute the fixes upstream.
Context for these:
cc -std=gnu2x -Og -ggdb3 -I/usr/include/json-c -mavx -march=znver2 -Wall -W -D_GNU_SOURCE -DZENTOOL_VERSION=\"0.01\" -mavx -march=znver2 -c -o edit.o edit.c
edit.c: In function ‘set_fastpath_hook’:
edit.c:162:31: warning: passing argument 1 of ‘str_split’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
162 | char **values = str_split(options, ',');
| ^~~~~~~
In file included from edit.c:30:
util.h:34:24: note: expected ‘char *’ but argument is of type ‘const char *’
34 | char** str_split(char* a_str, const char a_delim);
| ~~~~~~^~~~~
and for the Makefile bug: you shouldn't use pipes in Makefiles, if a command on the left of it fails, then the whole line still succeeds. So, I ran Make -> pahole failed -> I changed something -> build "succeeded". But it was incorrect, pahole was never called again because of this bug.
Is it fine to destroy optarg? If not then maybe make a copy first
No idea, the docs seem unclear. But good point, I changed it to make a copy of the string, and thus making set_fastpath_hook()'s interface less tricky.
So, i think the fixes are good but also they make the build fail with
pahole -C RegOp structs.o > RegOp_fields.h.pahole
libbpf: failed to find '.BTF' ELF section in structs.o
pahole: structs.o: Invalid argument
The same error also happened in the version in the master branch so the bug that causes it also exists there but the build didn't fail and for some reason Zentool still works. I would like to merge your fix, but you would have to make it so Zentool still builds with the fix applied.
Oh no, so I need to also fix the pahole bug :( I'll take a look into this, but may take a moment because I'll need to upstream the fix.
The fix here only stops the accidental silencing of the pahole bug (introduced in its newer versions), it's weird that Zentool worked with it...