Skip to content

Commit 5e0475e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into stable
2 parents 7af5ba3 + 4d44187 commit 5e0475e

910 files changed

Lines changed: 85068 additions & 19331 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.azure-pipelines/windows.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ if [[ "$HOST_DMD_VERSION" == "2.079.0" ]]; then
7272
fi
7373

7474
cd "$DMD_DIR"
75-
"$HOST_DC" -m$MODEL compiler/src/build.d -ofgenerated/build.exe
76-
generated/build.exe -j$N MODEL=$MODEL HOST_DMD=$HOST_DC BUILD=debug "${disable_debug_for_unittests[@]}" unittest
77-
generated/build.exe -j$N MODEL=$MODEL HOST_DMD=$HOST_DC DFLAGS="-L-LARGEADDRESSAWARE" ENABLE_RELEASE=1 ENABLE_ASSERTS=1 dmd
75+
"$GNU_MAKE" -j$N MODEL=$MODEL HOST_DMD=$HOST_DC BUILD=debug "${disable_debug_for_unittests[@]}" dmd-unittest
76+
"$GNU_MAKE" -j$N MODEL=$MODEL HOST_DMD=$HOST_DC HOST_DFLAGS="-L-LARGEADDRESSAWARE" ENABLE_RELEASE=1 ENABLE_ASSERTS=1 dmd
7877

7978
DMD_BIN_PATH="$DMD_DIR/generated/windows/release/$MODEL/dmd.exe"
8079

@@ -94,11 +93,9 @@ cd "$DMD_DIR/compiler/test"
9493

9594
# Rebuild dmd with ENABLE_COVERAGE for coverage tests
9695
if [ "${DMD_TEST_COVERAGE:-0}" = "1" ] ; then
97-
9896
# Recompile debug dmd + unittests
9997
rm -rf "$DMD_DIR/generated/windows"
100-
../../generated/build.exe -j$N MODEL=$MODEL DFLAGS="-L-LARGEADDRESSAWARE" ENABLE_DEBUG=1 ENABLE_COVERAGE=1 dmd
101-
../../generated/build.exe -j$N MODEL=$MODEL DFLAGS="-L-LARGEADDRESSAWARE" ENABLE_DEBUG=1 ENABLE_COVERAGE=1 unittest
98+
"$GNU_MAKE" -j$N -C "$DMD_DIR" MODEL=$MODEL HOST_DMD=$HOST_DC HOST_DFLAGS="-L-LARGEADDRESSAWARE" ENABLE_DEBUG=1 ENABLE_COVERAGE=1 dmd dmd-unittest
10299
fi
103100

104101
"$HOST_DC" -m$MODEL -g -i run.d

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ jobs:
66
- image: cimg/base:current-20.04
77
parallelism: 1
88
steps:
9-
- checkout
9+
- checkout:
10+
method: blobless
1011
- run:
1112
command: ./.circleci/run.sh install-deps
1213
name: Install dependencies

.github/workflows/release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# GitHub Action to build releases on command
2+
#
3+
# This script builds and packages a release for Linux, Windows, OSX and FreeBSD
4+
# using the stable branch. The generated archives are published as a release
5+
# on the GitHub release page.
6+
#
7+
# Job overview:
8+
# 1. Builds the actual release using `build_release_template` from dlang/installer
9+
# 2. Publishes all artifacts from (1) to the release page on GitHub
10+
#
11+
# Triggered manually by authorized users via workflow_dispatch.
12+
13+
name: build-release
14+
15+
on:
16+
workflow_dispatch:
17+
inputs:
18+
branch:
19+
description: 'Branch to build from'
20+
required: true
21+
type: string
22+
default: stable
23+
tag:
24+
description: 'Release tag (e.g., v2.109.0)'
25+
required: true
26+
type: string
27+
prerelease:
28+
description: 'Mark as pre-release'
29+
required: false
30+
type: boolean
31+
default: false
32+
33+
jobs:
34+
# Build and package a new release for all supported platforms
35+
build-all-releases:
36+
name: Build release from ${{ github.event.inputs.branch }}
37+
uses: dlang/installer/.github/workflows/build_release_template.yml@master
38+
with:
39+
release_branch: ${{ github.event.inputs.branch }}
40+
41+
# Bundles and publishes the entire release
42+
generate_release:
43+
name: "Publish artifacts on the release page"
44+
needs:
45+
- build-all-releases
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
#################################################################
50+
# Fetch all artifacts from the jobs defined above
51+
#
52+
- name: Download generated releases from the artifacts
53+
uses: actions/download-artifact@v4
54+
with:
55+
pattern: dmd-release-*
56+
merge-multiple: true
57+
path: ~/artifacts/
58+
59+
#################################################################
60+
# Debug: Check that all required artifacts are present
61+
#
62+
- name: Display all files included in the artifacts
63+
id: list-artifacts
64+
shell: bash
65+
run: |
66+
set -euox pipefail
67+
ls -aul ~ ~/artifacts
68+
echo "artifacts_directory=$HOME/artifacts" >> $GITHUB_OUTPUT
69+
70+
#################################################################
71+
# Create the new release using the downloaded artifacts
72+
#
73+
- name: Create the release
74+
uses: ncipollo/release-action@v1
75+
with:
76+
token: "${{ secrets.GITHUB_TOKEN }}"
77+
name: DMD ${{ github.event.inputs.tag }}
78+
prerelease: ${{ github.event.inputs.prerelease }}
79+
body: |
80+
Release of the reference D compiler
81+
82+
| Component | Revision |
83+
| --------- | ---------------------------------------------------------------- |
84+
| DMD | dlang/dmd@${{ needs.build-all-releases.outputs.dmd-revision }} |
85+
| Phobos | dlang/phobos@${{ needs.build-all-releases.outputs.phobos-revision }} |
86+
87+
artifacts: ${{ steps.list-artifacts.outputs.artifacts_directory }}/*
88+
artifactErrorsFailBuild: true
89+
tag: ${{ github.event.inputs.tag }}
90+
commit: ${{ needs.build-all-releases.outputs.dmd-revision }}

.github/workflows/runnable_cxx.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,13 @@ jobs:
193193
- name: Build compiler & standard library
194194
run: |
195195
set -eux
196+
extraFlags=()
196197
if [[ '${{ matrix.os }}' == macos-14 ]]; then
197-
# don't try compiling a native arm64 DMD on macOS (doesn't work)
198-
make -C dmd -j$N dmd DFLAGS="-mtriple=x86_64-apple-macos14"
198+
# DMD doesn't work on arm64 yet. Make LDC host compiler cross-compile
199+
# DMD to x86_64, and then use implicit Rosetta emulation.
200+
extraFlags=(HOST_DFLAGS="-mtriple=x86_64-apple-macos14")
199201
fi
200-
make -C dmd -j$N
202+
make -C dmd -j$N "${extraFlags[@]}"
201203
make -C phobos -j$N
202204
203205
########################################
@@ -213,10 +215,8 @@ jobs:
213215
if: runner.os != 'Windows' # not supported by build.d yet
214216
run: |
215217
set -eux
218+
extraFlags=()
216219
if [[ '${{ matrix.os }}' == macos-14 ]]; then
217-
# switch from LDC to freshly built DMD as host compiler
218-
export HOST_DMD="$PWD/dmd/generated/osx/release/64/dmd"
219-
export CXXFLAGS="-arch x86_64"
220-
rm ./dmd/generated/osx/release/64/*.o
220+
extraFlags=(HOST_DMD=ldmd2 DFLAGS="-mtriple=x86_64-apple-macos14" CXXFLAGS="-arch x86_64")
221221
fi
222-
./dmd/generated/build cxx-unittest
222+
./dmd/generated/build cxx-unittest "${extraFlags[@]}"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ untracked_files/
6262
# Just in case
6363
/dmd
6464
.DS_Store
65+
/compiler/src/vcbuild/*.filters
66+
/compiler/src/vcbuild/*.sources

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v6.0.0
44
hooks:
55
- id: trailing-whitespace
66
exclude: >
@@ -22,6 +22,6 @@ repos:
2222
- id: no-commit-to-branch
2323
args: [--branch, master]
2424
- repo: https://github.com/sirosen/check-jsonschema
25-
rev: 0.23.0
25+
rev: 0.34.1
2626
hooks:
2727
- id: check-github-workflows

Makefile

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# make -j$(nproc) dmd-test
1717
#
1818
# See compiler/src/build.d for variables affecting the compiler build.
19+
# Use HOST_DFLAGS (not DFLAGS) for extra flags (for the host compiler) to be used for the compiler build.
1920

2021
include compiler/src/osmodel.mak
2122

@@ -48,8 +49,15 @@ GENERATED:=generated
4849
BUILD_EXE:=$(GENERATED)/build$(EXE)
4950
RUN_EXE:=$(GENERATED)/run$(EXE)
5051

52+
# forward any HOST_DFLAGS as DFLAGS for the build tool
53+
ifeq (,$(HOST_DFLAGS))
54+
BUILD_CMD:=$(BUILD_EXE)
55+
else
56+
BUILD_CMD:=$(BUILD_EXE) DFLAGS='$(HOST_DFLAGS)'
57+
endif
58+
5159
.PHONY: all clean test html install \
52-
dmd dmd-test druntime druntime-test \
60+
dmd dmd-unittest dmd-test druntime druntime-test \
5361
auto-tester-build auto-tester-test buildkite-test \
5462
toolchain-info check-clean-git style
5563

@@ -70,7 +78,7 @@ auto-tester-test:
7078
buildkite-test: test
7179

7280
toolchain-info: $(BUILD_EXE)
73-
$(BUILD_EXE) $@
81+
$(BUILD_CMD) $@
7482

7583
clean:
7684
rm -rf $(GENERATED)
@@ -79,10 +87,12 @@ clean:
7987
$(QUIET)$(MAKE) -C druntime clean
8088

8189
dmd: $(BUILD_EXE)
82-
$(BUILD_EXE) $@
90+
$(BUILD_CMD) $@
91+
92+
dmd-unittest: $(BUILD_EXE)
93+
$(BUILD_CMD) unittest
8394

84-
dmd-test: dmd druntime $(BUILD_EXE) $(RUN_EXE)
85-
$(BUILD_EXE) unittest
95+
dmd-test: dmd-unittest dmd druntime $(RUN_EXE)
8696
$(RUN_EXE) --environment
8797

8898
druntime: dmd
@@ -94,7 +104,7 @@ druntime-test: dmd
94104
test: dmd-test druntime-test
95105

96106
html: $(BUILD_EXE)
97-
$(BUILD_EXE) $@
107+
$(BUILD_CMD) $@
98108

99109
# Creates Exuberant Ctags tags file
100110
tags: Makefile $(ECTAGS_FILES)
@@ -106,8 +116,8 @@ install:
106116
echo "Darwin_64_32_disabled"
107117
else
108118
install: $(BUILD_EXE)
109-
$(BUILD_EXE) man
110-
$(BUILD_EXE) install INSTALL_DIR='$(if $(findstring $(OS),windows),$(shell cygpath -w '$(INSTALL_DIR)'),$(INSTALL_DIR))'
119+
$(BUILD_CMD) man
120+
$(BUILD_CMD) install INSTALL_DIR='$(if $(findstring $(OS),windows),$(shell cygpath -w '$(INSTALL_DIR)'),$(INSTALL_DIR))'
111121
mkdir -p '$(INSTALL_DIR)'/man
112122
cp -r $(GENERATED)/docs/man/* '$(INSTALL_DIR)'/man/
113123
$(QUIET)$(MAKE) -C druntime install INSTALL_DIR='$(INSTALL_DIR)'
@@ -124,7 +134,7 @@ check-clean-git:
124134
fi
125135

126136
style: $(BUILD_EXE)
127-
$(BUILD_EXE) $@
137+
$(BUILD_CMD) $@
128138

129139
.DELETE_ON_ERROR: # GNU Make directive (delete output files on error)
130140

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Support for default values in C-style bitfields
2+
3+
D now supports specifying default values for C-style bitfields in structs and classes.
4+
This brings valid D code closer to behavior allowed in C++20 and allows for more concise initialization of bitfield members.
5+
6+
Value range checking is performed at compile-time to ensure the default value fits within the specified number of bits.
7+
8+
-------
9+
struct S
10+
{
11+
int a : 4 = 2; // OK
12+
int b : 2 = 5; // Error: bitfield initializer `5` does not fit in 2 bits
13+
uint c : 1 = 1; // OK
14+
bool d : 1 = 1; // OK
15+
}
16+
-------

changelog/dmd.exception-rewrite.dd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Finally statements are no longer rewritten to a sequence if no Exception was thrown
2+
3+
Finally statements have been allowed to rewrite to sequences when no Exception was throwable from within the try body.
4+
This has been shown to be problematic as cleanup when an Error is thrown does not occur.
5+
6+
By default this has been reverted back to the pre-2018 behavior of not doing the rewrite.
7+
8+
To change this use the new switch `-checkactionfinally=off` to reenable the previous behavior.
9+
10+
This behavior can be observed by running the following code:
11+
12+
```d
13+
import core.stdc.stdio;
14+
15+
void main() {
16+
try {
17+
callMe();
18+
} finally {
19+
printf("exiting!\n");
20+
}
21+
}
22+
23+
void callMe() {
24+
throw new Error("hi there :)");
25+
}
26+
```
27+
28+
When the switch is set to `on`, "exiting!" will be printed.
29+
30+
The `-betterC` switch is unaffected by this change.

changelog/dmd.fastdfa.dd

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
New experimental Data Flow Analysis Engine for nullability and truthiness
2+
3+
A new experimental Data Flow Analysis (DFA) has been implemented under the preview flag ``-preview=fastdfa``.
4+
The intent of the engine is to be both fast and free from false positives, if successful it may in the future be turned on by default.
5+
6+
No attributes have been implemented to date, before they are considered the engine itself must be both usable with the right tradeoffs and have desirable features.
7+
This has some side effects, it prevent separate compilation, function pointers, and cyclic functions from being analysable.
8+
These limitations are not supposed to prevent a successful compilation when in use.
9+
10+
The engine itself is variable centric with a strong focus on giving up on analysing a variable if things get too complex for it.
11+
This can result in messages that may not appear to make sense for where they are emitted, due to the way shortcutting of analysis works.
12+
As an example of loops:
13+
14+
```d
15+
void loopy()
16+
{
17+
int* ptr = new int;
18+
19+
foreach (i; 0 .. 2) // Error: Variable `ptr` was required to be non-null and has become null
20+
{
21+
int val = *ptr;
22+
ptr = null;
23+
}
24+
}
25+
```
26+
27+
If the engine is successful, the reporting mechanism would be replaced with a tracing state pass.
28+
This would offer for a function line by line explanation of how and why the engine thought something was true.
29+
30+
The engine has been tested on a 100k LOC defensively written codebase without any false positives.
31+
The performance is similar to DIP1000 and is not supposed to be noticeable.

0 commit comments

Comments
 (0)