Bug 1980549

Summary: h5cc passes through flags from package build process
Product: [Fedora] Fedora EPEL Reporter: taw-rhb
Component: hdf5Assignee: Orion Poplawski <orion>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: epel7CC: dakingun, igor.raits, orion, scitech-bugs, trpost
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: hdf5-1.8.12-13.el7 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-09-24 20:56:23 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:

Description taw-rhb 2021-07-08 20:00:16 UTC
Description of problem:

The compiler driver program 'h5cc' includes what appear to be the CFLAGS from the package build process.  This causes problems because those flags include things which meaningfully change the interpretation of source code (-D_BSD_SOURCE), as well as other things that should be chosen by the user such as optimisation and debug flags (-O2, -g and others).

I believe this happens because the HDF5 library's autotools build process copies CFLAGS into the output of h5cc.  It expects H5_CFLAGS to be used instead, for flags to be used for building HDF5 itself but not to be passed through to h5cc.

I noticed the problem because Meson uses the output of h5cc as one way to detect HDF5, in the absence of a pkg-config file.  Stripping out the extra flags in Meson was discussed as a potential solution, but is really more of a band-aid/hacky solution: https://github.com/mesonbuild/meson/issues/8932 - see that issue for some more background.

I believe this is exactly the same problem as reported and fixed earlier for Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=1794625
Here's the fix used over there: https://src.fedoraproject.org/rpms/hdf5/c/6a442e16217e3eee5ecd670a57297c73cd81cdc5?branch=rawhide


Version-Release number of selected component (if applicable):
Version     : 1.8.12
Release     : 12.el7


How reproducible:
100%


Steps to Reproduce:
1. Run h5cc -c -show


Actual results:
$ h5cc -c -show
gcc -I/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_BSD_SOURCE -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c


Expected results:
$ h5cc -c -show
gcc -I/usr/include -c


Additional info:

Comment 1 Fedora Update System 2021-09-16 03:50:11 UTC
FEDORA-EPEL-2021-cac52e951e has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2021-cac52e951e

Comment 2 Fedora Update System 2021-09-16 19:10:15 UTC
FEDORA-EPEL-2021-cac52e951e has been pushed to the Fedora EPEL 7 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2021-cac52e951e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 3 Fedora Update System 2021-09-24 20:56:23 UTC
FEDORA-EPEL-2021-cac52e951e has been pushed to the Fedora EPEL 7 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 4 taw-rhb 2022-02-10 15:43:52 UTC
The situation has improved, but there are still some incorrect flags in the h5cc output:

$ rpm -q hdf5-devel
hdf5-devel-1.8.12-13.el7.x86_64
$ /usr/bin/h5cc -c -show
gcc -I/usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_BSD_SOURCE -c
$

These (particularly -D_BSD_SOURCE) break programs trying to use the library.

On a Fedora (35) system, there are no extra flags:

$ rpm -q hdf5-devel
hdf5-devel-1.10.7-2.fc35.x86_64
$ h5cc -c -show
gcc -I/usr/include -c