You are right David and now I remember the thing about ms-extensions.
Declspec was part of those extensions and enabling it by default caused
errors with specific code so declspec was changed to general attribute
instead.
Since I have clang git build (trying to upstream some patches used by
MSYS2), I tried it also:
https://paste.ubuntu.com/23957478/

While for 3.9.x Clang `-fms-extensions` didn't hurt, master branch require
some corrections but it is another issue.


2017-02-09 0:15 GMT+01:00 David Grayson <davidegray...@gmail.com>:

> I can confirm that MSYS2's x86_64 clang++ compiler does not support
> __popcnt but does support __builtin_popcount.  I looked into it a
> little bit, and found out that the clang commit that adds the __popcnt
> builtins is very recent (September 2016).  I seems like it has not
> made it into a release yet.
>
> Here is the commit:
>
> https://github.com/llvm-mirror/clang/commit/5eb95c4c284486351e3ed0fdad011a
> cf41540c8b
>
> The source code archive that Alexey used to build the MSYS2 clang++
> does not have the changes from that commit in it:
>
> http://repo.msys2.org/mingw/sources/mingw-w64-clang-3.9.1-3.src.tar.gz
>
> I don't intend to submit any more patches for this issue.  Jacek has
> already committed my patch to mingw-w64 (thanks!).  Once the new
> version of clang comes out and people start using it there should not
> be any problems.  If any clang users are itching to use __popcnt
> before the new version of clang comes out, they can easily remove the
> #if I put in intrin-impl.h.  They could also use __has_builtin in
> intrin-impl.h to detect whether clang has the builtin or not.
>
> Mateusz, the "CodeGen" folder in clang is not just used for MSVC libs,
> it has tons of general-purpose code for generating LLVM code from
> C/C++ code.
>
> --David Grayson
>
> On Wed, Feb 8, 2017 at 1:24 PM, Mateusz <mati...@gmail.com> wrote:
> > Opps, gmail put output into quote. Improved version:
> > $ clang++ popcnt.cc -std=c++14 -fms-extensions
> > popcnt.cc:9:26: error: use of undeclared identifier '__popcnt16'
> >     unsigned short usr = __popcnt16(us[i]);
> >                          ^
> > popcnt.cc:17:24: error: use of undeclared identifier '__popcnt'
> >     unsigned int uir = __popcnt(ui[i]);
> >                        ^
> > popcnt.cc:26:28: error: use of undeclared identifier '__popcnt64'; did
> you
> > mean '_popcnt64'?
> >     unsigned __int64 ulr = __popcnt64(ul[i]);
> >                            ^~~~~~~~~~
> >                            _popcnt64
> > D:\msys64\mingw64\bin\..\lib\clang\3.9.1\include\popcntintrin.h:90:1:
> note:
> > '_popcnt64' declared here
> > _popcnt64(long long __A)
> > ^
> > 3 errors generated.
> >
> >
> >
> > 2017-02-08 22:22 GMT+01:00 Mateusz <mati...@gmail.com>:
> >
> >> I think ms-extensions was made default option for mingw and msvc clang
> and
> >> codegen is used only for creating msvc libs. Here is Clang output
> anyway:
> >>
> >> $ clang++ popcnt.cc -std=c++14 -fms-extensions
> >> popcnt.cc:9:26: error: use of undeclared identifier '__popcnt16'
> >>     unsigned short usr = __popcnt16(us[i]);
> >>                          ^
> >> popcnt.cc:17:24: error: use of undeclared identifier '__popcnt'
> >>     unsigned int uir = __popcnt(ui[i]);
> >>                        ^
> >> popcnt.cc:26:28: error: use of undeclared identifier '__popcnt64'; did
> you
> >> mean '_popcnt64'?
> >>     unsigned __int64 ulr = __popcnt64(ul[i]);
> >>                            ^~~~~~~~~~
> >>                            _popcnt64
> >> D:\msys64\mingw64\bin\..\lib\clang\3.9.1\include\popcntintrin.h:90:1:
> >> note: '_popcnt64' declared here
> >> _popcnt64(long long __A)
> >> ^
> >> 3 errors generated.
> >>
> >> 2017-02-08 20:10 GMT+01:00 David Grayson <davidegray...@gmail.com>:
> >>
> >>> Mateusz, thanks for looking in to this.
> >>>
> >>> Here are the relevant lines from the clang source code that indicate
> >>> that it supports those builtins:
> >>>
> >>> https://github.com/llvm-mirror/clang/blob/3e45634a7f951c2306
> >>> e4b368f9fb8c8d80c48273/include/clang/Basic/Builtins.def#L760-L762
> >>> https://github.com/llvm-mirror/clang/blob/4cedfcc1ecf8387082
> >>> 183508604b7f47c634f708/lib/CodeGen/CGBuiltin.cpp#L804-L821
> >>>
> >>> Can you try your clang test again with the "-fms-extensions" argument?
> >>>
> >>> (I tried to test clang myself earlier but I had various issues.  I
> >>> could probably try again tonight if you don't want to.)
> >>>
> >>> --David
> >>>
> >>> On Wed, Feb 8, 2017 at 10:54 AM, Mateusz <mati...@gmail.com> wrote:
> >>> > MSYS2 native Clang test-popcnt.cpp:
> >>> >
> >>> > $ clang++ popcnt.cc -std=c++14
> >>> > popcnt.cc:9:26: error: use of undeclared identifier '__popcnt16'
> >>> >     unsigned short usr = __popcnt16(us[i]);
> >>> >                          ^
> >>> > popcnt.cc:17:24: error: use of undeclared identifier '__popcnt'
> >>> >     unsigned int uir = __popcnt(ui[i]);
> >>> >                        ^
> >>> > popcnt.cc:26:28: error: use of undeclared identifier '__popcnt64';
> did
> >>> you
> >>> > mean '_popcnt64'?
> >>> >     unsigned __int64 ulr = __popcnt64(ul[i]);
> >>> >                            ^~~~~~~~~~
> >>> >                            _popcnt64
> >>> > D:\msys64\mingw64\bin\..\lib\clang\3.9.1\include\
> popcntintrin.h:90:1:
> >>> note:
> >>> > '_popcnt64' declared here
> >>> > _popcnt64(long long __A)
> >>> > ^
> >>> > 3 errors generated.
> >>> >
> >>> > Probably its safe to enable it for Clang, I'll try tomorrow late.
> >>> >
> >>> > 2017-02-08 18:37 GMT+01:00 David Grayson <davidegray...@gmail.com>:
> >>> >
> >>> >> Hello.  This patch adds support for the Microsoft __popcnt16,
> __popcnt,
> >>> >> and __popcnt64 intrinsics, which are documented here:
> >>> >>
> >>> >> https://msdn.microsoft.com/en-us/library/bb385231.aspx
> >>> >>
> >>> >> I was trying to compile ANGLE recently and one of the first errors I
> >>> >> encountered was due to both GCC/mingw-w64 not supporting __popcnt.
> >>> >>
> >>> >> I attached the simple C++ program I used to test this patch.
> >>> >>
> >>> >> I am not totally sure, but it looks like Clang already supports the
> >>> >> __popcnt intrinsics because I saw code for it in the clang
> >>> repository.  So
> >>> >> that is why this patch has "#if !defined(__clang__)" around it.
> >>> >>
> >>> >> I read the documentation for intrin.h and intrin-impl.h and I
> believe
> >>> this
> >>> >> patch follows all the rules.  It would be great if it could be
> merged
> >>> in.
> >>> >> Thanks!
> >>> >>
> >>> >> --David Grayson
> >>> >>
> >>> >> ------------------------------------------------------------
> >>> >> ------------------
> >>> >> Check out the vibrant tech community on one of the world's most
> >>> >> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> >>> >> _______________________________________________
> >>> >> Mingw-w64-public mailing list
> >>> >> Mingw-w64-public@lists.sourceforge.net
> >>> >> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
> >>> >>
> >>> >>
> >>> > ------------------------------------------------------------
> >>> ------------------
> >>> > Check out the vibrant tech community on one of the world's most
> >>> > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> >>> > _______________________________________________
> >>> > Mingw-w64-public mailing list
> >>> > Mingw-w64-public@lists.sourceforge.net
> >>> > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
> >>>
> >>> ------------------------------------------------------------
> >>> ------------------
> >>> Check out the vibrant tech community on one of the world's most
> >>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> >>> _______________________________________________
> >>> Mingw-w64-public mailing list
> >>> Mingw-w64-public@lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
> >>>
> >>
> >>
> > ------------------------------------------------------------
> ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Mingw-w64-public mailing list
> > Mingw-w64-public@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to