HDFGroup / HDFGroup/hdf5

Allow "-c" to be anywhere on the command line of the legacy compiler wrappers

Open
#6,320 3 comments 0 reactions 1 assignee Claimed by @jhendersonHDF View on GitHub
Dominant language
C
Stars
988
Forks
355
Avg merge
4d 2h
Merged PRs (30d)
12

Description

The compiler wrappers h5cc and h5fc now need the "-c" option to be at the beginning of the compile line. If "-c" is not at the beginning, the scripts do not give a warning but instead mangle the compile line:

> h5fc test.f90 -c
ifort: command line error: no files specified; for help type "ifort -help"
compile failed with command: /opt/intel/oneapi/compiler/latest/bin/ifort -c -c -I/usr/local/include

or

> h5fc -show -O3 -c test.f90
/opt/intel/oneapi/compiler/latest/bin/ifort -c -c test.f90 -I/usr/local/include

My build system usually adds "-c" to the end of the compiler flags when only compiling, so this change in the behavior of the compiler wrappers affected me until I realized that the placement of "-c" was important.

An improvement would be to not try to strip "-c" from the argument list and not add it to the compile_args:

```
diff -up hdf5-2.0.0/config/libh5cc.in.orig hdf5-2.0.0/config/libh5cc.in
--- hdf5-2.0.0/config/libh5cc.in.orig 2026-02-11 16:26:50.169412698 -0500
+++ hdf5-2.0.0/config/libh5cc.in 2026-02-11 16:27:20.453250437 -0500
@@ -182,9 +182,6 @@ for arg in $@ ; do
add_rpath="no"
;;
-c)
- compile_args="${compile_args:+${compile_args} }$arg"
- shift
-
do_link="no"
;;
*)

```

This works because "-c" is still passed to the compiler along with the rest of the compile line. With this small change, the new compiler wrappers behave like the pre-2.0 wrappers with regard to recognizing "-c":

> h5fc -show -O3 -c test.f90
/opt/intel/oneapi/compiler/latest/bin/ifort -O3 -c test.f90 -I/usr/local/include

Please consider this small change so that others using the legacy compiler wrappers do not run into any unexpected issues with the placement of "-c" on the command line.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.