On Sun, 24 Mar 2019, Kacvinsky, Tom wrote:



-----Original Message-----
From: Kacvinsky, Tom <[email protected]>
Sent: Sunday, March 24, 2019 11:34 AM
To: [email protected]
Subject: Re: [Mingw-w64-public] Adding Visual Studio 2017 support to MinGW-w64

HI,

Realized I just be bottom posting.  Sorry about that.

-----Original Message-----
From: Martin Storsjö <[email protected]>
Sent: Saturday, March 23, 2019 6:09 PM
To: [email protected]
Subject: Re: [Mingw-w64-public] Adding Visual Studio 2017 support to MinGW-w64

On Sat, 23 Mar 2019, Kacvinsky, Tom wrote:

Hi Martin,

I have a mixed C, C++, and Ada source tree.  I used Visual Studio to
compile C and C++ code, and a MinGW-w64 based Ada compiler.  What I
would like to do is get MinGW-w64 version 5.0.4 (which is what the Ada
compiler is based on) to have support for the Visual Studio CRT.

So, what I'd like to do is get the specs file used by the Ada compiler
to have the necessary
moldnames140 and vcruntime140 (or equivalent) library files for
linking, so I don't have a mismatch in the runtimes used by Ada
produced DLLs (via gnatdll) and the run time libraries used by C/C++ based 
libraries and executables.

I suppose an option here is to see what is done in MinGW-w64 6.x and
see if I can backport it to 5.0.4.

The support for the UCRT, which is what you want, isn't that trivial to 
backport - it's rather many changes in many places.

The best way to use it is to rebuild mingw-w64 from scratch with both headers and crt 
built with --with-default-msvcrt=ucrt (or ucrtbase). Then your "libmsvcrt.a" 
actually will be the libucrt.a (or libucrtbase.a) and will link against 
api-ms-win-crt-*.dll or ucrtbase.dll. (VS 2017 by default links against 
api-ms-win-crt-*.dll if linking the CRT
dynamically.)

You don't need to care about moldnames, in modern mingw-w64 versions that's an 
empty library. And vcruntime140 doesn't matter either, you don't need it 
(unless you are packaging an app for windows store).

Question: will the libucrt.a build with v6.0.0 work witch v5.0.4, or will I 
need more changes than that?
I am locked into v5.0.4 for the Ada toolchain I am using

The libucrt.a itself won't be enough, unfortunately - you'll need the corresponding updated headers, and updated libmingw32/libmingwex as well. (They are a bit updated so that they work with both old style libmsvcrt.a and the new libucrt.a at the same time.)

Building v6.0.0 from the git repro (git checkout v6.0.06) using the MinGW-w64 
5.0.5 compilers (GCC 5.4.) and ran into this problem

misc/onexit_table.c:77:8: error: '_execute_onexit_table' undeclared here (not 
in a function)
typeof(_execute_onexit_table) *__MINGW_IMP_SYMBOL(_execute_onexit_table) = 
_execute_onexit_table;

This looks like one of the many places that need the new corresponding headers.

Unfortunately, I think the most practical way of getting what you want is to rebuild the Ada toolchain with the new mingw version. Since I presume that you want the Ada runtime to work with UCRT, the it needs to be built with headers set up with --with-default-msvcrt=ucrt.

libmingwex and libmingw32 are special as we try to make sure that one build of them work with all msvcrt versions, but most all other code needs to be built with the headers in the right mode (setting __MSVCRT_VERSION__, which switches between a lot of different redirection paths in the headers, especially regarding stdio.h).

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to