* 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
* 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
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>
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>
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>
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>
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.
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`.
* 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
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
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.
* 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>
- 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>
* 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.
* 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>
* Fix Issue 23890 - "Warning: cannot inline function" in core.lifetime
* druntime/test/profile: Divorce test from exact Druntime source numbers
Allow lines to move around in core/lifetime without affecting this test.
* rt.minfo: Avoid calling realloc with size 0
This is not portable, and memcheck complains about this.
* Add C Valgrind API
Add the BSD-licensed C header files which provide the API for
controlling Valgrind from within programs executed under it.
The files are from Valgrind v3.21.0.
* Add some D bindings for the Valgrind C API
We will use these in the GC implementation to tell Valgrind which
memory operations are OK or not.
* Silence Valgrind warnings caused by GC marking
Allow the conservative GC to scan memory, whether it has been
initialized by the application or not.
* Add test suite for Valgrind
* Unify VALGRIND with MEMSTOMP
The two share the same goal: mark memory which should not be accessed
any more.
* Mask "invalid" access to free lists
The GC stores free lists in the cells of the objects on the list.
We would like to allow the GC to work with these lists, but still
raise a warning if application code attempts to access them.
* Distinguish between writable and unwritable invalidation
Freshly allocated memory should be writable but not readable.
Explicitly deallocated or GC-ed memory should be neither readable or
writable.
* Add use-after-free test
* Invalidate freshly-allocated memory
* Integrate VALGRIND with SENTINEL
* Fix reporting of arrays of structs with destructors
* Re-invalidate reused blocks during malloc/calloc
* Add Changelog entry
* .pre-commit-config.yaml: Exempt vendored files
* etc.valgrind.valgrind: Propagate return values of the vbits functions
* etc.valgrind.valgrind: Add documentation for functions
Copy/adapt the documentation in memcheck.h.
* druntime/test/valgrind: Add no_use_after_gc test
* ci/cirrusci.sh: Install Valgrind on Linux
Run the Druntime Valgrind integration tests.
libc6-dbg is needed to allow Valgrind to redirect certain functions.
* etc.valgrind.valgrind: Add @nogc
Although the GC is the primary user, this is not a restriction of
these Valgrind API wrappers.
* druntime/test/valgrind: Fix no_use_after_gc test with -release
Trick the optimizer to pretend we're doing something with the result
of those invalid memory accesses.
This makes the following changes:
- Replace `_d_newitem{U,T,iT}` with a template `_d_newitemT` that
allocates memory for the new `struct` and performs the required
initialisation
- Move lowering call to `_d_newitemT` from e2ir.d to expressionsem.d
- Add `lowering` field to `NewExp` that contains the lowered call and
use it in e2ir.d
- Remove `_d_newitem{,i}T` from rt.lifetime
Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>