Skip to content

Solaris: only pass SunPro -erroff to SunPro compilers#6570

Open
hyoklee wants to merge 1 commit into
HDFGroup:developfrom
hyoklee:fix-solaris-clang-erroff
Open

Solaris: only pass SunPro -erroff to SunPro compilers#6570
hyoklee wants to merge 1 commit into
HDFGroup:developfrom
hyoklee:fix-solaris-clang-erroff

Conversation

@hyoklee

@hyoklee hyoklee commented Jul 25, 2026

Copy link
Copy Markdown
Member

Fixes #6569

Problem

On Solaris, both flag files append the SunPro-only -erroff option for every compiler, bundled with -DBSD_COMP in a single list element:

if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
  list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP")

Since that is one list element, target_compile_options() passes it to the compiler as one argument. Clang rejects it and the build fails on the very first object file:

[  0%] Building C object src/CMakeFiles/hdf5-static.dir/H5.c.o
clang: error: unknown argument: '-erroff=%none -DBSD_COMP'
gmake[2]: *** [src/CMakeFiles/hdf5-static.dir/build.make:76: src/CMakeFiles/hdf5-static.dir/H5.c.o] Error 1

GCC masks the bug rather than hitting it: it parses the leading -e of -erroff=... as the linker entry-symbol option and consumes the rest as that option's argument, so at compile time the whole string is simply discarded. Reproducible anywhere:

$ echo 'int main(void){return 0;}' > t.c
$ gcc "-erroff=%none -DBSD_COMP" -c t.c -o t.o ; echo $?
0
$ clang "-erroff=%none -DBSD_COMP" -c t.c -o t.o
clang: error: unknown argument: '-erroff=%none -DBSD_COMP'

A side effect worth noting: -DBSD_COMP was not actually reaching any Solaris compiler as a define, under GCC or SunPro.

Fix

Pass -erroff=%none only when the compiler is Oracle Developer Studio (SunPro), and append -DBSD_COMP as its own list element so it is a separate argument for all Solaris compilers. Same change in the C and C++ flag files; nothing else is touched.

Testing

Built and tested on Solaris 11.4 in CI:

  • clang 19 — was failing at H5.c.o; now 0 compiler errors, 0 compiler warnings, 2847/2847 tests passed.
  • gcc 15.2.0 — unaffected, as expected, since it was silently discarding the flag before. Still green.

No behavior change on any non-SunOS platform: the modified branch is inside if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS").

On SunOS the C and C++ flag files appended the single string
"-erroff=%none -DBSD_COMP" to HDF5_CMAKE_C/CXX_FLAGS. Because that is one
list element, target_compile_options() hands it to the compiler as one
argument, and -erroff is an Oracle Developer Studio option to begin with.
gcc silently ignores the result (it parses the leading -e as the linker
entry-symbol option), but clang errors out:

  clang: error: unknown argument: '-erroff=%none -DBSD_COMP'

which breaks the build on the first object file. As a side effect,
-DBSD_COMP was never actually reaching the compiler as a define.

Emit -erroff=%none only for SunPro, and append -DBSD_COMP as its own list
element so it is passed as a separate argument on all Solaris compilers.

Fixes HDFGroup#6569

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

  • config
    • @lrknox (manually added) — approval required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To be triaged

Development

Successfully merging this pull request may close these issues.

Solaris: SunPro-only -erroff flag is passed to clang and breaks the build

1 participant