dmd D Programming Language compiler
Find a file
Ilya Yanok c1343f69f3 Make lambda symbols stable post a3abf1187e
Commit a3abf1187e fixes some cases of
lambdas having unstable symbol names between compilation units by
using `generateIdWithLoc` to generate stable lambda names, however since
LOC doesn't uniquely identify a lambda instance (because templates,
mixins, static foreach and foreach unrolling), `generateIdWithLoc`
adds a counter, so there is still some instability going on.

`generateIdWithLoc` makes the name uniq per file+loc, by adding adding a
numeric suffix. But the order of instantiations might be different
across compilation units, so with this counting scheme we are back to
unstable names, so one module might have

`t!0.__lambda_LOC` and
`t!1.__lambda_LOC_1`

while another one has

`t!1.__lambda_LOC`

This is not a critical problem, but at very least the code gets
duplicated for no reason. I also have an example where it leads to
linking error, but since it's not a small one and fails to minimize
further, I suspect it's a result of interaction with some other bug.

The thing is we don't even need uniqueness for those lambdas inside
templates/mixins: their final names will have the instantiation prefix anyway.
But we can't also just disable this uniqueness check completely: `static
foreach` as well as unrollings of the normal `foreach` with lambdas in
the loop body will have several copies of a single lambda with the same
file+loc. So here we do want to keep making them unique. Fortunately, I
don't think a `foreach` could be iterated in different order in
different compilation units, so hopefully if we limit the counting to
this case only, it won't make symbols unstable.

To implement this idea, I've added an extra `parent` argument to
`generateIdWithLoc`: it works like using `parent ~ prefix` prefix, but
without adding `parent` to the final output.

Fixes since last review:
 1. Changed `fromStringz` to `toDString`
 2. Added a test to showcase the problem
2024-12-07 10:48:34 +01:00
.azure-pipelines Get rid of obsolete DMC special cases 2024-05-25 19:34:44 +02:00
.circleci CI: Adapt to generic Makefile for Phobos 2023-12-18 17:10:31 +08:00
.github/workflows GitHub Actions: Bump macos-12 jobs to macos-13 (#17063) 2024-11-14 03:46:12 +01:00
changelog Fix bugzilla issue 24882 - COM class is allocated using GC not malloc 2024-11-29 08:37:07 +01:00
ci GitHub Actions: Bump macos-12 jobs to macos-13 (#17063) 2024-11-14 03:46:12 +01:00
compiler Make lambda symbols stable post a3abf1187e 2024-12-07 10:48:34 +01:00
druntime Fix bugzilla issue 24882 - COM class is allocated using GC not malloc 2024-11-29 08:37:07 +01:00
src Convert posix.mak to generic Makefile 2023-12-09 15:59:14 +01:00
.cirrus.yml Cirrus CI: Allow single remaining FreeBSD coverage job to fail (might be out of credits) 2023-10-29 02:40:10 +01:00
.codecov.yml Fix capitalization of CircleCI in codecov configuration 2021-10-19 01:53:57 +00:00
.editorconfig Replace http:// with https:// for various links throughout codebase 2021-12-22 21:45:11 +00:00
.git-blame-ignore-revs Use Array.length instead of Array.dim (#14613) 2022-11-03 21:42:36 -07:00
.gitattributes Fix build script paths to work with new merged repository structure 2022-07-09 23:49:27 +02:00
.gitignore refactor gensaverestore() 2024-06-18 10:15:36 +02:00
.pre-commit-config.yaml Add Valgrind GC integration (#15304) 2023-06-15 01:01:42 -07:00
azure-pipelines.yml Kill off OMF support 2024-05-03 18:24:36 +12:00
CODEOWNERS Remove myself as *.h code owner 2021-06-26 08:56:21 +00:00
config.d fix(dub): Make config.d executable to incremental compilation (#13712) 2022-02-28 14:08:59 +02:00
CONTRIBUTING.md Update the contributor guide (#16326) 2024-03-30 21:58:29 +01:00
dub.sdl Get rid of obsolete dmd.{lib,scan}omf modules 2024-05-25 16:25:35 +02:00
LICENSE.txt Make Boost license visible 2017-06-05 03:20:55 +02:00
Makefile Makefiles: Add comments wrt. usage on Windows and a few example invocations 2023-12-18 07:29:32 +08:00
posix.mak Restore posix.mak, forwarding to generic Makefile 2023-12-09 15:59:14 +01:00
README.md Add building dmd with dub 2024-02-02 20:52:10 +01:00
VERSION bump VERSION to v2.110.0-beta.1 2024-07-01 22:51:28 +00:00

dlang logo

DMD

GitHub tag Code coverage Bugzilla Issues license

Build status CircleCI Build Status Buildkite


DMD is the reference compiler for the D programming language.

Releases, language specification and other resources can be found on the homepage. Please refer to the guidelines for bug reports to report a problem or browse the list of open bugs.

Overview

This repository is structured into the following directories. Refer to their respective README.md for more in-depth information.

Directory Description
changelog changelog entries for the upcoming release
ci CI related scripts / utilities
compiler root of all compiler (DMD/frontend) related code
compiler/src source code, build system and build instructions
compiler/test tests and testing infrastructure
compiler/docs man pages and internal documentation
compiler/ini predefined dmd.conf files
compiler/samples Various code examples
druntime root of all runtime related code

With a D compiler and dub installed, dmd can be built with:

dub build dmd:compiler

For more information regarding compiling, installing, and hacking on DMD, check the contribution guide and visit the D Wiki.

Nightlies

Nightly builds based of the current DMD / Phobos master branch can be found here.