Commit graph

69 commits

Author SHA1 Message Date
Paul Backus
5fc114165d
Fix importc_compare test on Windows (#20922)
MSVC does not support C11 atomics, but it still provides a "stub"
version of stdatomic.h, which aborts compilation with an #error
directive when included.

To avoid this error, explicitly set the C standard to C11 when invoking
the C preprocessor on Windows, and check for the C11 macro
__STDC_NO_ATOMICS__ before including stdatomic.h.
2025-02-27 20:15:31 +01:00
Rainer
c4a9796472 add test case from #20853 2025-02-18 13:51:06 +01:00
Rainer
7d6fff7bcf Fix issue #17503 - Associative Arrays improperly register a GC-allocated TypeInfo for element cleanup
- let the compiler generate type info for the AA Entry and add it to TypeInfo_AssociativeArray
- strip modifiers for index and next in TypeInfo_AssociativeArray to make it agnostic to changes by the glue layer
2025-02-17 22:02:57 +01:00
Dennis
c0c1b0ab12
Use __FILE__, __LINE__ for templated tracegc hooks (#20882) 2025-02-17 11:53:16 +01:00
Steven Schveighoffer
0542419acb
Remove knowledge of metadata storage from rt/lifetime and (#20833)
core/internal/array. All metadata management should be done by GC.
2025-02-09 16:46:34 +08:00
Martin Kinkelin
130e6aa1d4
GHA main: Add Alpine Linux job, to CI-test musl libc (#20741)
* GHA main: Add Alpine Linux job, to CI-test musl libc

Incl. some test fixes.

* [refactor common isDlcoseNoop logic and prepare for Darwin support]
2025-01-28 00:28:20 +01:00
Jonas Meeuws
5a02544ea3
Use selective imports when importing from core.stdc in druntime tests (#20743) 2025-01-20 19:59:19 +01:00
Jonas Meeuws
d115713410
Add an assert-based segfault handler to etc.linux.memoryerror (#20643)
* Add an assert-based segfault handler to `etc.linux.memoryerror`

* Commit memoryAssertError review feedback

* Indent the MemoryErrorSupported version block

* Fix a bad ucontext_t in memoryerror.d

* Fix bad imports in memoryerror.d

* Use a module-scope version: in memoryerror.d

* Add a memoryerror.d unittest

* Prefer version-else-version... in memoryerror.d
2025-01-18 22:38:54 +01:00
Nicholas Wilson
93ca4676b6
Merge pull request #20698 from schveiguy/gcfinalizerarrays
Move all array and finalizer functionality into the GC
2025-01-15 06:27:36 +08:00
Steven Schveighoffer
4f93c2a1a2 Trying to "fix" obvious non-deterministic test. 2025-01-14 14:21:29 -05:00
Steven Schveighoffer
b711f1ac89 Fix custom_gc to avoid alignment issues on platforms where alignment
matters.
2025-01-13 20:29:49 +01:00
Jonas Meeuws
c0fb282be9
Use selective imports when importing platform-specific modules (core.sys) (#20632) 2025-01-08 08:57:39 +08:00
Steven Schveighoffer
b88ffc50d7
Update GC interface to contain array management functions. (#20608)
* Move array functions into conservative GC.

* Move array functions into conservative GC. Implement stubs for manual GC
and proto GC.

* Add note about trusted functions
2024-12-30 11:04:33 +08:00
Andrei Horodniceanu
a3ed3ec690 druntime/test: rewrite the makefiles
Improvements specific to the makefiles:
- reduce the amount of individual code each makefiles requires to
  function.
- provide variables for specifying DFLAGS, CFLAGS, CXXFLAGS etc.,
- properly rerun the tests when DMD or DRUNTIME are updated.
- don't build the few tests that are skipped
- keep object files even after running the tests

Fixes:
- a bunch of tests were silently skipped, these include:
  - stdcpp/src/test_array.d (it didn't have any unittest block)
  - stdcpp/ C++17 tests are now run on posix, if the compiler supports
    it
  - uuid/ is now run, not just compiled
  - thread/ and gc/ skipped some tests because of misspelling
    TESTS (they were doing TEST+= instead of TESTS+=)
  - exceptions/src/assert_fail.d wans't being reference in the
    Makefile
- added -check=assert to the default flags to gather meaningful
  results from running the tests with BUILD=release
- In exceptions/ tests previously skipped when BUILD=release are now
  run

The main change that this commit tries to fix is being able to specify
compiler flags. The current makefiles make doing this pretty much
impossible and this has affected at least the ldc project which needs
to patch the makefiles to include variables like DFLAGS_BASE into the
variables used by the makefiles in order to be able to pass its flags
around.

On top of being an actual needed feature, the usage of DFLAGS to
specify test-specific flags (like -Isrc or -dip1000) is against the
standard used by GNU make. According to the standard such variables
are reserved for users to add any compiler arguments they desire and
projects should:
1. make sure that those variables are respected and passed, on the
   command line of the compiler, after all project specific flags.
2. pass any required flags outside of DFLAGS (because that variable
   can be overwritten by the user).
This was simply accomplished by just renaming the current variables
to something like extra_cflags (note the lower case spelling) to
clearly mark the separation between flags that were specified by the
user and flags that are freely usable in the makefiles.

The flags that the makefiles now respects are presented as a table in
common.mak:
$(CC)      $(CXX)      $(DMD)       # the compiler
$(CFLAGS)  $(CXXFLAGS) $(DFLAGS)    # flags for the compiler
$(LDFLAGS) ditto       $(LDFLAGS.d) # flags for the compiler when it invokes the linker
$(LDLIBS)  ditto       $(LDLIBS.d)  # library names given to the compiler when invoking the linker
$(TARGET_ARCH) ditto   $(TARGET_ARCH.d) # undocumented but used in the implicit rules

For the purposes of writing the makefiles most the flags variables
above have an extra_dflags variant which can be used to pass test
specific features. Their usage, coupled with the default rules for
building executables, allows the makefiles to easily specify flags, in
a standard compliant manner, with minimal duplication. As an example:
```
$(OBJDIR)/my_test$(DOTEXE): private extra_dflags += -version=TEST_ME
```
is all that's needed to pass -version=TEST_ME when building the
my_test executable.

As specified above, there are now pattern rules that can build common
artifacts. They are inspired by the GNU makefile standard rules, with
the addition of rules for building D executables and the changes
required to respect the extra_dflags variables.

In terms of having the tests be rerun when DMD or DRUNTIME change, the
current code did accomplish this, to some degree, by having the
druntime/Makefile inject the dependencies, which mostly worked. The
approach is problematic because:
1. the dependencies are added unconditionally, if a target doesn't use
   DMD or DRUNTIME it will still be rebuilt.
2. it relies on make deleting the build artifacts across runs, so that
   they're always rebuilt when the tests are rerun.
3. it only works inside the dmd project, where the tests are invoked
   as part of druntime/Makefile. This has lead to ldc needing to add a
   manual command that cleans the build directories of the tests in
   order to be able to rerun them.
4. It doesn't take into account LINK_SHARED being able to be specified
   on the command line.
The solution is simple, simply have the rules that use DMD or DRUNTIME
depend on them, so when those two change the build artifacts are
rebuilt and any tests that depend on them are rerun.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-09-21 13:32:13 +08:00
Andrei Horodniceanu
f2bc9ba61e
druntime/test/cycles: Don't check abort msg if LINK_SHARED is active
The abort message contains line-trace information when linking shared
druntime witch makes the test fail.

Carry out the same logic for deprecate since it fallbacks to the abort
behavior.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-09-20 12:42:15 +03:00
Andrei Horodniceanu
3b991b10f6
druntime/test/stdcpp/src/array.cpp: Fix C++ unspecified behavior
The order of evaluation in the + expression is unspecified so the
order of the function calls is unknown. Since the call order does
influence the final result use separate statements for the additions
to enforce any order.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-09-20 12:42:11 +03:00
Andrei Horodniceanu
2f19831b10
druntime/test/coverage: Fix race condition when modifying source files
This has been hit by ldc because it runs multiple druntime testsuites
in parallel (one for the debug build and one for the release
build). Because of this, modifying the source file directly can lead
to problems which requires that this test be special cased in the ldc
cmake file.

Simply copying the source file to the build directory is enough to get
around this.

A make dependency on the expected output files has also been added.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2024-09-19 08:06:31 +03:00
Tim Schendekehl
845adf8e3c Fix bugzilla 24661 - wctype_t and wctrans_t are platform-dependent
The previous definitions are left as the default. They could still
be wrong on some other platforms.
2024-07-13 18:51:42 +02:00
Tim Schendekehl
5f4002ba5e
Fix bugzilla 24660 - atomic_wchar_t has wrong size on Posix (#16688) 2024-07-13 18:46:13 +02:00
Tim Schendekehl
67996abdc9
Compare type sizes in druntime with ImportC (#16571)
Types for bindings of C libraries in druntime need to match the
C headers. Small differences can result in hard to debug problems.

This test tries to automatically find types with a wrong size.
This is done by also getting type sizes from C headers using ImportC
and comparing them. Differences between the sizes can have different reasons:
* Bugs in ImportC (e.g. for bitfields) can result in a wrong size
* Type definitions in druntime can be wrong
* Different preprocessor options could be used, like _FILE_OFFSET_BITS
* Size differences can be fine, because some structs contain a member
    for the size or a version

Members of structs and unions with the same name are also compared.
For types with potential problems a comparison of the layout is printed.

The test contains a list of known problems, which are only treated as
warnings and not errors.
2024-07-08 10:39:36 +08:00
Iain Buclaw
9ca85e493d Merge remote-tracking branch 'upstream/stable' into merge_stable 2024-05-27 09:41:18 +00:00
Martin Kinkelin
801ad02294 druntime: Streamline make clean for integration tests
The 22 integration tests came with a mix of removing only ROOT
(generated/OS/BUILD/MODEL) or GENERATED (generated) subdirs as
part of their `make clean`.

And running `make clean` in the druntime dir only cleaned up the
default BUILD=release variant, while running `make unittest` without
explicit BUILD type includes running the integration tests in both
debug and release variants.

Streamline/fix this to always cleaning up ROOT, and running `make clean`
in both variants when running druntime's `make clean`.
2024-05-25 22:56:15 +02:00
Johan Engelen
673ddf38bc
Only test druntime exceptions gdb test case (rt_trap_exceptions_drt_gdb) when gdb is available. (#16513) 2024-05-20 06:17:23 +08:00
Steven Schveighoffer
aec16d889c
Remove the interface function fullCollectNoStack from the gcinterface (#16401)
* Remove the interface function fullCollectNoStack from the gcinterface

* Fix tests that depend on the GC not scanning the stack.

* Remove all nostack remnants

* Add changelog entry
2024-04-23 15:06:21 +08:00
Iain Buclaw
53cd4b7c30 Merge remote-tracking branch 'upstream/stable' into merge_stable 2024-03-01 23:11:59 +00:00
Iain Buclaw
6f2a6f919d Fix Bugzilla 23517 - dmd with -g flag fails to link on macOS with unaligned pointer 2024-02-22 14:52:34 +01:00
Rainer Schuetze
aca5ba63b0 pass -visibility=public for SHARED=1 2024-02-08 00:13:08 +01:00
Martin Kinkelin
29aecdd375 [nits after rebase] 2024-02-04 15:50:50 +01:00
Rainer Schuetze
e2a5c72a74 test/shared for windows:
- add -visibility=public when building DLLs
- use -dllimport=all to simplify building exe
- enable tests link linkD linkDR loadDR
2024-02-04 10:49:55 +01:00
Martin Kinkelin
2f8041fff5 druntime: Prepare test/shared/Makefile for broader Windows support 2024-02-04 10:49:54 +01:00
Martin Kinkelin
520240e312 druntime: Prepare test/shared source files for Windows support
Upstreaming from LDC.
2024-02-04 10:48:47 +01:00
Rainer Schuetze
eafad1d5ea shared runtime: basic exception support for Win64 2024-01-06 11:28:01 +01:00
Rainer Schuetze
2f9921d102 version shared runtime hooks on DigitalMars
add missing runtime termination of exe image
2024-01-05 17:26:34 +01:00
Rainer Schuetze
174f0cc0c3 fix link/lib test
- run checks in release builds, too
- side effects in assert() never executed in release builds
- respect different termination order on windows
2024-01-04 10:25:43 +01:00
Rainer Schuetze
1f4e7217e1 fix issue 4071: improve support for shared runtime
- register module info of clients and run module ctors/dtors
- register .data section of clients with the GC
2024-01-03 11:50:56 +01:00
Rainer Schuetze
95f4ad91a3 move PATH modification to makefile to allow running both debug and release unittests 2024-01-03 11:50:55 +01:00
Rainer Schuetze
f9a2557c72
fix issue 4071 and others: shared runtime DLL for Windows (#14849)
Allow exporting all generated symbols (including internal symbols).
Implement switch `-dllimport` ( windows only, not restricted to `extern(D)`)

Still to do:
* running shared module ctors
* running thread local module ctors
* registering DATA/TLS ranges with the GC
* exceptions
2023-12-31 05:26:57 +08:00
Tim Schendekehl
b53341ab91 Fix issue 24298 - cpp_delete should check for null
The delete operator in C++ can be called with a null pointer and
ignores it. This commit makes cpp_delete consistent with C++, so null
pointers are also ignored.
2023-12-22 22:45:08 +01:00
Martin Kinkelin
f3a0366f4f druntime: Avoid -run in Windows-specific additional tests
As temporary object files seem to collide for parallel runs in the
same working dir.
2023-12-18 07:29:32 +08:00
Martin Kinkelin
e030a5ff55 druntime: Slightly simplify test/{uuid,valgrind} Makefiles
By disabling them in druntime/Makefile on unsupported platforms.
2023-12-18 07:29:32 +08:00
Martin Kinkelin
ef8db98dcd druntime: Merge test/shared/win64.mak into Makefile 2023-12-18 07:29:32 +08:00
Martin Kinkelin
28cbd2fe8f druntime: Merge test/stdcpp/win64.mak into Makefile 2023-12-18 07:29:32 +08:00
Martin Kinkelin
b99b9d2c20 druntime: Make most *test* Makefiles usable on Windows too
Still to do: `test/{shared,stdcpp}`.
2023-12-18 07:29:32 +08:00
Denis Feklushkin
554f822d4b
druntime/test/*.mak: replaces -Isrc by -Iimport (#15881)
* druntime/test/*.mak: Replace -Isrc by -Iimport

* Fix Windows tests build: rt/tlsgc.d is not in import/ dir

---------

Co-authored-by: Denis Feklushkin <feklushkin.denis@gmail.com>
2023-12-04 12:24:07 +02:00
Iain Buclaw
7afce7f466 Merge remote-tracking branch 'upstream/stable' into merge_stable 2023-11-20 10:03:05 +01:00
Teodor Dutu
055accfbe6
Translate _d_newarray{mTX, miTX, Op} to a single template (#15819)
- Move code for `_d_newarraymTX` to `core.internal.array.construction`
- Remove `_d_newarraymiTX` and `_d_newarraymOp`
- Add unittests for `_d_newarraymTX`
- Move lowering to `_d_newarraymTX` to the semantic phase
- Inline the lowering when inlining `NewExp`s
- Add changelog entry about the new hook

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
2023-11-17 09:57:30 +02:00
Steven Schveighoffer
084eed696e
Fix static AA initialization (#15744)
* Fix static associative array initialization to always use hashOf at
runtime. We do this by storing the hash function in the Impl instead of
using the passed-in TypeInfo for the key.
2023-11-02 18:41:35 +08:00
Teodor Dutu
fcff1b51ba
Translate _d_newarray{U,iT,T} to a single template (#15299)
* druntime: Copy array allocation functions to `core.internal.array.utils`

This copies `__setArrayAllocLength()`, `__arrayAlloc()` and moves
`__arrayStart()` and `__arrayClearPad()` to
`core.internal.array.utils.d`. This is needed because `_d_newarrayT()`
calls these functions from `rt.lifetime.d`, but the file cannot be
imported from `core.internal.array.creation.d`.

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>

* Translate `_d_newarray{U,iT,T}` to a single template

This achieves the following:
- Convert `_d_newarray{U,iT,T}` to a single template `_d_newarrayT` that
handles arrays of elements that either have an init symbol or are
zero-initialised.
- Move compiler lowering to the semantic phase
- Store lowered expression in `NewExp.lowering`

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>

---------

Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
2023-10-24 10:44:55 +03:00
Iain Buclaw
cd1bbd4733 Fix broken tests caused by merge conflicts 2023-07-15 14:21:45 +00:00
Iain Buclaw
4dccb4aa5d Merge remote-tracking branch 'upstream/stable' into merge_stable 2023-07-15 13:45:11 +00:00