Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DtoCreateNestedContextType() for -linkonce-templates #3766

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .azure-pipelines/6-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# Required env vars:
# - ARCH
# - CI_OS
# - EXTRA_CMAKE_FLAGS_CROSS (optional)
# - CROSS_TRIPLE (optional)
# - DFLAGS (optional)
# - EXTRA_CMAKE_FLAGS_CROSS (optional)

steps:

Expand All @@ -26,7 +27,7 @@ steps:
git clone --recursive https://github.com/dlang/dub.git
cd dub
git checkout "$(cat $BUILD_SOURCESDIRECTORY/packaging/dub_version)"
DFLAGS='' $DMD -run build.d -O -w $DFLAGS
DFLAGS='' $DMD -run build.d -O -w -linkonce-templates $DFLAGS
cp bin/dub ../installed/bin
if [[ "$EXTRA_CMAKE_FLAGS_CROSS" == "" ]]; then
../installed/bin/dub --version
Expand All @@ -50,7 +51,7 @@ steps:
git clone --recursive https://github.com/atilaneves/reggae.git
cd reggae
git checkout "$(cat $BUILD_SOURCESDIRECTORY/packaging/reggae_version)"
DFLAGS="-O $DFLAGS" ../host-ldc/bin/dub build -v --build-mode=allAtOnce --combined \
DFLAGS="-O -linkonce-templates $DFLAGS" ../host-ldc/bin/dub build -v --build-mode=allAtOnce --combined \
--compiler="$(dirname "$DMD")/ldc2" \
${CROSS_TRIPLE:+--arch="$CROSS_TRIPLE"}
cp bin/reggae ../installed/bin
Expand Down
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ task:
git clone --recursive https://github.com/dlang/dub.git
cd dub
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/dub_version)"
$DMD -run build.d -O -w
$DMD -run build.d -O -w -linkonce-templates
cp bin/dub ../installed/bin
../installed/bin/dub --version
# Build & copy dlang tools
Expand All @@ -264,7 +264,7 @@ task:
git clone --recursive https://github.com/atilaneves/reggae.git
cd reggae
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/reggae_version)"
DFLAGS="-O" ../dub/bin/dub build -v --combined --compiler="$PWD/../installed/bin/ldc2"
DFLAGS="-O -linkonce-templates" ../dub/bin/dub build -v --combined --compiler="$PWD/../installed/bin/ldc2"
cp bin/reggae ../installed/bin
../installed/bin/reggae --version -b ninja
# Pack artifact
Expand Down
7 changes: 3 additions & 4 deletions cmake/Modules/BuildDExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ function(build_d_executable target_name output_exe d_src_files compiler_args lin
# Compile all D modules to a single object.
set(object_file ${PROJECT_BINARY_DIR}/obj/${target_name}${CMAKE_CXX_OUTPUT_EXTENSION})
# Default to -linkonce-templates with LDMD host compiler, to speed-up optimization.
# FIXME: https://github.com/ldc-developers/ldc/issues/3690
#if("${D_COMPILER_ID}" STREQUAL "LDMD")
# set(dflags -linkonce-templates ${dflags})
#endif()
if("${D_COMPILER_ID}" STREQUAL "LDMD")
set(dflags -linkonce-templates ${dflags})
endif()
add_custom_command(
OUTPUT ${object_file}
COMMAND ${D_COMPILER} -c ${dflags} -of${object_file} ${d_src_files}
Expand Down
12 changes: 6 additions & 6 deletions gen/nested.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
fd->toPrettyChars());
LOG_SCOPE

FuncDeclaration *parentFunc = getParentFunc(fd);
// Make sure the parent has already been analyzed.
if (parentFunc) {
DtoCreateNestedContextType(parentFunc);
}

DtoDeclareFunction(fd);

IrFunction &irFunc = *getIrFunc(fd);
Expand All @@ -326,12 +332,6 @@ static void DtoCreateNestedContextType(FuncDeclaration *fd) {
}
irFunc.nestedContextCreated = true;

FuncDeclaration *parentFunc = getParentFunc(fd);
// Make sure the parent has already been analyzed.
if (parentFunc) {
DtoCreateNestedContextType(parentFunc);
}

if (fd->closureVars.length == 0) {
// No local variables of this function are captured.
if (parentFunc) {
Expand Down