Created attachment 155215 [details] Fix sysutils/i7z segfaults and warnings I found out that sysutils/i7z segfaults under various conditions, e.g. different compilers and compilation flags. For example, compiling with clang -O0 almost always works, but as soon as you start optimizing, segfaults occur. There is also a comment in the Makefile about having to disable several gcc optimizations to avoid segfaults. I did some debugging, and it turns out that the inline cpuid() implementation can inadvertently clobber registers, causing the cpu_heirarchy_info struct in 'chi' to be destroyed. Later on, this can lead to segfaults. I replaced the cpuid() implementation by a more standard one, and that solves all crashes for me. I tried compiling with: * clang 3.4.1 (on stable/10), with default flags * clang 3.4.1 (on stable/10), with CPUTYPE=core-avx2 * clang 3.4.1 (on stable/10), with CPUTYPE=core-avx2 and -O3 * gcc 4.2.1 (on stable/10), with default flags * gcc 4.2.1 (on stable/10), with -O3 There was also no more need to use -fno-schedule-insns2 -fno-schedule-insns -fno-caller-saves for gcc. In addition, I fixed a number of warnings about printf formats used for time_t, but that is mostly cosmetic.
I forgot to mention that I also compiled with clang trunk r234092, same result.
Maintainer timeout
A commit references this bug: Author: amdmi3 Date: Sun Sep 11 19:18:59 UTC 2016 New revision: 421871 URL: https://svnweb.freebsd.org/changeset/ports/421871 Log: - Fix broken cpuid implementation to fix segfaults and remove need of optimization removal hacks PR: 199186 Submitted by: dim Approved by: maintainer timeout (zont, 1 year) Changes: head/sysutils/i7z/Makefile head/sysutils/i7z/files/patch-helper_functions.c head/sysutils/i7z/files/patch-i7z.c
Dmitry, can you please also remove the USE_GCC= yes line? It is no longer needed, the program works fine when compiled with clang.
(In reply to Dimitry Andric from comment #4) I second this. It would be really good because I just don't want to install 200 MiB of crap like GCC just to run i7z.