fwts does not build with -O0

Bug #1687049 reported by BenjaminBerg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Firmware Test Suite
Fix Released
Medium
Colin Ian King

Bug Description

I tried to disable -Werror (because it fails on newer gcc versions right now). In the process I noticed that fwts fails to build with gcc 6.3.1. The output is (simply running with "make CFLAGS=":

/bin/sh ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../../src/lib/include -I../../../src/acpica/source/include -I../../../src/acpi
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../../src/lib/include -I../../../src/acpica/source/include -I../../../src/acpica/source/compiler -I/usr/include/
In file included from ../../../src/lib/include/fwts_binpaths.h:27:0,
                 from ../../../src/lib/include/fwts.h:54,
                 from fwts_firmware.c:24:
fwts_firmware.c: In function ‘fwts_firmware_feature_string’:
../../../src/lib/include/fwts_framework.h:273:27: error: enumerator value for ‘FWTS_ASSERT_str_too_small_in_line_102’ is not an integer constant
 enum { FWTS_CONCAT_EXPAND(FWTS_ASSERT_ ## m ## _in_line_, __LINE__) = 1 / !!(e) }
                           ^
../../../src/lib/include/fwts_framework.h:270:27: note: in definition of macro ‘FWTS_CONCAT’
 #define FWTS_CONCAT(a, b) a ## b
                           ^
../../../src/lib/include/fwts_framework.h:273:8: note: in expansion of macro ‘FWTS_CONCAT_EXPAND’
 enum { FWTS_CONCAT_EXPAND(FWTS_ASSERT_ ## m ## _in_line_, __LINE__) = 1 / !!(e) }
        ^~~~~~~~~~~~~~~~~~
fwts_firmware.c:100:2: note: in expansion of macro ‘FWTS_ASSERT’
  FWTS_ASSERT((n * (sizeof(feature_names[0].name) - 1)) +
  ^~~~~~~~~~~
../../../src/lib/include/fwts_framework.h:273:27: error: enumerator value for ‘FWTS_ASSERT_invalid_feature_names_in_line_106’ is not an integer constant
 enum { FWTS_CONCAT_EXPAND(FWTS_ASSERT_ ## m ## _in_line_, __LINE__) = 1 / !!(e) }
                           ^
../../../src/lib/include/fwts_framework.h:270:27: note: in definition of macro ‘FWTS_CONCAT’
 #define FWTS_CONCAT(a, b) a ## b
                           ^
../../../src/lib/include/fwts_framework.h:273:8: note: in expansion of macro ‘FWTS_CONCAT_EXPAND’
 enum { FWTS_CONCAT_EXPAND(FWTS_ASSERT_ ## m ## _in_line_, __LINE__) = 1 / !!(e) }
        ^~~~~~~~~~~~~~~~~~
fwts_firmware.c:105:2: note: in expansion of macro ‘FWTS_ASSERT’
  FWTS_ASSERT(((1 << n) - 1) == FWTS_FW_FEATURE_ALL,
  ^~~~~~~~~~~
Makefile:789: recipe for target 'libfwts_la-fwts_firmware.lo' failed
make: *** [libfwts_la-fwts_firmware.lo] Error 1

Revision history for this message
Colin Ian King (colin-king) wrote :

Please let me know which fwts version you are building and where you got the source as debugging this is going to be tricky without such pertinent information.

Building fwts from source with make CFLAGS= is not the way to build fwts. If you want to build it with Werror disabled, then do the following:

1. Edit configure.ac, remove -Werror from AM_INIT_AUTOMAKE

2. Run:

autoreconf -ivf
./configure
make

3. let me know if this works or not

thanks.

Changed in fwts:
status: New → Incomplete
importance: Undecided → Low
assignee: nobody → Colin Ian King (colin-king)
Revision history for this message
BenjaminBerg (benjamin-sipsolutions) wrote :

Well, I was trying to build fwts for Fedora and for this I tried to simply use "fedora/buildrpm.sh" and submit the srpm to COPR. When this failed I now worked around it by setting CFLAGS="-Wno-error -O2 -g" for now.

I am not sure why it is failing with -O0 and I am aware that it is probably not a great idea to disable optimization (I did not intentionally do this). However it seemed like -O0 should work in theory and something odd is going on in those assertion checks that are causing failures.

Revision history for this message
BenjaminBerg (benjamin-sipsolutions) wrote :
Download full text (5.4 KiB)

Get further now:

gcc -DHAVE_CONFIG_H -I. -I.. -I../src/lib/include -I../src/acpica/source/include -I../src/acpica/source/compiler -I../efi_runtime `pkg-config --silence-errors --cflags json` `pkg-config --silence-errors --cflags json-c` -pthread `pkg-config --cflags glib-2.0 gio-2.0` -Wall -Werror -Wextra -DACPI_DEBUG_OUTPUT -g -O2 -MT cpu/cpufreq/fwts-cpufreq.o -MD -MP -MF cpu/cpufreq/.deps/fwts-cpufreq.Tpo -c -o cpu/cpufreq/fwts-cpufreq.o `test -f 'cpu/cpufreq/cpufreq.c' || echo './'`cpu/cpufreq/cpufreq.c
cpu/cpufreq/cpufreq.c: In function ‘cpu_set_frequency’:
cpu/cpufreq/cpufreq.c:85:26: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4072 [-Werror=format-truncation=]
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
                          ^~
cpu/cpufreq/cpufreq.c:85:2: note: ‘snprintf’ output between 50 and 4145 bytes into a destination of size 4096
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cpu->sysfs_path,
    ~~~~~~~~~~~~~~~~
    name ? "/" : "",
    ~~~~~~~~~~~~~~~~
    name ?: "");
    ~~~~~~~~~~~
cpu/cpufreq/cpufreq.c: In function ‘get_claimed_hz’:
cpu/cpufreq/cpufreq.c:85:26: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4072 [-Werror=format-truncation=]
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
                          ^~
cpu/cpufreq/cpufreq.c:85:2: note: ‘snprintf’ output between 50 and 4145 bytes into a destination of size 4096
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cpu->sysfs_path,
    ~~~~~~~~~~~~~~~~
    name ? "/" : "",
    ~~~~~~~~~~~~~~~~
    name ?: "");
    ~~~~~~~~~~~
cpu/cpufreq/cpufreq.c: In function ‘get_bios_limit’:
cpu/cpufreq/cpufreq.c:85:26: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4072 [-Werror=format-truncation=]
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
                          ^~
cpu/cpufreq/cpufreq.c:85:2: note: ‘snprintf’ output between 44 and 4139 bytes into a destination of size 4096
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cpu->sysfs_path,
    ~~~~~~~~~~~~~~~~
    name ? "/" : "",
    ~~~~~~~~~~~~~~~~
    name ?: "");
    ~~~~~~~~~~~
cpu/cpufreq/cpufreq.c: In function ‘parse_cpu_info’:
cpu/cpufreq/cpufreq.c:85:26: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4073 [-Werror=format-truncation=]
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
                          ^~
cpu/cpufreq/cpufreq.c:85:2: note: ‘snprintf’ output between 33 and 4128 bytes into a destination of size 4097
  snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cpu->sysfs_path,
    ~~~~~~~~~~~~~~~~
    name ? "/" : "",
    ~~~~~~~~~~~~~~~~
    name ?: "");
    ~~~~~~~~~~~
cpu/cpufreq/cpufreq.c:85:26: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 40...

Read more...

Revision history for this message
BenjaminBerg (benjamin-sipsolutions) wrote :

Sorry for pasting that into this bug, now pasted to the correct one.

Revision history for this message
Colin Ian King (colin-king) wrote :

OK, I'll get gcc-7 installed and try and resolve the issues it finds. Thanks for the heads-up on these issues with the newer toolchain.

Revision history for this message
Colin Ian King (colin-king) wrote :

Please try the attached patch to fix that new warning in comment #3

Revision history for this message
BenjaminBerg (benjamin-sipsolutions) wrote :

With the two patches the build works fine on GCC 7.0.1 for me.

Revision history for this message
Colin Ian King (colin-king) wrote :

Thanks for the feedback. I've sent the fixes to the fwts-devel mailing list and they will be committed to the repository before the next release.

Changed in fwts:
status: Incomplete → In Progress
importance: Low → Medium
Changed in fwts:
status: In Progress → Fix Committed
Changed in fwts:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.