1
0
mirror of https://git.code.sf.net/p/mingw-w64/mingw-w64 synced 2025-04-17 06:57:02 +03:00

8178 Commits

Author SHA1 Message Date
Biswapriyo Nath
c67e9a7ab6 headers: Define MapViewOfFile2 as inline function
As doucumented by 9173247d41

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
2025-04-11 23:25:54 +02:00
Martin Storsjö
a980aed460 github: Add an optional set of smoke tests for github actions
This adds an optional github actions workflow, with a number of
smoke test verifications of mingw-w64:
- With an existing release of llvm-mingw, rebuild all the runtimes
 - This done for the CRT configurations ucrtbase, ucrt and msvcrt
- Run the llvm-mingw smoke tests on Windows (testing compilation
  for all 4 architectures, testing running on x86)
- Run the libcxx testsuite on Windows (i686 and x86_64)
- Test cross-building ffmpeg for all 4 architectures
- Test building and running ffmpeg with its testsuite on Windows
  (i686 and x86_64)
- Test building a GCC cross compiler from scratch
- Test cross-building a Windows hosted GCC using the GCC above
- Run a small set of basic tests with the GCC toolchain

This allows doing some amount of automatic testing of mingw-w64,
covering most common build configurations, avoiding regressing
any of these cases.

While mingw-w64 isn't primarily hosted on github, this wouldn't
be a mandatory/integrated testsuite per se. But many mingw-w64
developers do use github and can benefit from this test setup,
and by having it in-repo, it's easier to coordinate updates to
the test configuration when that is needed. It also makes it
easier for others to contribute more testing configurations.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-11 16:58:20 +03:00
Martin Storsjö
777190497c crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:35:35 +03:00
Pali Rohár
9333df12a0 crt: Add test case for _aligned_* and *_recalloc functions
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:32:27 +03:00
Pali Rohár
e1ff62d7f9 crt: Provide *_recalloc functions
They are natively available since msvcr80.dll, they are not available in
msvcrt.dll. Provide compatibility emulation into all import libraries where
they are not available.

Compatibility emulation needs to use _msize() or _aligned_msize() functions
to figure out the previous size and properly clear the expanded memory as
*calloc functions require.

Memory allocated by these mingw-w64 emulation functions can be normally
released by the appropriate CRT free() or _aligned_free() function.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:32:27 +03:00
Pali Rohár
b40e24afb1 crt: Provide _aligned_msize function for all CRT import libraries
Function _aligned_msize() is available only in msvcr80+ and UCRT. It is not
available in msvcrt.dll system os library.

Now when the mingw-w64 aligned functions use same alignment and gap
calculation we can use mingw-w64 __mingw_aligned_msize() function as
implementation for CRT's _aligned_msize() function.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:32:27 +03:00
Pali Rohár
b8a0910a88 crt: Change mingw-aligned-malloc.c to be compatible with MS CRT functions
MS CRT libraries (UCRT, msvcr70+ and os system msvcrt) for functions
_aligned_malloc() and _aligned_offset_malloc() allocate the source buffer
slightly smaller than the mingw-w64 functions in mingw-aligned-malloc.c.
This is because the alignment gap can be used for the user data too.

Do exactly same math calculation in the mingw-w64 implementation as is UCRT
doing. Same calculation is in msvcr70 and probably also in system msvcrt
library (at least different _msize() tests confirms it).

This will allow to call __mingw_aligned_msize() on buffer allocated by
MS CRT _aligned_malloc() function from msvcrt.dll, msvcr70.dll and
msvcrt71.dll CRT libraries. This is very useful because these CRT libraries
do not have _aligned_msize() function and hence mingw-w64 could emulate it
via __mingw_aligned_msize().

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:32:27 +03:00
Pali Rohár
b4722cedb3 crt: Implement __mingw_aligned_msize() function
Its API is same as MS CRT _aligned_msize() function.

It can be used only on the memory allocated and returned by the
__mingw_aligned_offset_malloc() and __mingw_aligned_offset_realloc()
functions.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:32:27 +03:00
Pali Rohár
a91e27b3d9 crt: Provide _aligned_* functions
Functions _aligned_free(), _aligned_malloc(), _aligned_offset_malloc(),
_aligned_offset_realloc() and _aligned_realloc() are available since
msvcr70.dll. For older CRT import libraries provide emulation via
mingw functions __mingw_aligned_free(), __mingw_aligned_malloc(),
__mingw_aligned_offset_malloc(), __mingw_aligned_offset_realloc() and
__mingw_aligned_realloc(). msvcrt.dll will use system implementation if
available, otherwise transparently fallback to mingw version.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:32:27 +03:00
Pali Rohár
ecf5fdb410 headers: Add missing declaration for __mingw_aligned_offset_malloc()
There is already declaration for msvcrt _aligned_offset_malloc() function,
so add export also declaration for mingw __mingw_aligned_offset_malloc()
function.

At the same time, remove also uneeded declaration of this function from
mingw-w64-crt/misc/mingw-aligned-malloc.c file and use the new one from
malloc.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-09 14:27:28 +03:00
Martin Storsjö
1e8b1ccdd4 crt: Fix condition for fabsf in api-ms-win-crt-math
This was changed erroneously in
95ad23696f57b0f966525b574096bd53d48c773a; fabsf is only available
on arm/aarch64 - it doesn't have anything to do with whether
we are compatible with UCRT regarding long doubles.

Also fix _o_fabsf in ucrtbase-common.def.in which also was changed
erroneously in the same way.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-07 22:38:26 +03:00
Billy Laws
a421d2c0c6 crt: Implement the indirect call helper ARM64EC adjustor thunk
Calls to this are synthesized by the linker where it is used for calling
into import libraries, this is referred to as an 'Adjustor Thunk' in
ARM64EC documentation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-07 15:54:17 +02:00
Jacek Caban
8191d597be crt: Regenerate Makefile.in 2025-04-07 15:54:17 +02:00
Billy Laws
ad38e33189 crt: Define metadata structures used for ARM64EC
These are populated by the linker, and then used by the loader and
emulator at runtime to allow for ARM64EC <-> X86_64 interoperability.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-07 15:54:17 +02:00
Jacek Caban
9b31a5346c Regenerate Makefile.in and configure 2025-04-07 15:54:16 +02:00
Billy Laws
4d83e142b6 crt: Add initial ARM64EC build system support
This introduces basic ARM64EC build support by reusing a modified ARM64
configuration. In the future, the goal is to include both native and
ARM64EC object files in aarch64 archives.

This setup is still subject to change.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-07 15:54:16 +02:00
LIU Hao
22f9ed9987
crt: Move definitions of __mingw_fe_dfl_env to 'fesetenv.c'
These macros are to be used with `fesetenv()`, so they belong there.

Having these `selectany` variables in 'fenv.h' causes them to be defined with
external linkage in every source file which includes 'fenv.h'. They can also
be exported inappropriately from a DLL, which either is built with
`--export-all-symbols`, or does not contain explicit `dllexport` and is not
built with a DEF file.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-04-07 16:54:48 +08:00
Jacek Caban
2f7aff6511 headers: Get rid of unused declarations from math.h.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-06 14:25:06 +02:00
Martin Storsjö
1e5c312743 crt: Use __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ instead of arch checks
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-06 12:37:33 +02:00
Martin Storsjö
7be0af16e1 headers: Use __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ instead of arch checks
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-06 12:37:33 +02:00
Jacek Caban
16335b3c4d crt: Restore arch checks in __signbit.
This partially reverts dbb60ad07c29830, which accidentally removed __x86_64__
check. The change is not needed for ARM64EC, which defined __x86_64__ too.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 15:44:26 +02:00
Martin Storsjö
d16a77a4f9 crt: Regenerate Makefile.in
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-04 16:28:21 +03:00
Martin Storsjö
b72e93b85a crt: Don't delete implicit intermediate .a/.def files after building
Previously, GNU make would delete the implicit intermediate .a/.def
files after building, see [1] for details.

Not deleting them does inflate the size of the build directory a
little bit, but only very marginally (from 201 to 213 MB for a
build with GCC for x86_64).

By keeping them around, they are easier to inspect if debugging
some aspect of them. (Although I haven't really needed to do
this - this isn't the main motivation.)

By not removing them, a build of mingw-w64-crt doesn't end with
a huge wall of text of make doing "rm <all-implicit-files>",
making it easier to observe the output of the other compile
commands instead.

[1] https://www.gnu.org/software/make/manual/html_node/Chained-Rules.html

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-04 16:28:21 +03:00
Martin Storsjö
5433028416 crt: Respect automake silent rules
If configuring mingw-w64-crt with the autoconf/automake config
option --enable-silent-rules, the default automake rules will
print e.g. "  CC       misc/lib64_libmsvcrt_extra_a-wctype.o"
when compiling such a file. However, any custom makefile rules
will still be printed as usual.

Respect the --enable-silent-rules flag on our custom rules;
by adding $(AM_V_GEN) on rules, it will print e.g.
"  GEN      lib64/msvcrt.def" instead of the command, if
configured with that flag, or if building with "make V=0".
By adding $(AM_V_at) on rules, that command won't be printed
at all, when building with silent rules.

By enabling silent rules, the output is much less verbose, and
it is easier to spot e.g. compiler warnings.

See [1] for more details on automake silent rules.

[1] https://www.gnu.org/software/automake/manual/html_node/Automake-Silent-Rules.html

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-04 16:28:21 +03:00
Jacek Caban
7bb76de344 crt: Rename __ASM_NAKED_FUNC macro to __ASM_DEFINE_FUNC.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 15:26:23 +02:00
Billy Laws
cf2b16e2a3 crt: Use aarch64 assembly variants for ARM64EC math functions.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 14:26:46 +02:00
Jacek Caban
dbb60ad07c crt: Use headers: Use __SIZEOF_LONG_DOUBLE__ instead of arch checks in some math functions.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 14:26:46 +02:00
Jacek Caban
75ed7d2d1f headers: Update imported headers to current Wine version.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 11:48:13 +02:00
Jacek Caban
cd0300c499 headers: Regenerate headers with current widl version.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 11:48:13 +02:00
Jacek Caban
1eb8ed2fbd widl: Import Wine version 1.4 (099e35983ff768b5).
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 11:48:12 +02:00
Jacek Caban
6355a96915 crt: Use naked functions for ARM64 assembly functions.
On ARM64EC, function declarations have additional nuances:
- Function names are mangled by prefixing them with "#"
- An unmangled symbol is defined as a weak anti-dependency alias to the mangled
  symbol
- An entry thunk is generated to convert from the x86_64 calling convention to
  the ARM64EC calling convention, used by the emulator
- A .hybmp section entry is generated to associate the function with its entry
  thunk

The compiler can handle all of this if provided with the necessary information.
Naked functions are the most convenient way to achieve this.

Use naked functions only on Clang. GCC doesn’t support them on ARM targets and
has broken behavior on x86_64 by emitting .seh_endprologue.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 11:39:56 +02:00
Jacek Caban
85c48a0bf4 crt: Regenerate Makefile.in 2025-04-04 11:39:56 +02:00
Jacek Caban
0ca516e448 crt: Move ARM64 nearbyint implementation to C files.
In preparation for using naked functions.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 11:38:49 +02:00
Jacek Caban
0b27cfc5ce crt: Move ARM64 trunc implementation to C files.
In preparation for using naked functions.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-04 11:38:49 +02:00
Jacek Caban
d0c80252d6 crt: Regenerate Makefile.in 2025-04-01 14:59:57 +02:00
Jacek Caban
ad6e32374f crt: Implement exp2/exp2f/exp2l in C on ARM targets.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-04-01 14:59:31 +02:00
Jacek Caban
216cc9328b crt: Regenerate Makefile.in 2025-03-31 14:40:25 +02:00
Jacek Caban
3d15f5e160 crt: Implement sincos in C.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-31 14:39:53 +02:00
Jacek Caban
57ec2cff5f crt: Build with -fno-builtin.
mingw-w64-crt implements a number of functions that the compiler considers
built-in. Currently, we must be cautious about compiler optimizations, as they
may not align with our intentions. In theory, the compiler could optimize an
implementation of such a function back into a call to itself.

Rather than second-guessing the optimizer and reimplementing problematic
functions in assembly, disable built-in functions globally for mingw-w64-crt.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-31 14:39:53 +02:00
Jacek Caban
ebf7183b4f crt: Avoid memset call in profile_ctl.
In preparation for building the CRT with -fno-builtin. This allows the compiler
to zero memory without making an actual library call.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-31 14:39:53 +02:00
Jacek Caban
ecc01089f2 crt: Avoid memset calls in stdio format functions.
In preparation for building the CRT with -fno-builtin. This allows the compiler
to zero memory without making an actual library call.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-31 14:39:53 +02:00
Jacek Caban
7ea592a7ba crt: Avoid memset calls in stat functions implementation.
In preparation for building the CRT with -fno-builtin. This allows the compiler
to zero memory without making an actual library call.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-31 14:39:53 +02:00
Jacek Caban
475fc9674e crt: Avoid memset calls in libsrc/ws2tcpip.
In preparation for building the CRT with -fno-builtin. This allows the compiler
to zero memory without making an actual library call.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-31 14:39:53 +02:00
Jacek Caban
d4b6d1d4ab crt: Remove redundant STARTUPINFO initialization.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-31 14:39:52 +02:00
Jacek Caban
f70507db60 crt: Regenerate Makefile.in 2025-03-30 17:58:42 +02:00
Jacek Caban
28d2ed32cb crt,headers: Use headers to redirect __ms_v*scanf functions to v*scanf functions.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
2025-03-30 17:57:55 +02:00
Biswapriyo Nath
90da6c6535
headers/crt: Add _wcreate_locale declaration
This function is available since MSVCR110.

Required for https://sourceforge.net/p/mingw-w64/mailman/message/59164037/

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Co-authored-by: LIU Hao <lh_mouse@126.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-03-26 22:12:25 +08:00
Alexander Argentakis
dc69654d1b winpthreads: fix typo pthread_attr_setgaurdsize->pthread_attr_setguardsize
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-03-24 15:05:25 +02:00
Daniel Starke via Mingw-w64-public
850703ae46
headers: Change _S_IFBLK from 0x3000 to 0x6000
The _S_IFBLK macro, used to identify block special files in file systems, is
being updated from 0x3000 to 0x6000. This change aligns mingw-w64 with the more
commonly used value across Unix-like systems and other C libraries.

The old value of 0x3000 may have caused compatibility issues when working with
code that assumes the standard 0x6000 value for S_IFBLK.

This update improves cross-platform compatibility and consistency with other
systems, making it easier to write portable code that deals with file type
identification. It also reduces potential confusion and errors that might arise
from the non-standard value.

One of these is for example python. This is only an example. It does not change
the fact that python should be more careful about actual value implementation.

Note that the current value implies character device + FIFO instead of
character device + directory.

Link: f819900245/Python/fileutils.c (L1197)
Link: 81e4f8d68c/include/uapi/linux/stat.h (L13)
Signed-off-by: Daniel Starke <daniel-email@gmx.net>
Signed-off-by: LIU Hao <lh_mouse@126.com>
2025-03-22 10:59:37 +08:00
Jacek Caban
4da21051f3 crt: Regenerate Makefile.in 2025-03-21 23:32:32 +01:00