Skip to content

-msse4.2 should produce an error when passed to inappropriate targets #70143

Open
@sh1boot

Description

@sh1boot

Clang seems to accept (with a warning) -msse4 for any target, not just x86.

No problem, as expected:

clang-18 --target=amd64 -msse2 -c -xc /dev/null
clang-18 --target=amd64 -msse3 -c -xc /dev/null
clang-18 --target=amd64 -msse4 -c -xc /dev/null
clang-18 --target=amd64 -msse4.2 -c -xc /dev/null

Error, as expected:

$ clang-18 --target=arm64 -msse2 -c -xc /dev/null
clang-18: error: unsupported option '-msse2' for target 'arm64'
$ clang-18 --target=arm64 -msse3 -c -xc /dev/null
clang-18: error: unsupported option '-msse3' for target 'arm64'

Warning, this is unexpected behaviour:

$ clang-18 --target=arm64 -msse4 -c -xc /dev/null
clang-18: warning: argument unused during compilation: '-msse4' [-Wunused-command-line-argument]
$ clang-18 --target=arm64 -msse4.2 -c -xc /dev/null
clang-18: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]

This breaks feature detection in some cmake files which do not see a failure from clang, meaning sse4.2 appears to be available for the compilation target.

(unexpected behaviour exists for arm64 and riscv64 at least; I haven't tested others)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'compiler-rt:tsanThread sanitizer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions