Bug 1980549 - h5cc passes through flags from package build process
Summary: h5cc passes through flags from package build process
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: hdf5
Version: epel7
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Orion Poplawski
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2021-07-08 20:00 UTC by taw-rhb
Modified: 2022-02-10 15:43 UTC (History)
5 users (show)

Fixed In Version: hdf5-1.8.12-13.el7
Doc Type: ---
Doc Text:
Clone Of:
Last Closed: 2021-09-24 20:56:23 UTC
Type: Bug

Attachments (Terms of Use)

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:
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:

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
$ /usr/bin/h5cc -c -show

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
$ h5cc -c -show
gcc -I/usr/include -c

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