-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler-rt: Provide __cpu_indicator_init, __cpu_model and __cpu_features2 #20081
base: master
Are you sure you want to change the base?
Conversation
#1018 ? |
Yep that was it. Thanks. |
Missing support for these symbols is a blocker for compiling error: ld.lld: undefined symbol: __cpu_indicator_init
note: referenced by gc-get.c:584 (src/gc-get.c:584)
note: mdbx-static.o:(scan4seq_resolver) in archive [...]/libmdbx.a
error: ld.lld: undefined symbol: __cpu_model
note: referenced by gc-get.c:587 (src/gc-get.c:587)
note: mdbx-static.o:(scan4seq_resolver) in archive [...]/libmdbx.a I really appreciate this PR and hope it gets merged soon. 🫡 |
As a temporary solution, you can use cpu_model, which provides __cpu_indicator_init and __cpu_model symbols. |
577394c
to
167cb40
Compare
Rebased to latest master. |
These match what LLVM expects and generates when building multiversioned functions (e.g. functions tagged with attributes target or target_clones). The actual CPU detection reuses the logic under std/zig/system/x86.zig, and transforms it into the values that LLVM-generated code expects. These values are auto-generated using a new tool (tools/update_x86_cpu_model_enums.zig) which parses the relevant file in the LLVM codebase and generates Zig enums out of it.
- Use pointers in export builtin - Update names for Type enum tag
167cb40
to
a481fa8
Compare
Rebased again . I'm not entirely happy with |
The new logic is closer to how it's done in C where any unspecified enum simply increments the previous value.
Is it actually problematic if the standard library |
Fixes #18074, original PR was #18193.
This PR adds support for X86/X86_64 CPU model detection and function multiversioning in C/C++ via the target and target_clones attributes (compatible with LLVM's, which in turn is compatible with libgcc's). It adds
__cpu_indicator_init
,__cpu_model
and__cpu_features2
symbols to compiler-rt for x86/x86_64 which reuse the CPU detection logic under std/zig/system/x86.zig and transform the detected features into the values expected by LLVM-generated code. These values are kept in sync with LLVM using a new tool (tools/update_x86_cpu_model_enums.zig) which parses llvm/include/llvm/TargetParser/X86TargetParser.def in LLVM to generate the corresponding Zig enums.This PR also adds a standalone test that the symbols are emitted when the
target
attribute is used in C.While this functionality could in principle contribute to solving
issue #4591(edit: wrong issue, its #1018), I think it would be best to use a Zig-specific solution for richer CPU detection capabilities, leveraging std.Target.* instead of relying only on the feature set supported by LLVM/libgcc. The changes in this PR would therefore only be useful for C/C++ compatibility with Clang and gcc.