Bug 213541 - Build failure of libcap without -std=c99 mode
Summary: Build failure of libcap without -std=c99 mode
Status: RESOLVED CODE_FIX
Alias: None
Product: Tools
Classification: Unclassified
Component: libcap (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Andrew G. Morgan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-21 16:18 UTC by Andrew G. Morgan
Modified: 2021-06-22 00:54 UTC (History)
1 user (show)

See Also:
Kernel Version: n/a
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Andrew G. Morgan 2021-06-21 16:18:50 UTC
Byron Stanoszek reports:
-----------------------
I have a small bug report for you concerning libcap-2.51. It fails to compile
out of the box on RedHat Enterprise Linux 7.6 due to the following error:

# make
...
uns_test.c: In function ‘main’:
uns_test.c:118:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
      for (int i=0; i<2; i++) {
      ^
uns_test.c:118:5: note: use option -std=c99 or -std=gnu99 to compile your code
make[2]: *** [uns_test] Error 1
make[2]: Leaving directory `/root/src/rhel7-os-update/libcap-2.51/tests'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/root/src/rhel7-os-update/libcap-2.51/tests'
make: *** [all] Error 2

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
Comment 1 Andrew G. Morgan 2021-06-22 00:29:34 UTC
I can reproduce this with:

   make COPTS="-O2 -std=c89" all

It also throws up some other warnings, so I'll address those as well.
Comment 2 Andrew G. Morgan 2021-06-22 00:54:28 UTC
It looks like we did have this working at some point in the past:

   https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=d45a3d4812598fc056499fa4622be4af58076bd5 (libcap-2.29)

This is now fixed again as of this (will eventually be included in libcap-2.52):

   https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=06ec53d0c9fcddcc071a0e07731e6c83238400e6

Note You need to log in before you can comment on or make changes to this bug.