Closed Bug 1983399 Opened 9 months ago Closed 9 months ago

dbtool.c:75:15: error: type of ‘sftkdb_known_attributes_size’ does not match original declaration [-Werror=lto-type-mismatch]

Categories

(NSS :: Libraries, defect)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: nvinson234, Unassigned)

Details

Attachments

(1 file)

Steps to reproduce:

  1. export CFLAGS="-march=native -O3 -flto=auto -pipe -Wno-error -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -ffat-lto-objects"
  2. export CXXFLAGS="-march=native -O3 -flto=auto -pipe -Wno-error -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -ffat-lto-objects"
  3. export CPPFLAGS="-I/usr/include/nspr"
  4. export XCFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
  5. make -C coreconf CC=x86_64-pc-linux-gnu-gcc USE_64=1
  6. export XCFLAGS="${CFLAGS} ${CPPFLAGS} -D_FILE_OFFSET_BITS=64"
  7. make CC=x86_64-pc-linux-gnu-gcc CCC=x86_64-pc-linux-gnu-g++ 'AR=x86_64-pc-linux-gnu-ar rc $@' RANLIB=x86_64-pc-linux-gnu-ranlib OPTIMIZER= USE_64=1 disable_ckbi=0 NSINSTALL="${PWD}/$(find -type f -name nsinstall)" -C . OS_TEST=x86_64
  8. Observe error

Actual results:

Build fails with following error message:

dbtool.c:75:15: error: type of ‘sftkdb_known_attributes_size’ does not match original declaration [-Werror=lto-type-mismatch]
75 | extern size_t sftkdb_known_attributes_size;
| ^

Expected results:

nss should build successfully.

This bug report is based on the Gentoo bug report: https://bugs.gentoo.org/961590

The procedure given above is based on the steps Gentoo's portage takes when building nss.

Following additional information provided by Eli Schwartz:

Link-Time Optimization is a massively global compiler optimization pass which is pretty handy for producing faster executables. It also has the interesting property that because the compiler does whole-program analysis using bytecode, it can save type information and perform error checks that it normally doesn’t have enough insight for. In particular, checking for ODR issues and checking function type signature mismatches.

Note that all the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.

Additional update. I've created a github PR to fix this issue. https://github.com/nss-dev/nss/pull/31

Thanks.

sftkdb_known_attributes_size is defined with conflicting types. In /lib/softtoken/sdb.c it is defined as a 'const size_t'; whereas in lib/softtoken/sftkdbti.h it is defined as an 'unsigned int'. The correct type for sftkdb_known_attributes_size is size_t since its value is derived from the size of the sftkdb_known_attributes array.

This bug is now fixed. closing.

Status: UNCONFIRMED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: