Re: [Mingw-w64-public] [PATCH] Handle __CTOR_LIST__ for clang

2017-08-05 Thread David Grayson
I think Martell's last patch would have worked but it's not as safe as
I would like it to be.  I think the constructor and destructor lists
should not be defined in gccmain.c where they are used, because then
the compiler optimizer might start to get smart and stop optimizing
things in a bad way.  The kind of pointer arithmetic we're doing would
be undefined behavior since we're intentionally getting a pointer to
an object and then reading past the end of that object.

Also, I think we should add new symbols so there is no potential for a
clash with the symbols defined by the linker script in binutils.

So, attached to this email is a patch that worked for me (I was able
to compile and run a Qt Widgets application).  I'm not entirely sure
it would be a good patch to use though, since I'm not sure how GCC
picks names for its global constructor and destructor sections, and
how it sorts those names, so I'm not sure that the symbols we are
defining would really be in the right place.

--David Grayson

On Sat, Aug 5, 2017 at 4:45 AM, Martell Malone  wrote:
> Hey David,
>
>
>> Your binutils patch did not apply cleanly to binutils-2.27 but I got
>> it to work.  It looks pretty dangerous to me because you removed the
>> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
>> you're using .ctors and .dtors in your other patch, and other code
>> might use them too I suppose.
>
>
> It applies cleanly to HEAD.
> I changed to so that all it does is SORT the ctors and dtors sections.
> Someone would have to confirm though.
>
> Maybe crtexe.c is not linked into shared libraries since they are not EXEs.
>
>  That is exactly what happened there crtdll.c is used instead.
> Here is an updated patch which also applies to crtdll.c
>
> Also the only reason I am not putting it into gccmain.c is because I am
> having problems with creating it and then using is as a array.
> If someone is able to do that it would be much better.
>
> Transforming
> __attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void
> * const func_ptr __CTOR_LIST__[] = {(void *) -1};
> into
> func_ptr __CTOR_LIST__[]
> is being problematic within the one source.
>
> I'd gladly take direction from someone here on that if they have any ideas.
>
> Best,
> Martell
>
> On Sat, Aug 5, 2017 at 5:53 AM, David Grayson 
> wrote:
>
>> With your latest two patches, the toolchain compiles but I get an
>> error when building a shared library:
>>
>> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
>> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-gccmain.o):
>> In function `_do_global_dtors':
>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
>> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
>> w64-crt/crt/gccmain.c:25:
>> undefined reference to `__DTOR_END__'
>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
>> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
>> w64-crt/crt/gccmain.c:25:
>> undefined reference to `__DTOR_END__'
>> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
>> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_
>> a-gccmain.o):gccmain.c:(.data+0x0):
>> undefined reference to `__CTOR_END__'
>>
>> Maybe crtexe.c is not linked into shared libraries since they are not EXEs.
>>
>> --David
>>
>> On Fri, Aug 4, 2017 at 6:12 PM, David Grayson 
>> wrote:
>> > Oh, I mean that I got the patch to apply, but I don't know if it
>> > really *works*; the toolchain is still building at this time.  --David
>> >
>> > On Fri, Aug 4, 2017 at 6:11 PM, David Grayson 
>> wrote:
>> >> Your binutils patch did not apply cleanly to binutils-2.27 but I got
>> >> it to work.  It looks pretty dangerous to me because you removed the
>> >> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
>> >> you're using .ctors and .dtors in your other patch, and other code
>> >> might use them too I suppose.
>> >>
>> >> --David
>> >>
>> >> On Fri, Aug 4, 2017 at 5:39 PM, Martell Malone 
>> wrote:
>> >>> Hey David,
>> >>>
>> >>> This could be caused by gcc including it's own crtbegin.o and crtend.o
>> >>> I managed to install a toolchain with brew and I swapped out gcc's and
>> >>> mingw-w64's crtbegin and crtend.
>> >>> Everything seems to work here as intended.
>> >>> Attached is an updated patch that avoids crtbegin and crtend that
>> should
>> >>> work along with a patch for binutils.
>> >>>
>> >>> Kai could you give some input on the binutils patch.
>> >>> On a side note while we are at this we should change __image_base__
>> >>> to ___ImageBase and __ImageBase on x86 and x64 respectively.
>> >>> Best,
>> >>> Martell
>> >>>
>> >>> On Sat, Aug 5, 2017 at 12:20 AM, David Grayson <
>> davidegray...@gmail.com>
>> >>> wrote:
>> >>>
>>  Martell:
>> 
>>  My setup ( https://github.com/DavidEGrayson/nixcrpkgs ) 

[Mingw-w64-public] [PATCH 01/19] math: Add errors in assembly sources if no implementation exists

2017-08-05 Thread Martin Storsjö
This helps finding unimplemented functions; otherwise the symbol
will exist, but won't contain any implementation, so the function
will end up pointing at whatever other function the linker places
next.
---
 mingw-w64-crt/math/_chgsignl.S  | 2 ++
 mingw-w64-crt/math/ceil.S   | 2 ++
 mingw-w64-crt/math/ceilf.S  | 2 ++
 mingw-w64-crt/math/ceill.S  | 2 ++
 mingw-w64-crt/math/copysignl.S  | 2 ++
 mingw-w64-crt/math/floor.S  | 2 ++
 mingw-w64-crt/math/floorf.S | 2 ++
 mingw-w64-crt/math/floorl.S | 2 ++
 mingw-w64-crt/math/nearbyint.S  | 2 ++
 mingw-w64-crt/math/nearbyintf.S | 2 ++
 mingw-w64-crt/math/nearbyintl.S | 2 ++
 mingw-w64-crt/math/trunc.S  | 2 ++
 mingw-w64-crt/math/truncf.S | 2 ++
 13 files changed, 26 insertions(+)

diff --git a/mingw-w64-crt/math/_chgsignl.S b/mingw-w64-crt/math/_chgsignl.S
index 3876465..2eb7de8 100644
--- a/mingw-w64-crt/math/_chgsignl.S
+++ b/mingw-w64-crt/math/_chgsignl.S
@@ -45,5 +45,7 @@ __MINGW_USYMBOL(_chgsignl):
movl%eax,12(%esp)
fldt4(%esp)
ret
+#else
+#error Not supported on your platform yet
 #endif
 
diff --git a/mingw-w64-crt/math/ceil.S b/mingw-w64-crt/math/ceil.S
index 134029c..6458cec 100644
--- a/mingw-w64-crt/math/ceil.S
+++ b/mingw-w64-crt/math/ceil.S
@@ -128,4 +128,6 @@ __MINGW_USYMBOL(ceil):
 
addl$8,%esp
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/ceilf.S b/mingw-w64-crt/math/ceilf.S
index fe64149..31078e6 100644
--- a/mingw-w64-crt/math/ceilf.S
+++ b/mingw-w64-crt/math/ceilf.S
@@ -123,4 +123,6 @@ __MINGW_USYMBOL(ceilf):
 
addl$8,%esp
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/ceill.S b/mingw-w64-crt/math/ceill.S
index 724dd52..0152fb1 100644
--- a/mingw-w64-crt/math/ceill.S
+++ b/mingw-w64-crt/math/ceill.S
@@ -68,4 +68,6 @@ __MINGW_USYMBOL(ceill):
fldcw   4(%esp)
addl $8,%esp
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/copysignl.S b/mingw-w64-crt/math/copysignl.S
index 5194330..67b46d0 100644
--- a/mingw-w64-crt/math/copysignl.S
+++ b/mingw-w64-crt/math/copysignl.S
@@ -43,4 +43,6 @@ __MINGW_USYMBOL(copysignl):
movl%eax,12(%esp)
fldt4(%esp)
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/floor.S b/mingw-w64-crt/math/floor.S
index 5c31404..932df0f 100644
--- a/mingw-w64-crt/math/floor.S
+++ b/mingw-w64-crt/math/floor.S
@@ -180,4 +180,6 @@ __MINGW_USYMBOL(floor):
 
addl$8,%esp
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/floorf.S b/mingw-w64-crt/math/floorf.S
index 45da320..cb182a3 100644
--- a/mingw-w64-crt/math/floorf.S
+++ b/mingw-w64-crt/math/floorf.S
@@ -63,4 +63,6 @@ __MINGW_USYMBOL(floorf):
 
addl$8,%esp
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/floorl.S b/mingw-w64-crt/math/floorl.S
index 7398743..ec99b92 100644
--- a/mingw-w64-crt/math/floorl.S
+++ b/mingw-w64-crt/math/floorl.S
@@ -76,4 +76,6 @@ __MINGW_USYMBOL(floorl):
 
addl$8,%esp
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/nearbyint.S b/mingw-w64-crt/math/nearbyint.S
index 6aa1046..5c38570 100644
--- a/mingw-w64-crt/math/nearbyint.S
+++ b/mingw-w64-crt/math/nearbyint.S
@@ -61,4 +61,6 @@ __MINGW_USYMBOL(nearbyint):
popl%ecx
popl%eax
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/nearbyintf.S b/mingw-w64-crt/math/nearbyintf.S
index 54f64fd..146ea47 100644
--- a/mingw-w64-crt/math/nearbyintf.S
+++ b/mingw-w64-crt/math/nearbyintf.S
@@ -61,4 +61,6 @@ __MINGW_USYMBOL(nearbyintf):
popl%ecx
popl%eax
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/nearbyintl.S b/mingw-w64-crt/math/nearbyintl.S
index f0aca0f..8f0e539 100644
--- a/mingw-w64-crt/math/nearbyintl.S
+++ b/mingw-w64-crt/math/nearbyintl.S
@@ -62,4 +62,6 @@ __MINGW_USYMBOL(nearbyintl):
popl%ecx
popl%eax
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/trunc.S b/mingw-w64-crt/math/trunc.S
index d2fca29..86f61e9 100755
--- a/mingw-w64-crt/math/trunc.S
+++ b/mingw-w64-crt/math/trunc.S
@@ -103,4 +103,6 @@ __MINGW_USYMBOL(trunc):
fldcw   (%esp)
addl$8, %esp
ret
+#else
+#error Not supported on your platform yet
 #endif
diff --git a/mingw-w64-crt/math/truncf.S b/mingw-w64-crt/math/truncf.S
index 626b9a5..4b399da 100755
--- a/mingw-w64-crt/math/truncf.S
+++ b/mingw-w64-crt/math/truncf.S
@@ -83,4 +83,6 @@ __MINGW_USYMBOL(truncf):
 fldcw   (%esp)
 addl$8, %esp
 ret
+#else
+#error Not supported on your platform yet
 

[Mingw-w64-public] [PATCH 10/19] math: Implement the exp2() wrappers using assembly on aarch64

2017-08-05 Thread Martin Storsjö
The LLVM optimizer replaces a call to pow(2, x) back into a call to
exp2(x), which ends up in an infinite loop/recursion here. To avoid
the issue, one could either build exp2.c (or easier to accomplish, all
of libmingwex.a) using -fno-builtin or -ffreestanding, or produce the
exp2() function wrappers using assembly instead, to force a function
call to the real pow/powf functions.
---
 mingw-w64-crt/math/arm/exp2.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/mingw-w64-crt/math/arm/exp2.c b/mingw-w64-crt/math/arm/exp2.c
index 6be1fba..8fc80c4 100644
--- a/mingw-w64-crt/math/arm/exp2.c
+++ b/mingw-w64-crt/math/arm/exp2.c
@@ -44,6 +44,33 @@
 
 #include 
 
+#if defined(__aarch64__) || defined(_ARM64_)
+
+// On aarch64, LLVM optimizes a pow(2, x) call back into a call to exp2(x).
+// To avoid this, we could either build without optimization, using 
-fno-builtin
+// or -ffreestanding (or -fno-builtin-pow -fno-builtin-powf), but ideally only
+// this file, or produce the exp2 wrappers  with assembly.
+asm(
+".def exp2;  .scl 2; .type 32; .endef\n\t"
+".def exp2f; .scl 2; .type 32; .endef\n\t"
+
+".text\n\t"
+".align 4\n\t"
+".globl exp2\n\t"
+".globl exp2f\n\t"
+
+"exp2:\n\t"
+"fmov d1, d0\n\t"
+"fmov d0, #2.0\n\t"
+"b pow\n\t"
+
+"exp2f:\n\t"
+"fmov s1, s0\n\t"
+"fmov s0, #2.0\n\t"
+"b powf\n\t");
+
+#else
+
 double exp2(double x)
 {
 return pow(2, x);
@@ -53,6 +80,7 @@ float exp2f(float x)
 {
 return powf(2, x);
 }
+#endif
 
 long double exp2l(long double x)
 {
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 06/19] headers: Skip the inline interlocked functions for aarch64 (as on all other non-i386 archs)

2017-08-05 Thread Martin Storsjö
These are skipped on x86_64, arm and aarch64 - in practice the condition
maybe should be inverted to only include i386.
---
 mingw-w64-headers/include/interlockedapi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-headers/include/interlockedapi.h 
b/mingw-w64-headers/include/interlockedapi.h
index 49f5cd7..bec2a93 100755
--- a/mingw-w64-headers/include/interlockedapi.h
+++ b/mingw-w64-headers/include/interlockedapi.h
@@ -14,7 +14,7 @@ extern "C" {
 #endif
 
 #if !defined (NOWINBASEINTERLOCK) && !defined (_NTOS_)
-#if !defined (__x86_64__) && !defined (__ia64__) && !defined (__arm__)
+#if !defined (__x86_64__) && !defined (__ia64__) && !defined (__arm__) && 
!defined (__aarch64__)
   WINBASEAPI LONG WINAPI InterlockedIncrement (LONG volatile *lpAddend);
   WINBASEAPI LONG WINAPI InterlockedDecrement (LONG volatile *lpAddend);
   WINBASEAPI LONG WINAPI InterlockedExchange (LONG volatile *Target, LONG 
Value);
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 02/19] setjmp.h: Add a fallback definition for unsupported architectures

2017-08-05 Thread Martin Storsjö
This allows including the header without errors, if building for an
architecture that we lack setjmp support for so far.

This matches what wine have got at the end of their setjmp.h.
---
 mingw-w64-headers/crt/setjmp.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/mingw-w64-headers/crt/setjmp.h b/mingw-w64-headers/crt/setjmp.h
index 79c28a5..c931c77 100644
--- a/mingw-w64-headers/crt/setjmp.h
+++ b/mingw-w64-headers/crt/setjmp.h
@@ -162,6 +162,11 @@ extern "C" {
 unsigned long long D[8];
   } _JUMP_BUFFER;
 
+#else
+
+#define _JBLEN 1
+#define _JBTYPE int
+
 #endif
 
 #ifndef _JMP_BUF_DEFINED
-- 
2.7.4


--
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


Re: [Mingw-w64-public] [PATCH 01/19] math: Add errors in assembly sources if no implementation exists

2017-08-05 Thread JonY via Mingw-w64-public
On 08/05/2017 09:14 PM, Martin Storsjö wrote:
> This helps finding unimplemented functions; otherwise the symbol
> will exist, but won't contain any implementation, so the function
> will end up pointing at whatever other function the linker places
> next.

I would prefer these checks be in the autoconfigury layer where:

...blah blah test...
AC_CASE([$math_platform],
[arm32], [AC_DEFINE(USE_ARM32_MATH)],
[arm64], [...]
[AC_MSG_ERROR([Unsupported platform])
...


That way, we don't need to keep growing the if/else macros as more
platforms are added.

Consider also using AM_CONDITIONAL and other automake constructs if
they're separate files to be compiled.


signature.asc
Description: OpenPGP digital signature
--
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


Re: [Mingw-w64-public] [PATCH] Handle __CTOR_LIST__ for clang

2017-08-05 Thread Martell Malone
>
> I think Martell's last patch would have worked but it's not as safe as
> I would like it to be. I think the constructor and destructor lists

should not be defined in gccmain.c where they are used, because then
> the compiler optimizer might start to get smart and stop optimizing
> things in a bad way.

That won't happen, this is what the attribute __used__ is for.
The issue I have is about casting in a clean way.
I also don't see the point in iterating through a list to get to the end
and then navigating back through it again if you have a pointer to the last
element.

>
> Also, I think we should add new symbols so there is no potential for a
> clash with the symbols defined by the linker script in binutils.

As I said in a previous email this would be one way to solve it yes.
Here is what I said
> This would mean that programs linked with LD would have an extra 2
pointers in the table but it should be fine otherwise.
I would be cleaner and better to change the linker script though.

On Sat, Aug 5, 2017 at 6:15 PM, David Grayson 
wrote:

> Oops, here is the patch.
>
> On Sat, Aug 5, 2017 at 10:14 AM, David Grayson 
> wrote:
> > I think Martell's last patch would have worked but it's not as safe as
> > I would like it to be.  I think the constructor and destructor lists
> > should not be defined in gccmain.c where they are used, because then
> > the compiler optimizer might start to get smart and stop optimizing
> > things in a bad way.  The kind of pointer arithmetic we're doing would
> > be undefined behavior since we're intentionally getting a pointer to
> > an object and then reading past the end of that object.
> >
> > Also, I think we should add new symbols so there is no potential for a
> > clash with the symbols defined by the linker script in binutils.
> >
> > So, attached to this email is a patch that worked for me (I was able
> > to compile and run a Qt Widgets application).  I'm not entirely sure
> > it would be a good patch to use though, since I'm not sure how GCC
> > picks names for its global constructor and destructor sections, and
> > how it sorts those names, so I'm not sure that the symbols we are
> > defining would really be in the right place.
> >
> > --David Grayson
> >
> > On Sat, Aug 5, 2017 at 4:45 AM, Martell Malone 
> wrote:
> >> Hey David,
> >>
> >>
> >>> Your binutils patch did not apply cleanly to binutils-2.27 but I got
> >>> it to work.  It looks pretty dangerous to me because you removed the
> >>> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
> >>> you're using .ctors and .dtors in your other patch, and other code
> >>> might use them too I suppose.
> >>
> >>
> >> It applies cleanly to HEAD.
> >> I changed to so that all it does is SORT the ctors and dtors sections.
> >> Someone would have to confirm though.
> >>
> >> Maybe crtexe.c is not linked into shared libraries since they are not
> EXEs.
> >>
> >>  That is exactly what happened there crtdll.c is used instead.
> >> Here is an updated patch which also applies to crtdll.c
> >>
> >> Also the only reason I am not putting it into gccmain.c is because I am
> >> having problems with creating it and then using is as a array.
> >> If someone is able to do that it would be much better.
> >>
> >> Transforming
> >> __attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void
> >> * const func_ptr __CTOR_LIST__[] = {(void *) -1};
> >> into
> >> func_ptr __CTOR_LIST__[]
> >> is being problematic within the one source.
> >>
> >> I'd gladly take direction from someone here on that if they have any
> ideas.
> >>
> >> Best,
> >> Martell
> >>
> >> On Sat, Aug 5, 2017 at 5:53 AM, David Grayson 
> >> wrote:
> >>
> >>> With your latest two patches, the toolchain compiles but I get an
> >>> error when building a shared library:
> >>>
> >>> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
> >>> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-gccmain.o):
> >>> In function `_do_global_dtors':
> >>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
> >>> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
> >>> w64-crt/crt/gccmain.c:25:
> >>> undefined reference to `__DTOR_END__'
> >>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
> >>> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
> >>> w64-crt/crt/gccmain.c:25:
> >>> undefined reference to `__DTOR_END__'
> >>> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
> >>> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_
> >>> a-gccmain.o):gccmain.c:(.data+0x0):
> >>> undefined reference to `__CTOR_END__'
> >>>
> >>> Maybe crtexe.c is not linked into shared libraries since they are not
> EXEs.
> >>>
> >>> --David
> >>>
> >>> On Fri, Aug 4, 2017 at 6:12 PM, David Grayson  >
> >>> wrote:
> >>> > Oh, I mean that I got the patch to apply, 

[Mingw-w64-public] [Project News|New Builds]

2017-08-05 Thread niXman


Hi,

The new builds of MinGW-W64 based on GCC-6.4.0 is uploaded.
MinGW-w64 v5.x is used.


32-bit:
posix-sjlj: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/6.4.0/threads-posix/sjlj/i686-6.4.0-release-posix-sjlj-rt_v5-rev0.7z
posix-dwarf: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/6.4.0/threads-posix/dwarf/i686-6.4.0-release-posix-dwarf-rt_v5-rev0.7z
win32-sjlj: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/6.4.0/threads-win32/sjlj/i686-6.4.0-release-win32-sjlj-rt_v5-rev0.7z
win32-dwarf: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/6.4.0/threads-win32/dwarf/i686-6.4.0-release-win32-dwarf-rt_v5-rev0.7z


64-bit:
posix-sjlj: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/6.4.0/threads-posix/sjlj/x86_64-6.4.0-release-posix-sjlj-rt_v5-rev0.7z
posix-seh: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/6.4.0/threads-posix/seh/x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z
win32-sjlj: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/6.4.0/threads-win32/sjlj/x86_64-6.4.0-release-win32-sjlj-rt_v5-rev0.7z
win32-seh: 
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/6.4.0/threads-win32/seh/x86_64-6.4.0-release-win32-seh-rt_v5-rev0.7z




The online installer is also available:
https://sf.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe



--
Regards, niXman
___
Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:
https://sf.net/p/mingw-w64/

--
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


Re: [Mingw-w64-public] [PATCH] Handle __CTOR_LIST__ for clang

2017-08-05 Thread David Grayson
Oops, here is the patch.

On Sat, Aug 5, 2017 at 10:14 AM, David Grayson  wrote:
> I think Martell's last patch would have worked but it's not as safe as
> I would like it to be.  I think the constructor and destructor lists
> should not be defined in gccmain.c where they are used, because then
> the compiler optimizer might start to get smart and stop optimizing
> things in a bad way.  The kind of pointer arithmetic we're doing would
> be undefined behavior since we're intentionally getting a pointer to
> an object and then reading past the end of that object.
>
> Also, I think we should add new symbols so there is no potential for a
> clash with the symbols defined by the linker script in binutils.
>
> So, attached to this email is a patch that worked for me (I was able
> to compile and run a Qt Widgets application).  I'm not entirely sure
> it would be a good patch to use though, since I'm not sure how GCC
> picks names for its global constructor and destructor sections, and
> how it sorts those names, so I'm not sure that the symbols we are
> defining would really be in the right place.
>
> --David Grayson
>
> On Sat, Aug 5, 2017 at 4:45 AM, Martell Malone  
> wrote:
>> Hey David,
>>
>>
>>> Your binutils patch did not apply cleanly to binutils-2.27 but I got
>>> it to work.  It looks pretty dangerous to me because you removed the
>>> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
>>> you're using .ctors and .dtors in your other patch, and other code
>>> might use them too I suppose.
>>
>>
>> It applies cleanly to HEAD.
>> I changed to so that all it does is SORT the ctors and dtors sections.
>> Someone would have to confirm though.
>>
>> Maybe crtexe.c is not linked into shared libraries since they are not EXEs.
>>
>>  That is exactly what happened there crtdll.c is used instead.
>> Here is an updated patch which also applies to crtdll.c
>>
>> Also the only reason I am not putting it into gccmain.c is because I am
>> having problems with creating it and then using is as a array.
>> If someone is able to do that it would be much better.
>>
>> Transforming
>> __attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void
>> * const func_ptr __CTOR_LIST__[] = {(void *) -1};
>> into
>> func_ptr __CTOR_LIST__[]
>> is being problematic within the one source.
>>
>> I'd gladly take direction from someone here on that if they have any ideas.
>>
>> Best,
>> Martell
>>
>> On Sat, Aug 5, 2017 at 5:53 AM, David Grayson 
>> wrote:
>>
>>> With your latest two patches, the toolchain compiles but I get an
>>> error when building a shared library:
>>>
>>> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
>>> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-gccmain.o):
>>> In function `_do_global_dtors':
>>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
>>> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
>>> w64-crt/crt/gccmain.c:25:
>>> undefined reference to `__DTOR_END__'
>>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
>>> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
>>> w64-crt/crt/gccmain.c:25:
>>> undefined reference to `__DTOR_END__'
>>> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
>>> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_
>>> a-gccmain.o):gccmain.c:(.data+0x0):
>>> undefined reference to `__CTOR_END__'
>>>
>>> Maybe crtexe.c is not linked into shared libraries since they are not EXEs.
>>>
>>> --David
>>>
>>> On Fri, Aug 4, 2017 at 6:12 PM, David Grayson 
>>> wrote:
>>> > Oh, I mean that I got the patch to apply, but I don't know if it
>>> > really *works*; the toolchain is still building at this time.  --David
>>> >
>>> > On Fri, Aug 4, 2017 at 6:11 PM, David Grayson 
>>> wrote:
>>> >> Your binutils patch did not apply cleanly to binutils-2.27 but I got
>>> >> it to work.  It looks pretty dangerous to me because you removed the
>>> >> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
>>> >> you're using .ctors and .dtors in your other patch, and other code
>>> >> might use them too I suppose.
>>> >>
>>> >> --David
>>> >>
>>> >> On Fri, Aug 4, 2017 at 5:39 PM, Martell Malone 
>>> wrote:
>>> >>> Hey David,
>>> >>>
>>> >>> This could be caused by gcc including it's own crtbegin.o and crtend.o
>>> >>> I managed to install a toolchain with brew and I swapped out gcc's and
>>> >>> mingw-w64's crtbegin and crtend.
>>> >>> Everything seems to work here as intended.
>>> >>> Attached is an updated patch that avoids crtbegin and crtend that
>>> should
>>> >>> work along with a patch for binutils.
>>> >>>
>>> >>> Kai could you give some input on the binutils patch.
>>> >>> On a side note while we are at this we should change __image_base__
>>> >>> to ___ImageBase and __ImageBase on x86 and x64 

[Mingw-w64-public] Where are headers defined?

2017-08-05 Thread Jeroen Ooms
Trying to build opendap [1] but the configure script can't find uuid.h:

checking uuid/uuid.h usability... no
checking uuid/uuid.h presence... no
checking for uuid/uuid.h... no
checking uuid.h usability... no
checking uuid.h presence... no
checking for uuid.h... no
configure: error: Could not find uuid.h

I see mingw-w64 includes libuuid.a but no header is included? Are
these headers part of some other file in mingw-w64?


[1] https://www.opendap.org/index.php/software/libdap/3.18.1

--
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


Re: [Mingw-w64-public] FW: Section sizes too big in object files (possible bug?)

2017-08-05 Thread Madalinski Piotr
Thanks LH_Mouse,

I've tested the -malign-data option and it does the job.

Sadly for now I'm stuck with gcc 4.9.2 in production and this option was 
introduced in 5.0.
Ah, well... At least the problem will solve itself in future, and the attribute 
approach must suffice for now.

Best regards,
Piotr Madaliński

-Original Message-
From: Liu Hao [mailto:lh_mo...@126.com]
Sent: 2 sierpnia 2017 17:54
To: mingw-w64-public@lists.sourceforge.net; Madalinski Piotr 

Subject: Re: [Mingw-w64-public] FW: Section sizes too big in object files 
(possible bug?)

On 2017/8/2 19:42, Madalinski Piotr wrote:
> Hi all,
>
> I'm having trouble with getting correct section sizes under MinGW.
> The example below demonstrates the issue:
>
> (... abridgement ...)
>
> Adding align(1) attribute to the data definition is a workaround, that fixes 
> the problem, but due to external factors I want to avoid adding it, if 
> possible.
> This behavior looks as a bug to me, but I can't say for sure.
> Anyhow - is there some other (than the align(1) attribute) approach that this 
> behavior can be changed? Compiler option maybe?
>

`-malign-data=abi` shall fix the problem by minimizing the alignment
requirement:

```plaintext
E:\Desktop>gcc test.c -Wl,-s && objdump -h a.exe | grep -F test_sec
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
   2 test_sec  0040  00404000  00404000  1c00  2**5

E:\Desktop>gcc test.c -Wl,-s -malign-data=abi && objdump -h a.exe | grep -F 
test_sec
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
   2 test_sec  0024  00404000  00404000  1c00  2**2

```

Reference:
https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/x86-Options.html#x86-Options

--
Best regards,
LH_Mouse

TRW Polska Sp. z o.o., ul. Rolnicza 33, 42-200 Czestochowa,
Sad Rejonowy w Czestochowie, KRS nr 077409
NIP nr 573-010-52-34, kapital zakladowy: 79.581.975 PLN

TRW Polska Sp. z o.o. Rolnicza 33 Str., 42-200 Czestochowa, Poland
District Court for Czestochowa, KRS no. 077409,
tax identification no. NIP 573-010-52-34, share capital: 79.581.975 PLN

Niniejsza wiadomosc moze zawierac informacje poufne oraz/lub prawnie chronione, 
przeznaczone do wylacznego uzytku adresata. Jesli nie jestescie Panstwo 
adresatem przesylki lub jesli otrzymaliscie ja Panstwo omylkowo, prosimy o 
bezzwloczne skontaktowanie sie z nadawca i usuniecie tej wiadomosci. Wszelkie 
kopiowanie, wykorzystanie lub rozpowszechnianie tej wiadomosci czy tez 
zawartych w niej informacji przez osoby inne niz adresat jest niedozwolone i 
moze spowodowac odpowiedzialnosc prawna.

This e-mail together with any attachments, may contain confidential and/or 
privileged information. If you are not the intended recipient or have received 
this e-mail in error, please notify the sender immediately and delete this 
e-mail. Any unauthorized copying, disclosure or distribution of the material in 
this e-mail or any attachments is strictly forbidden.
--
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


Re: [Mingw-w64-public] FW: Section sizes too big in object files (possible bug?)

2017-08-05 Thread Madalinski Piotr
> and you get the following from objdump:
>[ 20](sec  4)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x
>test_struct
>[ 21](sec  4)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0024 a
>[ 22](sec  4)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0028 b

>With the section size of 0x40.  In fact, when adding another copy of the test 
>structure after a, you will get the second one starting at 0x40, with a 
>section size of 0x80.  This is no >optimization, by the way.

>NOTE: this is without ANY optimization flags.  If you compile with -O1, you get
>[ 20](sec  7)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x b
>[ 21](sec  7)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0004 a
>[ 22](sec  7)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0020
>test_struct

Well, yes, I suppose the location of variables in a single section is not 
deterministic.
But I'm using only one variable per section (actually I'm using -data-sections 
option),
and am arranging the sections in the linker script to create a memory region 
that can be mmaped form external file.

The linker script looks something like this:
 .mmaped_region BLOCK(__section_alignment__) : SUBALIGN(1)
 {
*(.test_section1)
*(.test_section2)
}
The problem is that by default test_section1 is too big because of the padding, 
and test_section2 ends up in the wrong place.

Best regards,
Piotr Madalinski.

TRW Polska Sp. z o.o., ul. Rolnicza 33, 42-200 Czestochowa,
Sad Rejonowy w Czestochowie, KRS nr 077409
NIP nr 573-010-52-34, kapital zakladowy: 79.581.975 PLN

TRW Polska Sp. z o.o. Rolnicza 33 Str., 42-200 Czestochowa, Poland
District Court for Czestochowa, KRS no. 077409,
tax identification no. NIP 573-010-52-34, share capital: 79.581.975 PLN

Niniejsza wiadomosc moze zawierac informacje poufne oraz/lub prawnie chronione, 
przeznaczone do wylacznego uzytku adresata. Jesli nie jestescie Panstwo 
adresatem przesylki lub jesli otrzymaliscie ja Panstwo omylkowo, prosimy o 
bezzwloczne skontaktowanie sie z nadawca i usuniecie tej wiadomosci. Wszelkie 
kopiowanie, wykorzystanie lub rozpowszechnianie tej wiadomosci czy tez 
zawartych w niej informacji przez osoby inne niz adresat jest niedozwolone i 
moze spowodowac odpowiedzialnosc prawna.

This e-mail together with any attachments, may contain confidential and/or 
privileged information. If you are not the intended recipient or have received 
this e-mail in error, please notify the sender immediately and delete this 
e-mail. Any unauthorized copying, disclosure or distribution of the material in 
this e-mail or any attachments is strictly forbidden.

--
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


[Mingw-w64-public] [PATCH 17/19] winnt.h: Add arm64 specific handling of TEB

2017-08-05 Thread Martin Storsjö
---
 mingw-w64-headers/include/winnt.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/mingw-w64-headers/include/winnt.h 
b/mingw-w64-headers/include/winnt.h
index 9107a36..f48cb30 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -8395,6 +8395,17 @@ typedef DWORD (WINAPI 
*PRTL_RUN_ONCE_INIT_FN)(PRTL_RUN_ONCE, PVOID, PVOID *);
 FORCEINLINE PVOID GetFiberData (VOID) { return *(PVOID *)GetCurrentFiber 
(); }
 #endif /* arm */
 
+#if defined (__aarch64__) && !defined (__WIDL__)
+struct _TEB *NtCurrentTeb (VOID);
+PVOID GetCurrentFiber (VOID);
+PVOID GetFiberData (VOID);
+FORCEINLINE struct _TEB *NtCurrentTeb(VOID) { struct _TEB *teb;
+__asm ("mov %0, x18" : "=r" (teb));
+return teb; }
+FORCEINLINE PVOID GetCurrentFiber(VOID) { return 
(PVOID)(((PNT_TIB)NtCurrentTeb())->FiberData); }
+FORCEINLINE PVOID GetFiberData (VOID) { return *(PVOID *)GetCurrentFiber 
(); }
+#endif /* aarch64 */
+
 #ifndef _NTTMAPI_
 #define _NTTMAPI_
 
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 07/19] fenv: Add aarch64 specific codepaths in fenv functions, add aarch64 fenv.h header section

2017-08-05 Thread Martin Storsjö
The fpcr register used in aarch64 is the same as the fpscr register in 32
bit arm, but when the register is accessed via the msr/mrs instructions,
a 64 bit register has to be used - thus use a 64 bit local variable instead
of accessing a fenv_t directly.
---
 mingw-w64-crt/crt/CRT_fp10.c |  3 +++
 mingw-w64-crt/misc/feclearexcept.c   | 12 +---
 mingw-w64-crt/misc/fegetenv.c| 10 +++---
 mingw-w64-crt/misc/fegetexceptflag.c | 10 +++---
 mingw-w64-crt/misc/fegetround.c  |  6 +-
 mingw-w64-crt/misc/feholdexcept.c|  8 +++-
 mingw-w64-crt/misc/feraiseexcept.c   |  8 +++-
 mingw-w64-crt/misc/fesetenv.c| 14 +++---
 mingw-w64-crt/misc/fesetexceptflag.c | 13 ++---
 mingw-w64-crt/misc/fesetround.c  | 14 +++---
 mingw-w64-crt/misc/fetestexcept.c| 10 +++---
 mingw-w64-headers/crt/fenv.h | 16 +++-
 12 files changed, 99 insertions(+), 25 deletions(-)

diff --git a/mingw-w64-crt/crt/CRT_fp10.c b/mingw-w64-crt/crt/CRT_fp10.c
index 41cb573..f39b517 100644
--- a/mingw-w64-crt/crt/CRT_fp10.c
+++ b/mingw-w64-crt/crt/CRT_fp10.c
@@ -11,6 +11,9 @@ void _fpreset (void)
 #if defined(_ARM_) || defined(__arm__)
   __asm__ __volatile__ (
 "vmsr  fpscr, %0\n\t" : : "r"(0 /* INITIAL_FPSCR */));
+#elif defined(_ARM64_) || defined(__aarch64__)
+  __asm__ __volatile__ (
+"msr   fpcr, %0\n\t" : : "r"(0LL /* INITIAL_FPSCR */));
 #else
 #ifdef __GNUC__
   __asm__ ("fninit");
diff --git a/mingw-w64-crt/misc/feclearexcept.c 
b/mingw-w64-crt/misc/feclearexcept.c
index b5a3b70..673528b 100644
--- a/mingw-w64-crt/misc/feclearexcept.c
+++ b/mingw-w64-crt/misc/feclearexcept.c
@@ -5,7 +5,7 @@
  */
 #include 
 
-#if !(defined(_ARM_) || defined(__arm__))
+#if !(defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__))
 int __mingw_has_sse (void);
 
 int __mingw_has_sse(void)
@@ -32,7 +32,7 @@ int __mingw_has_sse(void)
 return 1;
   return 0;
 }
-#endif /* !(defined(_ARM_) || defined(__arm__)) */
+#endif /* !(defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__)) */
 
 /* 7.6.2.1
The feclearexcept function clears the supported exceptions
@@ -45,6 +45,12 @@ int feclearexcept (int excepts)
   __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
   _env.__cw &= ~(excepts & FE_ALL_EXCEPT);
   __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env));
+#elif defined(_ARM64_) || defined(__aarch64__)
+  unsigned __int64 fpcr;
+  (void) _env;
+  __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
+  fpcr &= ~(excepts & FE_ALL_EXCEPT);
+  __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr));
 #else
   int _mxcsr;
   if (excepts == FE_ALL_EXCEPT)
@@ -63,6 +69,6 @@ int feclearexcept (int excepts)
   _mxcsr &= ~(((excepts & FE_ALL_EXCEPT)));
   __asm__ volatile ("ldmxcsr %0" : : "m" (_mxcsr));
 }
-#endif /* defined(_ARM_) || defined(__arm__) */
+#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__) */
   return (0);
 }
diff --git a/mingw-w64-crt/misc/fegetenv.c b/mingw-w64-crt/misc/fegetenv.c
index 96f57e4..3196081 100644
--- a/mingw-w64-crt/misc/fegetenv.c
+++ b/mingw-w64-crt/misc/fegetenv.c
@@ -5,9 +5,9 @@
  */
 #include 
 
-#if !(defined(_ARM_) || defined(__arm__))
+#if !(defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__))
 int __mingw_has_sse (void);
-#endif /* !(defined(_ARM_) || defined(__arm__)) */
+#endif /* !(defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__)) */
 
 /* 7.6.4.1
The fegetenv function stores the current floating-point environment
@@ -17,6 +17,10 @@ int fegetenv (fenv_t * envp)
 {
 #if defined(_ARM_) || defined(__arm__)
   __asm__ volatile ("fmrx %0, FPSCR" : "=r" (*envp));
+#elif defined(_ARM64_) || defined(__aarch64__)
+  unsigned __int64 fpcr;
+  __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
+  envp->__cw = fpcr;
 #else
   __asm__ __volatile__ ("fnstenv %0;": "=m" (*envp));
  /* fnstenv sets control word to non-stop for all exceptions, so we
@@ -29,7 +33,7 @@ int fegetenv (fenv_t * envp)
   envp->__unused0 = (((unsigned int) _mxcsr) >> 16);
   envp->__unused1 = (((unsigned int) _mxcsr) & 0x);
 }
-#endif /* defined(_ARM_) || defined(__arm__) */
+#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__) */
   return 0;
 }
 
diff --git a/mingw-w64-crt/misc/fegetexceptflag.c 
b/mingw-w64-crt/misc/fegetexceptflag.c
index e8dae96..eaa940a 100644
--- a/mingw-w64-crt/misc/fegetexceptflag.c
+++ b/mingw-w64-crt/misc/fegetexceptflag.c
@@ -5,9 +5,9 @@
  */
 #include 
 
-#if !(defined(_ARM_) || defined(__arm__))
+#if !(defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__))
 extern int __mingw_has_sse (void);
-#endif /* !(defined(_ARM_) || defined(__arm__)) */
+#endif /* !(defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__)) */
 
 /* 7.6.2.2  
The fegetexceptflag 

[Mingw-w64-public] [PATCH 13/19] intrin-impl.h: Add aarch64 functions corresponding to the arm ones

2017-08-05 Thread Martin Storsjö
---
 mingw-w64-headers/include/psdk_inc/intrin-impl.h | 145 +++
 1 file changed, 145 insertions(+)

diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h 
b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
index a1c77b5..6f7d60e 100644
--- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
+++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
@@ -152,6 +152,24 @@ __INTRINSICS_USEINLINE
   : "memory", "cc"); \
return (old >> Offset) & 1; \
 }
+#elif defined(__aarch64__) || defined(_ARM64_)
+#define __buildbittesti(x, y, z, a, b) unsigned char x(b y *Base, y Offset) \
+{ \
+   unsigned int old, tmp1, tmp2; \
+   unsigned int bit = 1 << Offset; \
+   __asm__ __volatile__ ("dmb  sy\n\t" \
+"1: ldxr   %w[old], %[Base]\n\t" \
+"mov   %w[tmp1], %w[old]\n\t" \
+z "%w[tmp1], %w[tmp1], %w[bit]\n\t" \
+"stxr  %w[tmp2], %w[tmp1], %[Base]\n\t" \
+"cmp   %w[tmp2], #0\n\t" \
+"b.ne  1b\n\t" \
+"dmb   sy" \
+  : [old] "=" (old), [tmp1] "=" (tmp1), [tmp2] "=" (tmp2), [Base] 
"+m" (*Base) \
+  : [bit] a "r" (bit) \
+  : "memory", "cc"); \
+   return (old >> Offset) & 1; \
+}
 #endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || 
defined(_X86_) */
 
 /* This macro is used by YieldProcessor when compiling x86 w/o SSE2.
@@ -1069,6 +1087,133 @@ __buildbittesti(InterlockedBitTestAndComplement, 
__LONG32, "eor", /* unused para
 
 #endif /* defined(__arm__) || defined(_ARM_) */
 
+#if defined(__aarch64__) || defined(_ARM64_)
+
+#if __INTRINSIC_PROLOG(_interlockedbittestandset)
+unsigned char _interlockedbittestandset(__LONG32 *a, __LONG32 b);
+#if !__has_builtin(_interlockedbittestandset)
+__INTRINSICS_USEINLINE 
+__buildbittesti(_interlockedbittestandset, __LONG32, "orr", /* unused param 
*/, /* unused param */)
+#endif
+#define __INTRINSIC_DEFINED__interlockedbittestandset
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_interlockedbittestandreset)
+unsigned char _interlockedbittestandreset(__LONG32 *a, __LONG32 b);
+__INTRINSICS_USEINLINE 
+#if !__has_builtin(_interlockedbittestandreset)
+__buildbittesti(_interlockedbittestandreset, __LONG32, "bic", /* unused param 
*/, /* unused param */)
+#endif
+#define __INTRINSIC_DEFINED__interlockedbittestandreset
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_interlockedbittestandcomplement)
+unsigned char _interlockedbittestandcomplement(__LONG32 *a, __LONG32 b);
+#if !__has_builtin(_interlockedbittestandcomplement)
+__INTRINSICS_USEINLINE 
+__buildbittesti(_interlockedbittestandcomplement, __LONG32, "eor", /* unused 
param */, /* unused param */)
+#endif
+#define __INTRINSIC_DEFINED__interlockedbittestandcomplement
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(InterlockedBitTestAndSet)
+unsigned char InterlockedBitTestAndSet(volatile __LONG32 *a, __LONG32 b);
+#if !__has_builtin(InterlockedBitTestAndSet)
+__INTRINSICS_USEINLINE 
+__buildbittesti(InterlockedBitTestAndSet, __LONG32, "orr", /* unused param */, 
volatile)
+#endif
+#define __INTRINSIC_DEFINED_InterlockedBitTestAndSet
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(InterlockedBitTestAndReset)
+unsigned char InterlockedBitTestAndReset(volatile __LONG32 *a, __LONG32 b);
+#if !__has_builtin(InterlockedBitTestAndReset)
+__INTRINSICS_USEINLINE 
+__buildbittesti(InterlockedBitTestAndReset, __LONG32, "bic", /* unused param 
*/, volatile)
+#endif
+#define __INTRINSIC_DEFINED_InterlockedBitTestAndReset
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(InterlockedBitTestAndComplement)
+unsigned char InterlockedBitTestAndComplement(volatile __LONG32 *a, __LONG32 
b);
+#if !__has_builtin(InterlockedBitTestAndComplement)
+__INTRINSICS_USEINLINE 
+__buildbittesti(InterlockedBitTestAndComplement, __LONG32, "eor", /* unused 
param */, volatile)
+#endif
+#define __INTRINSIC_DEFINED_InterlockedBitTestAndComplement
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedAnd64)
+__MINGW_EXTENSION __int64 _InterlockedAnd64(__int64 volatile *, __int64);
+#if !__has_builtin(_InterlockedAnd64)
+__INTRINSICS_USEINLINE 
+__buildlogicali(_InterlockedAnd64, __int64, and)
+#endif
+#define __INTRINSIC_DEFINED__InterlockedAnd64
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedOr64)
+__MINGW_EXTENSION __int64 _InterlockedOr64(__int64 volatile *, __int64);
+#if !__has_builtin(_InterlockedOr64)
+__INTRINSICS_USEINLINE 
+__buildlogicali(_InterlockedOr64, __int64, or)
+#endif
+#define __INTRINSIC_DEFINED__InterlockedOr64
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedXor64)
+__MINGW_EXTENSION __int64 _InterlockedXor64(__int64 volatile *, __int64);
+#if !__has_builtin(_InterlockedXor64)
+__INTRINSICS_USEINLINE 
+__buildlogicali(_InterlockedXor64, __int64, xor)
+#endif
+#define __INTRINSIC_DEFINED__InterlockedXor64
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedIncrement64)

[Mingw-w64-public] [PATCH 00/19] ARM64 support in MinGW

2017-08-05 Thread Martin Storsjö
Hi,

This patchset adds initial support for targeting ARM64 in MinGW.

While Windows on ARM64 isn't publicly available yet (but rumored
to be released this fall), it is (somewhat) testable in Wine
(bootstrapped with some arm64 binaries from the windows 10 sdk,
by André Hentschel).

Additionally, MSVC targeting ARM64 isn't publicly available yet
either, but clang/LLVM is getting support for targeting this
OS/arch combo - it is usable already with the current trunk
version since very recently. For using with MinGW, a few other
patches are needed as well:
https://reviews.llvm.org/D36366
https://reviews.llvm.org/D36365
https://reviews.llvm.org/D36364
https://reviews.llvm.org/D36105
https://reviews.llvm.org/D36304
https://reviews.llvm.org/D33880


With this patchset, I have a usable MinGW environment for (some)
C projects (C++ support is still incomplete, and e.g. setjmp is
also yet unimplemented). In particular, I'm able to build all of
libav and run all of their regression tests, without errors, in wine.

Patch 18 adds a few empty structs to winnt.h for arm64 specific
structs - I'd appreciate help with filling them out in a
suitable clean-room manner (they are available in the win10 sdk).

// Martin



Martin Storsjö (19):
  math: Add errors in assembly sources if no implementation exists
  setjmp.h: Add a fallback definition for unsupported architectures
  crt: Add initial support for arm64 in mingw-w64-crt
Makefile.am/configure.ac
  crt: Add an initial libarm64 directory with def files
  headers: Detection of __aarch64__ in some main locations
  headers: Skip the inline interlocked functions for aarch64 (as on all
other non-i386 archs)
  fenv: Add aarch64 specific codepaths in fenv functions, add aarch64
fenv.h header section
  math: Use the same generic codepaths for aarch64 as for arm
  math: Add aarch64 assembly implementations of math functions
  math: Implement the exp2() wrappers using assembly on aarch64
  stdio: Add aarch64 assembly wrappers for the v*scanf functions
  intrin-impl.h: Include compiler builtins based parts on aarch64 as
well
  intrin-impl.h: Add aarch64 functions corresponding to the arm ones
  crtexe: Skip __initenv on aarch64 just as on arm
  crt: Skip .seh asm directives on aarch64, limit them to x86_64
  crt: Disable __mingw_init_ehandler on aarch64
  winnt.h: Add arm64 specific handling of TEB
  winnt.h: Add empty definition of arch specific structs for arm64
  crt: Disable win64 unwinding on arm64

 mingw-w64-crt/Makefile.am  |  253 +
 mingw-w64-crt/configure.ac |   21 +
 mingw-w64-crt/crt/CRT_fp10.c   |3 +
 mingw-w64-crt/crt/crt_handler.c|2 +-
 mingw-w64-crt/crt/crtdll.c |2 +-
 mingw-w64-crt/crt/crtexe.c |6 +-
 mingw-w64-crt/crt/gs_support.c |2 +-
 mingw-w64-crt/libarm64/Makefile.am | 1164 
 mingw-w64-crt/{libarm32 => libarm64}/*.def |0
 mingw-w64-crt/math/_chgsignl.S |5 +
 mingw-w64-crt/math/arm/exp2.c  |   30 +-
 mingw-w64-crt/math/arm/log2.c  |2 +-
 mingw-w64-crt/math/arm/scalbn.c|2 +-
 mingw-w64-crt/math/arm/sincos.c|2 +-
 mingw-w64-crt/math/ceil.S  |5 +
 mingw-w64-crt/math/ceilf.S |5 +
 mingw-w64-crt/math/ceill.S |5 +
 mingw-w64-crt/math/cephes_mconf.h  |4 +-
 mingw-w64-crt/math/copysignl.S |4 +
 mingw-w64-crt/math/fabs.c  |4 +-
 mingw-w64-crt/math/fabsf.c |4 +-
 mingw-w64-crt/math/fabsl.c |2 +-
 mingw-w64-crt/math/floor.S |5 +
 mingw-w64-crt/math/floorf.S|5 +
 mingw-w64-crt/math/floorl.S|5 +
 mingw-w64-crt/math/fma.c   |   12 +
 mingw-w64-crt/math/fmaf.c  |   12 +
 mingw-w64-crt/math/fmal.c  |2 +-
 mingw-w64-crt/math/fpclassifyf.c   |2 +-
 mingw-w64-crt/math/fpclassifyl.c   |2 +-
 mingw-w64-crt/math/isnan.c |2 +-
 mingw-w64-crt/math/isnanf.c|2 +-
 mingw-w64-crt/math/isnanl.c|2 +-
 mingw-w64-crt/math/lgammal.c   |4 +-
 mingw-w64-crt/math/lrint.c |5 +
 mingw-w64-crt/math/lrintf.c|5 +
 mingw-w64-crt/math/lrintl.c|2 +-
 mingw-w64-crt/math/nearbyint.S |7 +
 mingw-w64-crt/math/nearbyintf.S|7 +
 mingw-w64-crt/math/nearbyintl.S|7 +
 mingw-w64-crt/math/rint.c  

[Mingw-w64-public] [PATCH 03/19] crt: Add initial support for arm64 in mingw-w64-crt Makefile.am/configure.ac

2017-08-05 Thread Martin Storsjö
This is supported by llvm-dlltool only so far.

The actual def files in the libarm64 subdirectory are added in a separate 
commit.
---
 mingw-w64-crt/Makefile.am  | 253 +
 mingw-w64-crt/configure.ac |  21 
 2 files changed, 274 insertions(+)

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index fb6c4da..9b0b6d1 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -28,17 +28,21 @@ CPPFLAGS64=-m64
 if WITH_GENLIB
   AM_DLLTOOLFLAGS=-o $@
   DLLTOOLFLAGSARM32=-a arm
+  DLLTOOLFLAGSARM64=
   DLLTOOLFLAGS32=-a x86
   DLLTOOLFLAGS64=-a x86_64
   DTDEFARM32=$(GENLIB) $(DLLTOOLFLAGSARM32) $(AM_DLLTOOLFLAGS)
+  DTDEFARM64=$(GENLIB) $(DLLTOOLFLAGSARM64) $(AM_DLLTOOLFLAGS)
   DTDEF32=$(GENLIB) $(DLLTOOLFLAGS32) $(AM_DLLTOOLFLAGS)
   DTDEF64=$(GENLIB) $(DLLTOOLFLAGS64) $(AM_DLLTOOLFLAGS)
 else
   AM_DLLTOOLFLAGS=-k --as=$(AS) --output-lib $@
   DLLTOOLFLAGSARM32=-m arm
+  DLLTOOLFLAGSARM64=-m arm64
   DLLTOOLFLAGS32=--as-flags=--32 -m i386
   DLLTOOLFLAGS64=--as-flags=--64 -m i386:x86-64
   DTDEFARM32=$(DLLTOOL) $(DLLTOOLFLAGSARM32) $(AM_DLLTOOLFLAGS) --input-def
+  DTDEFARM64=$(DLLTOOL) $(DLLTOOLFLAGSARM64) $(AM_DLLTOOLFLAGS) --input-def
   DTDEF32=$(DLLTOOL) $(DLLTOOLFLAGS32) $(AM_DLLTOOLFLAGS) --input-def
   DTDEF64=$(DLLTOOL) $(DLLTOOLFLAGS64) $(AM_DLLTOOLFLAGS) --input-def
 endif
@@ -46,9 +50,11 @@ if DELAY_IMPORT_LIBS
   AM_DLLTOOLFLAGS += --output-delaylib $@.delayimp.a
 endif
 DTLIBARM32=$(DTDEFARM32) $(top_srcdir)/`echo $@ | $(SED) 
's|/lib|/|;s|\.a|.def|'`
+DTLIBARM64=$(DTDEFARM64) $(top_srcdir)/`echo $@ | $(SED) 
's|/lib|/|;s|\.a|.def|'`
 DTLIB32=$(DTDEF32) $(top_srcdir)/`echo $@ | $(SED) 's|/lib|/|;s|\.a|.def|'`
 DTLIB64=$(DTDEF64) $(top_srcdir)/`echo $@ | $(SED) 's|/lib|/|;s|\.a|.def|'`
 LDFLAGSARM32= -L$(top_builddir)/libarm32
+LDFLAGSARM64= -L$(top_builddir)/libarm64
 LDFLAGS32=-m32 -L$(top_builddir)/lib32
 LDFLAGS64=-m64 -L$(top_builddir)/lib64
 extra_include=-I$(top_srcdir)/include
@@ -354,6 +360,9 @@ src_libmingwexarm32=\
   math/arm/exp2.c   math/arm/log2.c   math/arm/scalbn.c
 math/arm/sincos.c
 endif
 
+# these only go into the ARM64 version:
+src_libmingwexarm64=\
+  math/arm/exp2.c   math/arm/log2.c   math/arm/scalbn.c
 math/arm/sincos.c
 
 
 # These intrinsics are target independent:
@@ -393,6 +402,9 @@ src_intrincs32=\
 # these only go into the ARM32 version:
 src_intrincsarm32=
 
+# these only go into the ARM64 version:
+src_intrincsarm64=
+
 if LIB32
 #
 # Compiling 32-bit runtime
@@ -1511,6 +1523,247 @@ endif
 # End ARM 32-bit runtime
 # ##
 
+if LIBARM64
+#
+# Compiling ARM 64-bit runtime
+#
+
+libarm64dir=$(prefix)/@LIBARM64SUFFIXDIR@
+crt64dir=$(libarm64dir)
+winrt64dir=$(libarm64dir)
+dx64dir=$(libarm64dir)
+
+if !W32API
+crt64_DATA = \
+  libarm64/crt1.olibarm64/crt2.o libarm64/crt1u.o   libarm64/crt2u.o   
 libarm64/dllcrt1.olibarm64/dllcrt2.o \
+  libarm64/CRT_fp8.o libarm64/CRT_fp10.o libarm64/txtmode.o libarm64/binmode.o 
 libarm64/crtbegin.o   libarm64/crtend.o \
+  libarm64/gcrt0.o   libarm64/gcrt1.olibarm64/gcrt2.o   
libarm64/CRT_glob.o libarm64/CRT_noglob.o
+else
+crt64_DATA =
+endif
+
+COMPILE64=$(COMPILE) $(CPPFLAGSARM64) $(extra_include) -D_SYSCRT=1 -DCRTDLL=1
+libarm64/crt1.o: crt/crtexe.c
+   $(COMPILE64) -c $< -o $@ -D__CRTDLL__ -U__MSVCRT__
+libarm64/crt2.o: crt/crtexe.c
+   $(COMPILE64) -c $< -o $@ -U__CRTDLL__ -D__MSVCRT__
+libarm64/crt1u.o: crt/ucrtexe.c
+   $(COMPILE64) -c $< -o $@ -D__CRTDLL__ -U__MSVCRT__
+libarm64/crt2u.o: crt/ucrtexe.c
+   $(COMPILE64) -c $< -o $@ -U__CRTDLL__ -D__MSVCRT__
+libarm64/dllcrt1.o: crt/crtdll.c
+   $(COMPILE64) -c $< -o $@ -D__CRTDLL__ -U__MSVCRT__
+libarm64/dllcrt2.o: crt/crtdll.c
+   $(COMPILE64) -c $< -o $@ -U__CRTDLL__ -D__MSVCRT__
+
+libarm64/gcrt0.o: profile/gcrt0.c
+   $(COMPILE) $(CPPFLAGSARM64) -c $< -o $@
+libarm64/gcrt1.o: profile/gcrt0.c
+   $(COMPILE) $(CPPFLAGSARM64) -c $< -o $@ -U__MSVCRT__
+libarm64/gcrt2.o: profile/gcrt0.c
+   $(COMPILE) $(CPPFLAGSARM64) -c $< -o $@ -D__MSVCRT__
+
+libarm64/%.o: crt/%.c
+   $(COMPILE) $(CPPFLAGSARM64) -c $< -o $@
+
+# These source files aren't compiled in to any library yet.  I'm not sure how 
/ where to do so.
+# The source files that I did compile somewhere I just guessed at anyway.
+#
+
+temp= \
+dxerr.c \
+test.c
+
+libarm64_LIBRARIES = libarm64/libkernel32.a
+libarm64_libkernel32_a_SOURCES = $(src_intrincs) $(src_intrincsarm64)
+libarm64_libkernel32_a_AR = $(DTLIBARM64) && $(AR) $(ARFLAGS)
+libarm64_libkernel32_a_CPPFLAGS=$(CPPFLAGSARM64) $(extra_include) 
$(AM_CPPFLAGS)
+
+if !W32API
+libarm64_LIBRARIES += libarm64/libmsvcrt.a
+libarm64_libmsvcrt_a_SOURCES = $(src_msvcrt32) libarm64/msvcrt.def.in
+libarm64_libmsvcrt_a_AR = $(DTDEFARM64) libarm64/msvcrt.def && $(AR) $(ARFLAGS)
+libarm64_libmsvcrt_a_CPPFLAGS=$(CPPFLAGSARM64) -D__LIBMSVCRT__ 
$(extra_include) 

[Mingw-w64-public] [PATCH 12/19] intrin-impl.h: Include compiler builtins based parts on aarch64 as well

2017-08-05 Thread Martin Storsjö
---
 mingw-w64-headers/include/psdk_inc/intrin-impl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h 
b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
index 352b686..a1c77b5 100644
--- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
+++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
@@ -1071,7 +1071,7 @@ __buildbittesti(InterlockedBitTestAndComplement, 
__LONG32, "eor", /* unused para
 
 /* * */
 
-#if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || 
defined(_X86_) || defined(__arm__) || defined(_ARM_)
+#if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || 
defined(_X86_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_)
 
 #if __INTRINSIC_PROLOG(__popcnt16)
 unsigned short __popcnt16(unsigned short);
@@ -1279,7 +1279,7 @@ void *_InterlockedExchangePointer(void *volatile 
*Target,void *Value) {
 #define __INTRINSIC_DEFINED__InterlockedExchangePointer
 #endif /* __INTRINSIC_PROLOG */
 
-#endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || 
defined(_X86_) || defined(__arm__) || defined(_ARM_) */
+#endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || 
defined(_X86_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_) */
 
 #if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || 
defined(_X86_)
 
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 05/19] headers: Detection of __aarch64__ in some main locations

2017-08-05 Thread Martin Storsjö
---
 mingw-w64-headers/crt/malloc.h|  2 +-
 mingw-w64-headers/include/winnt.h | 21 ++---
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/mingw-w64-headers/crt/malloc.h b/mingw-w64-headers/crt/malloc.h
index b4c9dc4..9d75ea6 100644
--- a/mingw-w64-headers/crt/malloc.h
+++ b/mingw-w64-headers/crt/malloc.h
@@ -136,7 +136,7 @@ void * __mingw_aligned_realloc (void *_Memory, size_t 
_Size, size_t _Offset);
 
 #if defined(_ARM_) || (defined(_X86_) && !defined(__x86_64))
 #define _ALLOCA_S_MARKER_SIZE 8
-#elif defined(__ia64__) || defined(__x86_64)
+#elif defined(__ia64__) || defined(__x86_64) || defined(__aarch64__)
 #define _ALLOCA_S_MARKER_SIZE 16
 #endif
 
diff --git a/mingw-w64-headers/include/winnt.h 
b/mingw-w64-headers/include/winnt.h
index ad077f8..9107a36 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -28,21 +28,28 @@ extern "C" {
 #endif
 
 #if defined(__x86_64) && \
-  !(defined(_X86_) || defined(__i386__) || defined(_IA64_) || defined 
(__arm__))
+  !(defined(_X86_) || defined(__i386__) || defined(_IA64_) || defined 
(__arm__) || defined(__aarch64__))
 #if !defined(_AMD64_)
 #define _AMD64_
 #endif
 #endif /* _AMD64_ */
 
 #if defined(__arm__) && \
-  !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_) || defined 
(__ia64__))
+  !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_) || defined 
(__ia64__) || defined(__aarch64__))
 #if !defined(_ARM_)
 #define _ARM_
 #endif
 #endif /* _ARM_ */
 
+#if defined(__aarch64__) && \
+  !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_) || defined 
(__ia64__) || defined(__arm__))
+#if !defined(_ARM64_)
+#define _ARM64_
+#endif
+#endif /* _ARM64_ */
+
 #if defined(__ia64__) && \
-  !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_) || defined 
(__arm__))
+  !(defined(_X86_) || defined(__x86_64) || defined(_AMD64_) || defined 
(__arm__) || defined(__aarch64__))
 #if !defined(_IA64_)
 #define _IA64_
 #endif
@@ -94,7 +101,7 @@ extern "C" {
 
 #undef  UNALIGNED  /* avoid redefinition warnings vs _mingw.h */
 #undef  UNALIGNED64
-#if defined (__ia64__) || defined (__x86_64__) || defined (__arm__)
+#if defined (__ia64__) || defined (__x86_64__) || defined (__arm__) || 
defined(__aarch64__)
 #define ALIGNMENT_MACHINE
 #define UNALIGNED __unaligned
 #if defined (_WIN64)
@@ -124,7 +131,7 @@ extern "C" {
 
 #if defined (__x86_64__) || defined (__i386__)
 #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT (DWORD)
-#elif defined (__ia64__) || defined (__arm__)
+#elif defined (__ia64__) || defined (__arm__) || defined(__aarch64__)
 #define PROBE_ALIGNMENT(_s) (TYPE_ALIGNMENT (_s) > TYPE_ALIGNMENT (DWORD) ? 
TYPE_ALIGNMENT (_s) : TYPE_ALIGNMENT (DWORD))
 #elif !defined (RC_INVOKED) && !defined (__WIDL__)
 #error No supported target architecture.
@@ -143,7 +150,7 @@ extern "C" {
 #include 
 
 #ifndef DECLSPEC_IMPORT
-#if (defined (__i386__) || defined (__ia64__) || defined (__x86_64__) || 
defined (__arm__)) && !defined (__WIDL__)
+#if (defined (__i386__) || defined (__ia64__) || defined (__x86_64__) || 
defined (__arm__) || defined(__aarch64__)) && !defined (__WIDL__)
 #define DECLSPEC_IMPORT __declspec (dllimport)
 #else
 #define DECLSPEC_IMPORT
@@ -258,7 +265,7 @@ extern "C" {
 #endif
 #endif /* FASTCALL */
 
-#if defined(_ARM_)
+#if defined(_ARM_) || defined(_ARM64_)
 #define NTAPI
 #else
 #define NTAPI __stdcall
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 14/19] crtexe: Skip __initenv on aarch64 just as on arm

2017-08-05 Thread Martin Storsjö
---
 mingw-w64-crt/crt/crtexe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index ae37e0f..bbef685 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -26,7 +26,7 @@ extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
 #define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
 #endif
 
-#if !defined(__initenv) && !defined(__arm__)
+#if !defined(__initenv) && !defined(__arm__) && !defined(__aarch64__)
 extern char *** __MINGW_IMP_SYMBOL(__initenv);
 #define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
 #endif
@@ -328,7 +328,7 @@ __tmainCRTStartup (void)
gcc inserts this call automatically for a function called main, but not 
for wmain.  */
 mainret = wmain (argc, argv, envp);
 #else
-#ifndef __arm__
+#if !defined(__arm__) && !defined(__aarch64__)
 __initenv = envp;
 #endif
 mainret = main (argc, argv, envp);
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 08/19] math: Use the same generic codepaths for aarch64 as for arm

2017-08-05 Thread Martin Storsjö
Just as on arm, long double is the same as double.
---
 mingw-w64-crt/math/arm/exp2.c |  2 +-
 mingw-w64-crt/math/arm/log2.c |  2 +-
 mingw-w64-crt/math/arm/scalbn.c   |  2 +-
 mingw-w64-crt/math/arm/sincos.c   |  2 +-
 mingw-w64-crt/math/cephes_mconf.h |  4 ++--
 mingw-w64-crt/math/fabs.c |  4 ++--
 mingw-w64-crt/math/fabsf.c|  4 ++--
 mingw-w64-crt/math/fabsl.c|  2 +-
 mingw-w64-crt/math/fmal.c |  2 +-
 mingw-w64-crt/math/fpclassifyf.c  |  2 +-
 mingw-w64-crt/math/fpclassifyl.c  |  2 +-
 mingw-w64-crt/math/isnan.c|  2 +-
 mingw-w64-crt/math/isnanf.c   |  2 +-
 mingw-w64-crt/math/isnanl.c   |  2 +-
 mingw-w64-crt/math/lgammal.c  |  4 ++--
 mingw-w64-crt/math/lrintl.c   |  2 +-
 mingw-w64-crt/math/rintl.c|  2 +-
 mingw-w64-crt/math/signbit.c  |  2 +-
 mingw-w64-crt/math/signbitf.c |  2 +-
 mingw-w64-crt/math/signbitl.c |  2 +-
 mingw-w64-crt/math/truncl.c   |  4 ++--
 mingw-w64-headers/crt/math.h  | 30 +++---
 22 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/mingw-w64-crt/math/arm/exp2.c b/mingw-w64-crt/math/arm/exp2.c
index 77e914d..6be1fba 100644
--- a/mingw-w64-crt/math/arm/exp2.c
+++ b/mingw-w64-crt/math/arm/exp2.c
@@ -56,7 +56,7 @@ float exp2f(float x)
 
 long double exp2l(long double x)
 {
-#if defined(__arm__) || defined(_ARM_)
+#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_)
 return exp2(x);
 #else
 #error Not supported on your platform yet
diff --git a/mingw-w64-crt/math/arm/log2.c b/mingw-w64-crt/math/arm/log2.c
index eeb690b..73c1a2d 100644
--- a/mingw-w64-crt/math/arm/log2.c
+++ b/mingw-w64-crt/math/arm/log2.c
@@ -56,7 +56,7 @@ float log2f(float x)
 
 long double log2l(long double x)
 {
-#if defined(__arm__) || defined(_ARM_)
+#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_)
 return log2(x);
 #else
 #error Not supported on your platform yet
diff --git a/mingw-w64-crt/math/arm/scalbn.c b/mingw-w64-crt/math/arm/scalbn.c
index f11fd37..a46e467 100644
--- a/mingw-w64-crt/math/arm/scalbn.c
+++ b/mingw-w64-crt/math/arm/scalbn.c
@@ -56,7 +56,7 @@ float scalbnf(float x, int exp)
 
 long double scalbnl(long double x, int exp)
 {
-#if defined(__arm__) || defined(_ARM_)
+#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_)
 return scalbn(x, exp);
 #else
 #error Not supported on your platform yet
diff --git a/mingw-w64-crt/math/arm/sincos.c b/mingw-w64-crt/math/arm/sincos.c
index 3bb86ee..099351f 100644
--- a/mingw-w64-crt/math/arm/sincos.c
+++ b/mingw-w64-crt/math/arm/sincos.c
@@ -20,7 +20,7 @@ void sincosf (float __x, float *p_sin, float *p_cos)
 
 void sincosl (long double __x, long double *p_sin, long double *p_cos)
 {
-#if defined(__arm__) || defined(_ARM_)
+#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_)
   *p_sin = sin(__x);
   *p_cos = cos(__x);
 #else
diff --git a/mingw-w64-crt/math/cephes_mconf.h 
b/mingw-w64-crt/math/cephes_mconf.h
index 832fae0..f502f18 100644
--- a/mingw-w64-crt/math/cephes_mconf.h
+++ b/mingw-w64-crt/math/cephes_mconf.h
@@ -66,7 +66,7 @@ extern double __QNAN;
 #endif
 
 /*long double*/
-#if defined(__arm__) || defined(_ARM_)
+#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_)
 #define MAXNUML1.7976931348623158E308
 #define MAXLOGL7.09782712893383996843E2
 #define MINLOGL-7.08396418532264106224E2
@@ -84,7 +84,7 @@ extern double __QNAN;
 #define PIL3.1415926535897932384626L
 #define PIO2L  1.5707963267948966192313L
 #define PIO4L  7.8539816339744830961566E-1L
-#endif /* defined(__arm__) || defined(_ARM_) */
+#endif /* defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || 
defined(_ARM64_) */
 
 #define isfinitel isfinite
 #define isinfl isinf
diff --git a/mingw-w64-crt/math/fabs.c b/mingw-w64-crt/math/fabs.c
index cf2e6ef..2011378 100644
--- a/mingw-w64-crt/math/fabs.c
+++ b/mingw-w64-crt/math/fabs.c
@@ -9,12 +9,12 @@
 double
 fabs (double x)
 {
-#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || 
defined(_ARM_)
+#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || 
defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
   return __builtin_fabs (x);
 #elif defined(__i386__) || defined(_X86_)
   double res = 0.0;
 
   asm ("fabs;" : "=t" (res) : "0" (x));
   return res;
-#endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || 
defined(_ARM_) */
+#endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || 
defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) */
 }
diff --git a/mingw-w64-crt/math/fabsf.c b/mingw-w64-crt/math/fabsf.c
index 5431c96..e8520d5 100644
--- a/mingw-w64-crt/math/fabsf.c
+++ b/mingw-w64-crt/math/fabsf.c
@@ -8,11 +8,11 @@ float fabsf (float x);
 float
 fabsf (float x)
 {
-#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || 

[Mingw-w64-public] [PATCH 15/19] crt: Skip .seh asm directives on aarch64, limit them to x86_64

2017-08-05 Thread Martin Storsjö
These asm directives are enabled on #ifdef _WIN64, but aren't supported
in LLVM on aarch64 (yet?).
---
 mingw-w64-crt/stdio/scanf2-template.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-crt/stdio/scanf2-template.S 
b/mingw-w64-crt/stdio/scanf2-template.S
index 892b7e6..bbd0e21 100644
--- a/mingw-w64-crt/stdio/scanf2-template.S
+++ b/mingw-w64-crt/stdio/scanf2-template.S
@@ -11,11 +11,11 @@
 .p2align 4,,15
 .globl  FCT
 .defFCT;.scl2;  .type   32; .endef
-#ifdef _WIN64
+#ifdef __x86_64__
 .seh_proc   FCT
 #endif
 FCT:
-#ifdef _WIN64
+#ifdef __x64_86__
 .seh_endprologue
 #endif
 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
defined(__i386__)
@@ -26,7 +26,7 @@ FCT:
 #elif defined(_ARM64_) || defined(__aarch64__)
 b   FWD
 #endif
-#ifdef _WIN64
+#ifdef __x86_64__
 .seh_endproc
 #endif
 .defFWD;  .scl2;  .type   32; .endef
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 19/19] crt: Disable win64 unwinding on arm64

2017-08-05 Thread Martin Storsjö
This allows building this file for now, until the necessary struct
(CONTEXT in winnt.h) is available.
---
 mingw-w64-crt/crt/gs_support.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-crt/crt/gs_support.c b/mingw-w64-crt/crt/gs_support.c
index c5c1773..0c6ac68 100644
--- a/mingw-w64-crt/crt/gs_support.c
+++ b/mingw-w64-crt/crt/gs_support.c
@@ -104,7 +104,7 @@ __declspec(noreturn) void __cdecl
 __report_gsfailure (ULONG_PTR StackCookie)
 {
   volatile UINT_PTR cookie[2] __MINGW_ATTRIB_UNUSED;
-#ifdef _WIN64
+#if defined(_WIN64) && !defined(__aarch64__)
   ULONG64 controlPC, imgBase, establisherFrame;
   PRUNTIME_FUNCTION fctEntry;
   PVOID hndData;
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 18/19] winnt.h: Add empty definition of arch specific structs for arm64

2017-08-05 Thread Martin Storsjö
---
The correct/official definition of these structs are available in
winnt.h in the win10 sdk (but they are not documented on e.g. MSDN).
I haven't looked closer at them other than noticing that they exist
there. This setup (with empty dummy structs) is enough for code to
compile without error at least, as long as one doesn't try to use
functions that need these structs.
---
 mingw-w64-headers/include/winnt.h | 97 +++
 1 file changed, 97 insertions(+)

diff --git a/mingw-w64-headers/include/winnt.h 
b/mingw-w64-headers/include/winnt.h
index f48cb30..6a51c44 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -1948,6 +1948,103 @@ extern "C" {
 #endif /* _ARM_ */
 
 
+#ifdef _ARM64_
+
+#if defined(__aarch64__) && !defined(RC_INVOKED)
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+#define BitTest _bittest
+#define BitTestAndComplement _bittestandcomplement
+#define BitTestAndSet _bittestandset
+#define BitTestAndReset _bittestandreset
+
+#define BitScanForward _BitScanForward
+#define BitScanReverse _BitScanReverse
+
+#define InterlockedIncrement16 _InterlockedIncrement16
+#define InterlockedDecrement16 _InterlockedDecrement16
+#define InterlockedCompareExchange16 _InterlockedCompareExchange16
+
+#define InterlockedAnd _InterlockedAnd
+#define InterlockedOr _InterlockedOr
+#define InterlockedXor _InterlockedXor
+#define InterlockedIncrement _InterlockedIncrement
+#define InterlockedIncrementAcquire InterlockedIncrement
+#define InterlockedIncrementRelease InterlockedIncrement
+#define InterlockedDecrement _InterlockedDecrement
+#define InterlockedDecrementAcquire InterlockedDecrement
+#define InterlockedDecrementRelease InterlockedDecrement
+#define InterlockedAdd _InterlockedAdd
+#define InterlockedExchange _InterlockedExchange
+#define InterlockedExchangeAdd _InterlockedExchangeAdd
+#define InterlockedCompareExchange _InterlockedCompareExchange
+#define InterlockedCompareExchangeAcquire InterlockedCompareExchange
+#define InterlockedCompareExchangeRelease InterlockedCompareExchange
+
+#define InterlockedAnd64 _InterlockedAnd64
+#define InterlockedAndAffinity InterlockedAnd64
+#define InterlockedOr64 _InterlockedOr64
+#define InterlockedOrAffinity InterlockedOr64
+#define InterlockedXor64 _InterlockedXor64
+#define InterlockedIncrement64 _InterlockedIncrement64
+#define InterlockedDecrement64 _InterlockedDecrement64
+#define InterlockedAdd64 _InterlockedAdd64
+#define InterlockedExchange64 _InterlockedExchange64
+#define InterlockedExchangeAcquire64 InterlockedExchange64
+#define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
+#define InterlockedCompareExchange64 _InterlockedCompareExchange64
+#define InterlockedCompareExchangeAcquire64 InterlockedCompareExchange64
+#define InterlockedCompareExchangeRelease64 InterlockedCompareExchange64
+
+#define InterlockedExchangePointer _InterlockedExchangePointer
+#define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
+#define InterlockedCompareExchangePointerAcquire 
_InterlockedCompareExchangePointer
+#define InterlockedCompareExchangePointerRelease 
_InterlockedCompareExchangePointer
+
+#ifdef __cplusplus
+  }
+#endif
+#endif /* defined(__aarch64__) && !defined(RC_INVOKED) */
+
+#define EXCEPTION_READ_FAULT0
+#define EXCEPTION_WRITE_FAULT   1
+#define EXCEPTION_EXECUTE_FAULT 8
+
+#if !defined(RC_INVOKED)
+
+// TODO: #define CONTEXT_*
+
+#endif /* !defined(RC_INVOKED) */
+
+  typedef struct _CONTEXT {
+// TODO
+  } CONTEXT, *PCONTEXT;
+
+//  typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY RUNTIME_FUNCTION, 
*PRUNTIME_FUNCTION;
+//  typedef PRUNTIME_FUNCTION (*PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD64 
ControlPc,PVOID Context);
+
+// TODO: #define UNW_*
+
+  typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
+// TODO
+  } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
+
+  typedef struct _UNWIND_HISTORY_TABLE {
+// TODO
+  } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
+
+  typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
+// TODO
+  } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;
+
+#define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME 
"OutOfProcessFunctionTableCallback"
+
+#endif /* _ARM64_ */
+
+
 #ifdef _X86_
 
 #if defined(__i386__) && !defined(__x86_64) && !defined(RC_INVOKED)
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 09/19] math: Add aarch64 assembly implementations of math functions

2017-08-05 Thread Martin Storsjö
---
 mingw-w64-crt/math/_chgsignl.S  |  3 +++
 mingw-w64-crt/math/ceil.S   |  3 +++
 mingw-w64-crt/math/ceilf.S  |  3 +++
 mingw-w64-crt/math/ceill.S  |  3 +++
 mingw-w64-crt/math/copysignl.S  |  2 ++
 mingw-w64-crt/math/floor.S  |  3 +++
 mingw-w64-crt/math/floorf.S |  3 +++
 mingw-w64-crt/math/floorl.S |  3 +++
 mingw-w64-crt/math/fma.c| 12 
 mingw-w64-crt/math/fmaf.c   | 12 
 mingw-w64-crt/math/lrint.c  |  5 +
 mingw-w64-crt/math/lrintf.c |  5 +
 mingw-w64-crt/math/nearbyint.S  |  5 +
 mingw-w64-crt/math/nearbyintf.S |  5 +
 mingw-w64-crt/math/nearbyintl.S |  5 +
 mingw-w64-crt/math/rint.c   |  2 ++
 mingw-w64-crt/math/rintf.c  |  2 ++
 mingw-w64-crt/math/sqrt.def.h   |  6 ++
 mingw-w64-crt/math/trunc.S  |  3 +++
 mingw-w64-crt/math/truncf.S |  3 +++
 20 files changed, 88 insertions(+)

diff --git a/mingw-w64-crt/math/_chgsignl.S b/mingw-w64-crt/math/_chgsignl.S
index 2eb7de8..2f8b906 100644
--- a/mingw-w64-crt/math/_chgsignl.S
+++ b/mingw-w64-crt/math/_chgsignl.S
@@ -39,6 +39,9 @@ __MINGW_USYMBOL(_chgsignl):
 #elif defined(_ARM_) || defined(__arm__)
vneg.f64d0, d0
bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+   fnegd0, d0
+   ret
 #elif defined(_X86_) || defined(__i386__)
movl12(%esp),%eax
xorl$0x8000,%eax
diff --git a/mingw-w64-crt/math/ceil.S b/mingw-w64-crt/math/ceil.S
index 6458cec..eac4cb2 100644
--- a/mingw-w64-crt/math/ceil.S
+++ b/mingw-w64-crt/math/ceil.S
@@ -107,6 +107,9 @@ __MINGW_USYMBOL(ceil):
vcvt.f64.s32d0, s0
vmsrfpscr, r1
bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+   frintp  d0, d0
+   ret
 #elif defined(_X86_) || defined(__i386__)
fldl4(%esp)
subl$8,%esp
diff --git a/mingw-w64-crt/math/ceilf.S b/mingw-w64-crt/math/ceilf.S
index 31078e6..c63c629 100644
--- a/mingw-w64-crt/math/ceilf.S
+++ b/mingw-w64-crt/math/ceilf.S
@@ -102,6 +102,9 @@ __MINGW_USYMBOL(ceilf):
vcvt.f32.s32s0, s0
vmsrfpscr, r1
bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+   frintp  s0, s0
+   ret
 #elif defined(_X86_) || defined(__i386__)
flds4(%esp)
subl$8,%esp
diff --git a/mingw-w64-crt/math/ceill.S b/mingw-w64-crt/math/ceill.S
index 0152fb1..2beee4c 100644
--- a/mingw-w64-crt/math/ceill.S
+++ b/mingw-w64-crt/math/ceill.S
@@ -55,6 +55,9 @@ __MINGW_USYMBOL(ceill):
vcvt.f64.s32d0, s0
vmsrfpscr, r1
bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+   frintp  d0, d0
+   ret
 #elif defined(_X86_) || defined(__i386__)
fldt4(%esp)
subl$8,%esp
diff --git a/mingw-w64-crt/math/copysignl.S b/mingw-w64-crt/math/copysignl.S
index 67b46d0..1c0dbab 100644
--- a/mingw-w64-crt/math/copysignl.S
+++ b/mingw-w64-crt/math/copysignl.S
@@ -34,6 +34,8 @@ __MINGW_USYMBOL(copysignl):
ret
 #elif defined(_ARM_) || defined(__arm__)
b   copysign
+#elif defined(_ARM64_) || defined(__aarch64__)
+   b   copysign
 #elif defined(_X86_) || defined(__i386__)
movl24(%esp),%edx
movl12(%esp),%eax
diff --git a/mingw-w64-crt/math/floor.S b/mingw-w64-crt/math/floor.S
index 932df0f..e8f59c6 100644
--- a/mingw-w64-crt/math/floor.S
+++ b/mingw-w64-crt/math/floor.S
@@ -159,6 +159,9 @@ __MINGW_USYMBOL(floor):
vcvt.f64.s32d0, s0
vmsrfpscr, r1
bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+   frintm  d0, d0
+   ret
 #elif defined(_X86_) || defined(__i386__)
fldl4(%esp)
subl$8,%esp
diff --git a/mingw-w64-crt/math/floorf.S b/mingw-w64-crt/math/floorf.S
index cb182a3..d08205b 100644
--- a/mingw-w64-crt/math/floorf.S
+++ b/mingw-w64-crt/math/floorf.S
@@ -42,6 +42,9 @@ __MINGW_USYMBOL(floorf):
vcvt.f32.s32s0, s0
vmsrfpscr, r1
bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+   frintm  s0, s0
+   ret
 #elif defined(_X86_) || defined(__i386__)
flds4(%esp)
subl$8,%esp
diff --git a/mingw-w64-crt/math/floorl.S b/mingw-w64-crt/math/floorl.S
index ec99b92..80838e8 100644
--- a/mingw-w64-crt/math/floorl.S
+++ b/mingw-w64-crt/math/floorl.S
@@ -55,6 +55,9 @@ __MINGW_USYMBOL(floorl):
vcvt.f64.s32d0, s0
vmsrfpscr, r1
bx  lr
+#elif defined(_ARM64_) || defined(__aarch64__)
+   frintm  d0, d0
+   ret
 #elif defined(_X86_) || defined(__i386__)
fldt4(%esp)
subl$8,%esp
diff --git a/mingw-w64-crt/math/fma.c b/mingw-w64-crt/math/fma.c
index 645a3d1..c4ce738 100644
--- a/mingw-w64-crt/math/fma.c
+++ b/mingw-w64-crt/math/fma.c
@@ -17,6 +17,18 @@ double fma(double x, double y, double z){
   return z;
 }
 
+#elif defined(_ARM64_) || defined(__aarch64__)
+
+/* Use hardware FMA on ARM64. */
+double fma(double x, double 

[Mingw-w64-public] [PATCH 16/19] crt: Disable __mingw_init_ehandler on aarch64

2017-08-05 Thread Martin Storsjö
This was enabled for _WIN64 before, but only enable it on x86_64
for now.
---
 mingw-w64-crt/crt/crt_handler.c | 2 +-
 mingw-w64-crt/crt/crtdll.c  | 2 +-
 mingw-w64-crt/crt/crtexe.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-crt/crt/crt_handler.c b/mingw-w64-crt/crt/crt_handler.c
index a1b51ce..6571e69 100644
--- a/mingw-w64-crt/crt/crt_handler.c
+++ b/mingw-w64-crt/crt/crt_handler.c
@@ -40,7 +40,7 @@ PBYTE _GetPEImageBase (void);
 int __mingw_init_ehandler (void);
 extern void _fpreset (void);
 
-#if defined(_WIN64) && !defined(_MSC_VER)
+#if defined(__x86_64__) && !defined(_MSC_VER)
 EXCEPTION_DISPOSITION __mingw_SEH_error_handler(struct _EXCEPTION_RECORD *, 
void *, struct _CONTEXT *, void *);
 
 #define MAX_PDATA_ENTRIES 32
diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
index 07a1840..7f6cf07 100644
--- a/mingw-w64-crt/crt/crtdll.c
+++ b/mingw-w64-crt/crt/crtdll.c
@@ -164,7 +164,7 @@ DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, 
LPVOID lpreserved)
   if (dwReason == DLL_PROCESS_ATTACH)
 {
   __security_init_cookie ();
-#ifdef _WIN64
+#ifdef __x86_64__
   __mingw_init_ehandler ();
 #endif
 }
diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index bbef685..c2c4bbd 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -279,7 +279,7 @@ __tmainCRTStartup (void)
 
 _pei386_runtime_relocator ();
 __mingw_oldexcpt_handler = SetUnhandledExceptionFilter 
(_gnu_exception_handler);
-#ifdef _WIN64
+#ifdef __x86_64__
 __mingw_init_ehandler ();
 #endif
 _set_invalid_parameter_handler (__mingw_invalidParameterHandler);
-- 
2.7.4


--
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


[Mingw-w64-public] [PATCH 11/19] stdio: Add aarch64 assembly wrappers for the v*scanf functions

2017-08-05 Thread Martin Storsjö
Implement the forwarding function in scanf2-template.S and the
va_list unwrapper in the __argtos function in scanf.S, and add
aarch64 to the list of supported architectures in the files that
need it.
---
 mingw-w64-crt/stdio/scanf.S   | 32 
 mingw-w64-crt/stdio/scanf2-template.S |  2 ++
 mingw-w64-crt/stdio/vfscanf.c |  3 ++-
 mingw-w64-crt/stdio/vfwscanf.c|  3 ++-
 mingw-w64-crt/stdio/vsscanf.c |  3 ++-
 mingw-w64-crt/stdio/vswscanf.c|  3 ++-
 6 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-crt/stdio/scanf.S b/mingw-w64-crt/stdio/scanf.S
index 8983190..3a0e977 100644
--- a/mingw-w64-crt/stdio/scanf.S
+++ b/mingw-w64-crt/stdio/scanf.S
@@ -197,4 +197,36 @@ __argtos:
 add sp, sp, #128
 pop {r4-r7, pc}
 
+#elif defined (__aarch64__)
+
+.text
+.align 2
+.globl __argtos
+
+__argtos:
+stp x29, x30, [sp, #-16]!
+mov x29, sp
+sub sp, sp, #256
+mov x9, sp
+mov x10, x2
+mov x11, x3
+
+ldr x2, [x10], #8
+ldr x3, [x10], #8
+ldr x4, [x10], #8
+ldr x5, [x10], #8
+ldr x6, [x10], #8
+ldr x7, [x10], #8
+
+mov x12, #240
+1:  ldr x13, [x10], #8
+str x13, [x9], #8
+subsx12, x12, #8
+b.ne1b
+
+blr x11
+mov sp, x29
+ldp x29, x30, [sp], #16
+ret
+
 #endif
diff --git a/mingw-w64-crt/stdio/scanf2-template.S 
b/mingw-w64-crt/stdio/scanf2-template.S
index 9ed0cf7..892b7e6 100644
--- a/mingw-w64-crt/stdio/scanf2-template.S
+++ b/mingw-w64-crt/stdio/scanf2-template.S
@@ -23,6 +23,8 @@ FCT:
 #elif defined(_ARM_) || defined(__arm__)
 .thumb_func
 b   FWD
+#elif defined(_ARM64_) || defined(__aarch64__)
+b   FWD
 #endif
 #ifdef _WIN64
 .seh_endproc
diff --git a/mingw-w64-crt/stdio/vfscanf.c b/mingw-w64-crt/stdio/vfscanf.c
index ffb5aef..dab72fe 100644
--- a/mingw-w64-crt/stdio/vfscanf.c
+++ b/mingw-w64-crt/stdio/vfscanf.c
@@ -20,7 +20,8 @@ int __ms_vfscanf (FILE * __restrict__ stream, const char * 
__restrict__ format,
 
 #if defined(_AMD64_) || defined(__x86_64__) || \
   defined(_X86_) || defined(__i386__) || \
-  defined(_ARM_) || defined(__arm__)
+  defined(_ARM_) || defined(__arm__) || \
+  defined(_ARM64_) || defined(__aarch64__)
   ret = __ms_vfscanf_internal (stream, format, arg, fscanf);
 #else
 #error "unknown platform"
diff --git a/mingw-w64-crt/stdio/vfwscanf.c b/mingw-w64-crt/stdio/vfwscanf.c
index 6437dc8..52cf928 100644
--- a/mingw-w64-crt/stdio/vfwscanf.c
+++ b/mingw-w64-crt/stdio/vfwscanf.c
@@ -21,7 +21,8 @@ int __ms_vfwscanf (FILE * __restrict__ stream,
 
 #if defined(_AMD64_) || defined(__x86_64__) || \
   defined(_X86_) || defined(__i386__) || \
-  defined(_ARM_) || defined(__arm__)
+  defined(_ARM_) || defined(__arm__) || \
+  defined (_ARM64_) || defined (__aarch64__)
   ret = __ms_vfwscanf_internal (stream, format, arg, fwscanf);
 #else
 #error "unknown platform"
diff --git a/mingw-w64-crt/stdio/vsscanf.c b/mingw-w64-crt/stdio/vsscanf.c
index 1566b1b..6c8fe5a 100644
--- a/mingw-w64-crt/stdio/vsscanf.c
+++ b/mingw-w64-crt/stdio/vsscanf.c
@@ -21,7 +21,8 @@ int __ms_vsscanf (const char * __restrict__ s,
 
 #if defined(_AMD64_) || defined(__x86_64__) || \
   defined(_X86_) || defined(__i386__) || \
-  defined(_ARM_) || defined(__arm__)
+  defined(_ARM_) || defined(__arm__) || \
+  defined(_ARM64_) || defined(__aarch64__)
   ret = __ms_vsscanf_internal (s, format, arg, sscanf);
 #else
 #error "unknown platform"
diff --git a/mingw-w64-crt/stdio/vswscanf.c b/mingw-w64-crt/stdio/vswscanf.c
index 7393204..941ed12 100644
--- a/mingw-w64-crt/stdio/vswscanf.c
+++ b/mingw-w64-crt/stdio/vswscanf.c
@@ -21,7 +21,8 @@ int __ms_vswscanf(const wchar_t * __restrict__ s, const 
wchar_t * __restrict__ f
 
 #if defined(_AMD64_) || defined(__x86_64__) || \
   defined(_X86_) || defined(__i386__) || \
-  defined(_ARM_) || defined(__arm__)
+  defined(_ARM_) || defined(__arm__) || \
+  defined(_ARM64_) || defined(__aarch64__)
   ret = __ms_vswscanf_internal (s, format, arg, swscanf);
 #else
 #error "unknown platform"
-- 
2.7.4


--
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


Re: [Mingw-w64-public] [PATCH] Handle __CTOR_LIST__ for clang

2017-08-05 Thread David Grayson
What I meant is that if GCC's optimizer ever figures out that we are
comparing pointers that came from two different memory objects, it
would know we are doing undefined behavior and would have a license to
do whatever it wants, including removing that code.  The way the loop
is written right now is probably safer than anything that uses a
symbol at the end of the constructors.

--David

On Sat, Aug 5, 2017 at 11:52 AM, Martell Malone  wrote:
>>
>> I think Martell's last patch would have worked but it's not as safe as
>> I would like it to be. I think the constructor and destructor lists
>
> should not be defined in gccmain.c where they are used, because then
>> the compiler optimizer might start to get smart and stop optimizing
>> things in a bad way.
>
> That won't happen, this is what the attribute __used__ is for.
> The issue I have is about casting in a clean way.
> I also don't see the point in iterating through a list to get to the end
> and then navigating back through it again if you have a pointer to the last
> element.
>
>>
>> Also, I think we should add new symbols so there is no potential for a
>> clash with the symbols defined by the linker script in binutils.
>
> As I said in a previous email this would be one way to solve it yes.
> Here is what I said
>> This would mean that programs linked with LD would have an extra 2
> pointers in the table but it should be fine otherwise.
> I would be cleaner and better to change the linker script though.
>
> On Sat, Aug 5, 2017 at 6:15 PM, David Grayson 
> wrote:
>
>> Oops, here is the patch.
>>
>> On Sat, Aug 5, 2017 at 10:14 AM, David Grayson 
>> wrote:
>> > I think Martell's last patch would have worked but it's not as safe as
>> > I would like it to be.  I think the constructor and destructor lists
>> > should not be defined in gccmain.c where they are used, because then
>> > the compiler optimizer might start to get smart and stop optimizing
>> > things in a bad way.  The kind of pointer arithmetic we're doing would
>> > be undefined behavior since we're intentionally getting a pointer to
>> > an object and then reading past the end of that object.
>> >
>> > Also, I think we should add new symbols so there is no potential for a
>> > clash with the symbols defined by the linker script in binutils.
>> >
>> > So, attached to this email is a patch that worked for me (I was able
>> > to compile and run a Qt Widgets application).  I'm not entirely sure
>> > it would be a good patch to use though, since I'm not sure how GCC
>> > picks names for its global constructor and destructor sections, and
>> > how it sorts those names, so I'm not sure that the symbols we are
>> > defining would really be in the right place.
>> >
>> > --David Grayson
>> >
>> > On Sat, Aug 5, 2017 at 4:45 AM, Martell Malone 
>> wrote:
>> >> Hey David,
>> >>
>> >>
>> >>> Your binutils patch did not apply cleanly to binutils-2.27 but I got
>> >>> it to work.  It looks pretty dangerous to me because you removed the
>> >>> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
>> >>> you're using .ctors and .dtors in your other patch, and other code
>> >>> might use them too I suppose.
>> >>
>> >>
>> >> It applies cleanly to HEAD.
>> >> I changed to so that all it does is SORT the ctors and dtors sections.
>> >> Someone would have to confirm though.
>> >>
>> >> Maybe crtexe.c is not linked into shared libraries since they are not
>> EXEs.
>> >>
>> >>  That is exactly what happened there crtdll.c is used instead.
>> >> Here is an updated patch which also applies to crtdll.c
>> >>
>> >> Also the only reason I am not putting it into gccmain.c is because I am
>> >> having problems with creating it and then using is as a array.
>> >> If someone is able to do that it would be much better.
>> >>
>> >> Transforming
>> >> __attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void
>> >> * const func_ptr __CTOR_LIST__[] = {(void *) -1};
>> >> into
>> >> func_ptr __CTOR_LIST__[]
>> >> is being problematic within the one source.
>> >>
>> >> I'd gladly take direction from someone here on that if they have any
>> ideas.
>> >>
>> >> Best,
>> >> Martell
>> >>
>> >> On Sat, Aug 5, 2017 at 5:53 AM, David Grayson 
>> >> wrote:
>> >>
>> >>> With your latest two patches, the toolchain compiles but I get an
>> >>> error when building a shared library:
>> >>>
>> >>> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
>> >>> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-gccmain.o):
>> >>> In function `_do_global_dtors':
>> >>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
>> >>> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
>> >>> w64-crt/crt/gccmain.c:25:
>> >>> undefined reference to `__DTOR_END__'
>> >>> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
>> >>> 

Re: [Mingw-w64-public] Where are headers defined?

2017-08-05 Thread Ozkan Sezer
On 8/5/17, Jeroen Ooms  wrote:
> Trying to build opendap [1] but the configure script can't find uuid.h:
>
> checking uuid/uuid.h usability... no
> checking uuid/uuid.h presence... no
> checking for uuid/uuid.h... no
> checking uuid.h usability... no
> checking uuid.h presence... no
> checking for uuid.h... no
> configure: error: Could not find uuid.h
>
> I see mingw-w64 includes libuuid.a but no header is included? Are
> these headers part of some other file in mingw-w64?
>
>
> [1] https://www.opendap.org/index.php/software/libdap/3.18.1

libuuid.a from mingw has nothing to do with e2fsprogs which
provides uuid/uuid.h, or OSSP uuid which provides uuid.h.
mingw[-w64] provides neither.

--
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


Re: [Mingw-w64-public] [PATCH] Handle __CTOR_LIST__ for clang

2017-08-05 Thread Martell Malone
Hey David,


> Your binutils patch did not apply cleanly to binutils-2.27 but I got
> it to work.  It looks pretty dangerous to me because you removed the
> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
> you're using .ctors and .dtors in your other patch, and other code
> might use them too I suppose.


It applies cleanly to HEAD.
I changed to so that all it does is SORT the ctors and dtors sections.
Someone would have to confirm though.

Maybe crtexe.c is not linked into shared libraries since they are not EXEs.

 That is exactly what happened there crtdll.c is used instead.
Here is an updated patch which also applies to crtdll.c

Also the only reason I am not putting it into gccmain.c is because I am
having problems with creating it and then using is as a array.
If someone is able to do that it would be much better.

Transforming
__attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void
* const func_ptr __CTOR_LIST__[] = {(void *) -1};
into
func_ptr __CTOR_LIST__[]
is being problematic within the one source.

I'd gladly take direction from someone here on that if they have any ideas.

Best,
Martell

On Sat, Aug 5, 2017 at 5:53 AM, David Grayson 
wrote:

> With your latest two patches, the toolchain compiles but I get an
> error when building a shared library:
>
> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-gccmain.o):
> In function `_do_global_dtors':
> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
> w64-crt/crt/gccmain.c:25:
> undefined reference to `__DTOR_END__'
> /tmp/nix-build-mingw-w64-2017-08-03-i686-w64-mingw32.drv-0/
> build_crt_and_headers/mingw-w64-crt/../../mingw-w64/mingw-
> w64-crt/crt/gccmain.c:25:
> undefined reference to `__DTOR_END__'
> /nix/store/k481dhv5hivggnjyb9rs95fz1k6ylhjz-mingw-w64-2017-08-03-i686-
> w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_
> a-gccmain.o):gccmain.c:(.data+0x0):
> undefined reference to `__CTOR_END__'
>
> Maybe crtexe.c is not linked into shared libraries since they are not EXEs.
>
> --David
>
> On Fri, Aug 4, 2017 at 6:12 PM, David Grayson 
> wrote:
> > Oh, I mean that I got the patch to apply, but I don't know if it
> > really *works*; the toolchain is still building at this time.  --David
> >
> > On Fri, Aug 4, 2017 at 6:11 PM, David Grayson 
> wrote:
> >> Your binutils patch did not apply cleanly to binutils-2.27 but I got
> >> it to work.  It looks pretty dangerous to me because you removed the
> >> lines for keeping the .dtors, .dtor, .ctors, and .ctor sections.  And
> >> you're using .ctors and .dtors in your other patch, and other code
> >> might use them too I suppose.
> >>
> >> --David
> >>
> >> On Fri, Aug 4, 2017 at 5:39 PM, Martell Malone 
> wrote:
> >>> Hey David,
> >>>
> >>> This could be caused by gcc including it's own crtbegin.o and crtend.o
> >>> I managed to install a toolchain with brew and I swapped out gcc's and
> >>> mingw-w64's crtbegin and crtend.
> >>> Everything seems to work here as intended.
> >>> Attached is an updated patch that avoids crtbegin and crtend that
> should
> >>> work along with a patch for binutils.
> >>>
> >>> Kai could you give some input on the binutils patch.
> >>> On a side note while we are at this we should change __image_base__
> >>> to ___ImageBase and __ImageBase on x86 and x64 respectively.
> >>> Best,
> >>> Martell
> >>>
> >>> On Sat, Aug 5, 2017 at 12:20 AM, David Grayson <
> davidegray...@gmail.com>
> >>> wrote:
> >>>
>  Martell:
> 
>  My setup ( https://github.com/DavidEGrayson/nixcrpkgs ) makes it
> quite
>  easy to try random patches and make sure that GCC can still be
>  bootstrapped and that I can build non-trivial applications.  I tried
>  your patch (after fixing the linebreaks added by GMail) but
>  unfortunately it doesn't work.
> 
>  When building the final GCC, I got this error:
> 
>  
>  checking for ld that supports -Wl,--gc-sections... configure: error:
>  Link tests are not allowed after GCC_NO_EXECUTABLES.
>  make[1]: *** [Makefile:9917: configure-target-libstdc++-v3] Error 1
>  make[1]: Leaving directory
>  '/tmp/nix-build-gcc-6.3.0-i686-w64-mingw32.drv-0/build'
>  make: *** [Makefile:878: all] Error 2
>  
> 
>  I've experienced this before and it just means something went wrong
>  earlier in the configure script, and GCC, in its infinite wisdom,
>  decided that it was targeting a system that does not support
>  executables (?).  Digging through the config.log for libstdc++-v3, I
>  found a suspicious error:
> 
>  
>  configure:3952: $? = 1
>  configure:3968:
>  /tmp/nix-build-gcc-6.3.0-i686-w64-mingw32.drv-0/build/./gcc/xgcc
>