Skip to content

CC compiler minor version extraction is broken #1076

@berrange

Description

@berrange

The top level buildenv.mk file extracts the compiler version as follows:

CC_VERSION := $(shell $(CC) -dumpversion)
CC_VERSION_MAJOR := $(shell echo $(CC_VERSION) | cut -f1 -d.)
CC_VERSION_MINOR := $(shell echo $(CC_VERSION) | cut -f2 -d.)

This logic only works if '-dumpversion' prints a multi-digit version string, but at some point GCC has switched to only printing the major version number

eg with gcc-9.3.1 RPM

# gcc -dumpversion
9

eg with gcc-14.2.1 RPM

$ gcc -dumpversion
14

This breaks the 'cut' commands above. When the delimiter is NOT present, the field selector has no effect and it will always return the original input string, no matter what field is requested.

IOW, when GCC 14.2.1 RPM, both CC_VERSION_MAJOR and CC_VERSION_MINOR are getting set to '14'.

Fortunately the only comparison that buildenv.mk does with CC_VERSION_MAJOR/MINOR are checking for ancient GCC versions, but this is a latent bug that may hit future conparisons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions