[PATCH] D21033: Add runtime support for __cpu_model (__builtin_cpu_supports)

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 16:26:23 PDT 2016


mehdi_amini added inline comments.

================
Comment at: lib/builtins/cpu_model.c:709
@@ +708,3 @@
+  unsigned int __cpu_features[1];
+} __cpu_model;
+
----------------
This definition (which should probably be documented as (with the previous declaration) *is* the public API of this file) is a "common" (tentative definition in C).
On MachO, these are not part of the symbol table (I had to pull my "Joker card" Nick Kledzik to figure) in the static archive by default.

I can see as solution:

- make sure we run `ranlib -c` on the archive to include the common in the symbol table
- make the file a C++ file (there is no "tentative definition" and as such "common" in C++).
- build with -fno-common
- Define the symbol with an explicit initialization: `} __cpu_model = { 0, 0, 0, { 0 } };`

(I may miss other possible solutions)


http://reviews.llvm.org/D21033





More information about the llvm-commits mailing list