Project

General

Profile

Bug #8516

Suppress gcc errors with -Wno- in Makefile for usr/src/cmd

Added by Gary Mills about 2 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
2017-07-20
Due date:
% Done:

90%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

While building illumos-gate usr/src/cmd with gcc-4.9.4, two types of gcc errors appeared that were difficult to correct by changes to the source files. A variety of reasons made them difficult to correct in the source. One was variations in the build environment. Another is that source files may be replaced by a newer version. Yet another is that the error may originate in a standard header file, not in the source at all. In these cases, it's simpler to suppress the error in the appropriate Makefile.

For example, compiling amt.c produced this error:

../amt.c: In function 'probe_data_area':
../amt.c:237:15: error: variable 'p1' set but not used [-Werror=unused-but-set-variable]
  volatile int p1;
               ^
../amt.c: In function 'probe_hole':
../amt.c:661:25: error: variable 'probe' set but not used [-Werror=unused-but-set-variable]
  volatile unsigned char probe;
                         ^
cc1: all warnings being treated as errors

The variable in question was often already marked /* LINTED */, indicating that the author already knew about the problem.

Compiling gssd_proc.c produced this error:

In file included from gssd_proc.c:45:0:
gssd_proc.c: In function 'checkfrom':
.../proto/root_i386/usr/include/sys/debug.h:134:15: error: typedef '__compile_time_assertion__2652' locally defined but not used [-Werror=unused-local-typedefs]  typedef char __compile_time_assertion__ ## y [(x) ? 1 : -1]
               ^
.../proto/root_i386/usr/include/sys/debug.h:132:26: note: in expansion of macro '__CTASSERT'
 #define _CTASSERT(x, y)  __CTASSERT(x, y)
                          ^
.../proto/root_i386/usr/include/sys/debug.h:131:22: note: in expansion of macro '_CTASSERT'
 #define CTASSERT(x)  _CTASSERT(x, __LINE__)
                      ^
gssd_proc.c:2652:3: note: in expansion of macro 'CTASSERT'
   CTASSERT(sizeof (struct authunix_parms) <= RQCRED_SIZE);
   ^
cc1: all warnings being treated as errors

In this case, the error occurred during expansion of the CTASSERT macro.

The solution, used in such situations only, is to suppress the error with a `CERRWARN += _gcc=-Wno' statement in the Makefile. By making it only apply to a specific target, gssd_proc.o in this case, the statement will only take effect when the specific source file is being compiled.

Note that even though I tested with gcc-4.9.4, later versions of gcc use the same error identifier strings. Earlier versions ignore unknown `-Wno-' options and do not detect these errors.


Related issues

Related to illumos gate - Feature #8572: ccompile.h: rename __GNU_UNUSED to __unusedClosed2017-08-10

Actions
Related to illumos gate - Bug #8608: debug.h: CTASSERT will trigger variable unused errorsClosed2017-09-04

Actions

History

#1

Updated by Gergő Mihály Doma about 2 years ago

  • Related to Feature #8572: ccompile.h: rename __GNU_UNUSED to __unused added
#2

Updated by Gergő Mihály Doma about 2 years ago

  • Related to Bug #8608: debug.h: CTASSERT will trigger variable unused errors added

Also available in: Atom PDF