[compiler-rt] [RISCV][compiler-rt] Small fixes for __riscv_feature_bits (PR #99958)

Piyou Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 19:55:41 PDT 2024


================
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "cpu_model.h"
----------------
BeMg wrote:

Here we have two solution to avoid the build fail

1. Move `feature_bits.c` from `compiler-rt/lib/builtins/riscv/feature_bits.c` to  `compiler-rt/lib/builtins/cpu_model/riscv.c`, and update the `compiler-rt/lib/builtins/CMakeLists.txt`. Then `cpu_model.h` can be searched correctly.  I create a commit for this case https://github.com/BeMg/llvm-project/commit/0aff090de58f1a0920952297fe6f803261186593
2. Simply copy code section from cpu_model.h to here

```
#if __has_attribute(constructor)
#if __GNUC__ >= 9
// Ordinarily init priorities below 101 are disallowed as they are reserved for
// the implementation. However, we are the implementation, so silence the
// diagnostic, since it doesn't apply to us.
#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
#endif
// We're choosing init priority 90 to force our constructors to run before any
// constructors in the end user application (starting at priority 101). This
// value matches the libgcc choice for the same functions.
#define CONSTRUCTOR_ATTRIBUTE __attribute__((constructor(90)))
#else
// FIXME: For MSVC, we should make a function pointer global in .CRT$X?? so that
// this runs during initialization.
#define CONSTRUCTOR_ATTRIBUTE
#endif
```

https://github.com/llvm/llvm-project/pull/99958


More information about the llvm-commits mailing list