cannot compile on arch linux

Issue #46 resolved
Thomas Pointhuber created an issue

Trying to compile on linux results in the following error:

make -C libpfm4 ARCH="x86_64" CC="gcc  -Wno-override-init"  lib
make[1]: Entering directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4'
make -C lib
make[2]: Entering directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4/lib'
gcc  -Wno-override-init  -g -Wall -Werror -Wextra -Wno-unused-parameter -I. -I/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4/lib/../include -DCONFIG_PFMLIB_DEBUG -DCONFIG_PFMLIB_OS_LINUX -D_REENTRANT -I. -fvisibility=hidden -DCONFIG_PFMLIB_ARCH_X86 -DCONFIG_PFMLIB_ARCH_X86_64 -I. -c pfmlib_perf_event_pmu.c
pfmlib_perf_event_pmu.c: In function 'gen_tracepoint_table':
pfmlib_perf_event_pmu.c:354:36: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
   snprintf(d2path, MAXPATHLEN, "%s/%s", debugfs_mnt, d1->d_name);
                                    ^~
pfmlib_perf_event_pmu.c:354:3: note: 'snprintf' output between 2 and 4352 bytes into a destination of size 4096
   snprintf(d2path, MAXPATHLEN, "%s/%s", debugfs_mnt, d1->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pfmlib_perf_event_pmu.c:404:58: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=]
                         snprintf(idpath, MAXPATHLEN, "%s/%s/id", d2path, d2->d_name);
                                                          ^~
pfmlib_perf_event_pmu.c:404:25: note: 'snprintf' output between 5 and 4355 bytes into a destination of size 4096
                         snprintf(idpath, MAXPATHLEN, "%s/%s/id", d2path, d2->d_name);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4/lib/../rules.mk:30: pfmlib_perf_event_pmu.o] Error 1
make[2]: Leaving directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4/lib'
make[1]: *** [Makefile:52: lib] Error 2
make[1]: Leaving directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4'
make: *** [Rules.pfm4_pe:42: libpfm4/lib/libpfm.a] Error 2

But deactivating this error by typing inmake CFLAGS='-Wno-format-truncation' still does not result in a working program. Now includes are missing:

make -C libpfm4 ARCH="x86_64" CC="gcc  -Wno-override-init"  lib
make[1]: Entering directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4'
make -C lib
make[2]: Entering directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4/lib'
gcc  -Wno-override-init -Wno-format-truncation -c pfmlib_perf_event_pmu.c
In file included from pfmlib_perf_event_pmu.c:44:
pfmlib_priv.h:27:10: fatal error: perfmon/pfmlib.h: No such file or directory
 #include <perfmon/pfmlib.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4/lib/../rules.mk:30: pfmlib_perf_event_pmu.o] Error 1
make[2]: Leaving directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4/lib'
make[1]: *** [Makefile:52: lib] Error 2
make[1]: Leaving directory '/home/thomas/JKU/ssw_msr2018/old/papi/src/libpfm4'
make: *** [Rules.pfm4_pe:42: libpfm4/lib/libpfm.a] Error 2

Comments (7)

  1. Vince Weaver

    PAPI bundles the libpfm4 library and this appears to be a bug with libpfm4.

    do you hit the same error if you build the current git of libpfm4 from http://perfmon2.sourceforge.net/ if so we should report the bug there.

  2. Thomas Pointhuber reporter

    It seems to be an issue with the libpfm4 library

    I managed to compile the library by using the following make and some small code changes (missing #define _GNU_SOURCE):

    make CFLAGS='-Wno-format-truncation -I.. -I../include -I../../include' LDFLAGS=-lpthread
    

    UPDATE:

    it seems make cannot handle changes in CFLAGS which resulted in those weired includes. Adding -Wno-format-truncation into the Makefile directly solved that issue for now.

  3. Log in to comment