Commit graph

19 commits

Author SHA1 Message Date
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
Steven Schveighoffer
4f93c2a1a2 Trying to "fix" obvious non-deterministic test. 2025-01-14 14:21:29 -05: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
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
6f2a6f919d Fix Bugzilla 23517 - dmd with -g flag fails to link on macOS with unaligned pointer 2024-02-22 14:52:34 +01: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
Rainer Schuetze
ca016bd979
fix issue 23859 - [REG 2.103] Throwing while in a deep callstack causes memory corruption (#15127)
avoid writing beyond the end of the trace buffer
2023-04-25 22:32:16 +03:00
Iain Buclaw
29b1efa0c4 Merge remote-tracking branch 'upstream/stable' into merge_stable 2023-02-21 23:52:41 +00:00
Martin Kinkelin
a9eedfe405
druntime: Fix up cpp_demangle subtest of exceptions integration tests (#14894)
* Don't run the test in release mode on Linux; just like for the other
  Posix targets.
* Include `-L--export-dynamic` as required dflag (added implicitly to cc
  linker cmdline by DMD, but not by LDC), which is required for symbol
  resolution in druntime exception backtraces.
2023-02-19 17:56:30 +08:00
Iain Buclaw
a59e38a7bd druntime: Match either _Dmain or D main 2023-01-30 00:15:07 +01:00
Nicholas Wilson
d494932ca6 Fix rt_trap_exceptions_drt_gdb in the presence of optimisations
The test checks the stack frame of `_Dmain` is in the backtrace, however if unused locals are optimised out and`test` is inlined into `main` 
```d
void test()
{
    int innerLocal = 20;
    throw new Exception("foo");
}
void main(string[] args)
{
    string myLocal = "bar";
    test();
}
```
then the point at which the untapped exception is thrown is at the start of D main - not somewhere in the middle of it - and so GDB prints 
```
...
#4 D main (args=...)
```
rather than 
```
...
#4 0xSOMEADDRESS in D main (args=...)
```
2022-11-02 04:17:26 +01:00
Ömer Faruk IRMAK
fabd06214e druntime: Demangle C++ symbols if a standard library is already loaded 2022-10-29 10:59:46 +01:00
Iain Buclaw
69ab16a7e8 Merge dlang/druntime repository into dlang/dmd 2022-07-09 18:53:15 +02:00