Bug 1381582 - LONG_WIDTH is incorrectly set to the 64 on 32 bit platforms (it's blocking e.g. grep build)
Summary: LONG_WIDTH is incorrectly set to the 64 on 32 bit platforms (it's blocking e....
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Florian Weimer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-04 13:26 UTC by Jaroslav Škarvada
Modified: 2016-10-10 17:45 UTC (History)
12 users (show)

Fixed In Version: glibc-2.24.90-9.fc26
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-05 20:37:33 UTC
Type: Bug


Attachments (Terms of Use)
Reproducer (207 bytes, text/x-csrc)
2016-10-04 13:30 UTC, Jaroslav Škarvada
no flags Details
Proposed host fix (300 bytes, patch)
2016-10-04 13:37 UTC, Jaroslav Škarvada
no flags Details | Diff

Description Jaroslav Škarvada 2016-10-04 13:26:07 UTC
Description of problem:
LONG_WIDTH is incorrectly set to the 64 on 32 bit platforms.

Version-Release number of selected component (if applicable):
gcc-6.2.1-2.fc26.i686

How reproducible:
Always

Steps to Reproduce:
1. mock -r fedora-rawhide-i386 chroot
2. gcc -D_GNU_SOURCE -o width width.c
3. ./width

Actual results:
sizeof(long)=4 LONG_WIDTH=64 LONG_MIN=-2147483648 LONG_MAX=2147483647

Expected results:
sizeof(long)=4 LONG_WIDTH=32 LONG_MIN=-2147483648 LONG_MAX=2147483647

Additional info:
I think the reason is the following new code from the /usr/include/limits.h:

/* The integer width macros are not defined by GCC's <limits.h> before
   GCC 7, or if _GNU_SOURCE rather than
   __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature.  */
#if __GLIBC_USE (IEC_60559_BFP_EXT)
...
# if LONG_MAX == 0x7fffffffL
#  ifndef LONG_WIDTH
#   define LONG_WIDTH 32
#  endif
#  ifndef ULONG_WIDTH
#   define ULONG_WIDTH 32
#  endif
# else
#  ifndef LONG_WIDTH
#   define LONG_WIDTH 64
#  endif
#  ifndef ULONG_WIDTH
#   define ULONG_WIDTH 64
#  endif
# endif

but LONG_MAX is not defined in the check, it's defined later thus LONG_WIDTH is
incorrectly set to the 64 even on 32 bit platforms.

I think the check should be rewritten to the following:
# if __LONG_MAX__ == 0x7fffffffL

It's blocking build (make check) of the grep-2.26, koji build log with the failure:
https://kojipkgs.fedoraproject.org/work/tasks/8044/15928044/build.log

Comment 1 Jaroslav Škarvada 2016-10-04 13:27:53 UTC
(In reply to Jaroslav Škarvada from comment #0)
> Steps to Reproduce:
> 1. mock -r fedora-rawhide-i386 chroot
Should be
mock -r fedora-rawhide-i386 shell

Comment 2 Jaroslav Škarvada 2016-10-04 13:30:03 UTC
Created attachment 1207189 [details]
Reproducer

Comment 3 Jaroslav Škarvada 2016-10-04 13:31:53 UTC
glibc-2.24.90-8.fc26.i686

Comment 4 Jaroslav Škarvada 2016-10-04 13:37:25 UTC
Created attachment 1207198 [details]
Proposed host fix

This host fix fixed the problem for me.

Comment 5 Florian Weimer 2016-10-04 15:13:14 UTC
gcc -Wundef -Wsystem-headers gives:

In file included from /usr/lib/gcc/x86_64-redhat-linux/6.2.1/include/limits.h:168:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/6.2.1/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/6.2.1/include/limits.h:34,
                 from u.c:1:
/usr/include/limits.h:167:6: warning: "LONG_MAX" is not defined [-Wundef]
 # if LONG_MAX == 0x7fffffffL
      ^~~~~~~~

Comment 6 Fedora Update System 2016-10-05 20:29:58 UTC
grep-2.26-1.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-6c2e016299

Comment 7 Fedora Update System 2016-10-10 17:43:14 UTC
grep-2.26-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.


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