thanks for catching that, seem like we only check for the linux path :)

Edwin Lu <e...@rivosinc.com> 於 2024年7月23日 週二 02:45 寫道:

> Hi Kito,
>
>
> On 7/22/2024 8:19 AM, Kito Cheng wrote:
> > Corresponding implementation in compiler-rt already merged in LLVM
> > side, so I plan to merge this into trunk tomorrow if no strong
> > objections.
> >
> > NOTE: This has been tested with clang/llvm within our internal CI.
>
> > On Mon, Jul 22, 2024 at 10:16 PM Kito Cheng <kito.ch...@sifive.com>
> wrote:
> >>
> >> This provides a common abstraction layer to probe the available
> extensions at
> >> run-time. These functions can be used to implement function
> multi-versioning or
> >> to detect available extensions.
> >>
> >> The advantages of providing this abstraction layer are:
> >> - Easy to port to other new platforms.
> >> - Easier to maintain in GCC for function multi-versioning.
> >>    - For example, maintaining platform-dependent code in C code/libgcc
> is much
> >>      easier than maintaining it in GCC by creating GIMPLEs...
> >>
> >> This API is intended to provide the capability to query minimal common
> available extensions on the system.
> >>
> >> Proposal in riscv-c-api-doc:
> https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74
> >>
> >> Full function multi-versioning implementation will come later. We are
> posting
> >> this first because we intend to backport it to the GCC 14 branch to
> unblock
> >> LLVM 19 to use this with GCC 14.2, rather than waiting for GCC 15.
> >>
> >> Changes since v2:
> >> - Prevent it initialize more than once.
> >>
> >> Changes since v1:
> >> - Fix the format.
> >> - Prevented race conditions by introducing a local variable to avoid
> load/store
> >>    operations during the computation of the feature bit.
> >>
> >> libgcc/ChangeLog:
> >>
> >>          * config/riscv/feature_bits.c: New.
> >>          * config/riscv/t-elf (LIB2ADD): Add feature_bits.c.
> >> ---
> >>   libgcc/config/riscv/feature_bits.c | 313 +++++++++++++++++++++++++++++
> >>   libgcc/config/riscv/t-elf          |   1 +
> >>   2 files changed, 314 insertions(+)
> >>   create mode 100644 libgcc/config/riscv/feature_bits.c
> >>
> >> diff --git a/libgcc/config/riscv/feature_bits.c
> b/libgcc/config/riscv/feature_bits.c
> >> new file mode 100644
> >> index 00000000000..cce4fbfa6be
> >> --- /dev/null
> >> +++ b/libgcc/config/riscv/feature_bits.c
> >> @@ -0,0 +1,313 @@
> >> +
> >> +void __init_riscv_feature_bits ()
> >> +{
> >> +  if (__init)
> >> +    return;
> >> +
> >> +#ifdef __linux
> >> +  __init_riscv_features_bits_linux ();
> >> +#else
> >> +  /* Unsupported, just initlizaed that into all zeros.  */
> >> +  __riscv_feature_bits.length = 0
>
> I don't know enough about this to be able to comment on the patch
> itself. There's just a missing semicolon here which slipped its way into
> the v3 patch which would cause errors when trying to build on non-linux
> targets.
>
> ../../../../../../gcc/libgcc/config/riscv/feature_bits.c:307:34: error:
> expected ';' before '__riscv_vendor_feature_bits'
>    307 |   __riscv_feature_bits.length = 0
>        |                                  ^
>        |                                  ;
>    308 |   __riscv_vendor_feature_bits.length = 0;
>        |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> make[5]: *** [../../../../../../gcc/libgcc/static-object.mk:17:
> feature_bits.o] Error 1
>
>
> >> +  __riscv_vendor_feature_bits.length = 0;
> >> +  __riscv_vendor_feature_bits.vendorID = 0;
> >> +#endif
> >> +
> >> +  __init = 1;
> >> +}
>
> Edwin
>
>
>
>

Reply via email to