Bug 1381582

Summary: LONG_WIDTH is incorrectly set to the 64 on 32 bit platforms (it's blocking e.g. grep build)
Product: [Fedora] Fedora Reporter: Jaroslav Škarvada <jskarvad>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: arjun.is, codonell, davejohansen, dj, fweimer, jakub, jwakely, law, mfabian, mpolacek, pfrankli, siddhesh
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.24.90-9.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-05 20:37:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproducer
none
Proposed host fix none

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.