Skip to content

[clang] target attributes with arch= doesn't work if -march is set #153199

@usamoi

Description

@usamoi

This compiles compiles without any flags, but fails with -march=x86-64-v2.

__attribute__((__always_inline__, target("sse"))) void g() {}
__attribute__((target("arch=x86-64,sse"))) void f() { g(); }
clang f.c -shared -march=x86-64-v2
f.c:2:55: error: always_inline function 'g' requires target feature 'sse3', but would be inlined into function 'f' that is compiled without support for 'sse3'
    2 | __attribute__((target("arch=x86-64,sse"))) void f() { g(); }
      |                                                       ^
1 error generated.

This compiles compiles without any flags or with -march=x86-64, -march=x86-64-v2, -march=x86-64-v3, -march=x86-64-v4, but fails with -march=znver1, -march=znver2, -march=znver3, -march=znver4, -march=znver5. It also compiles with -march=native even if sys::getHostCPUName() detects my cpu as znver5.

__attribute__((__always_inline__, target("avx512fp16"))) void g() {}
__attribute__((target("arch=x86-64-v4,avx512fp16"))) void f() { g(); }
clang f.c -shared -march=znver5
f.c:2:65: error: always_inline function 'g' requires target feature 'gfni', but would be inlined into function 'f' that is compiled without support for 'gfni'
    2 | __attribute__((target("arch=x86-64-v4,avx512fp16"))) void f() { g(); }
      |                                                                 ^
1 error generated.

cc tensorchord/pgvecto.rs#650

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions