Skip to content

Commit

Permalink
CI: Adapt to generic Makefile for Phobos
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke authored and thewilsonator committed Dec 18, 2023
1 parent f8ee42a commit f3f89ca
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 81 deletions.
15 changes: 4 additions & 11 deletions .azure-pipelines/windows-msbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ set DMD=%DMD_DIR%\generated\Windows\%CONFIGURATION%\%PLATFORM%\dmd.exe

set VISUALD_INSTALLER=VisualD-%VISUALD_VER%.exe
set N=3
set DM_MAKE=%DMD_DIR%\dm\path\make.exe
set LDC_DIR=%DMD_DIR%\ldc2-%LDC_VERSION%-windows-multilib

if "%D_COMPILER%" == "ldc" set HOST_DMD=%LDC_DIR%\bin\ldmd2.exe
if "%D_COMPILER%" == "dmd" set HOST_DMD=%DMD_DIR%\dmd2\windows\bin\dmd.exe

set MSVC_CC=cl.exe
FOR /F "tokens=* USEBACKQ" %%F IN (`where lib.exe`) DO (SET MSVC_AR=%%~fsF)

REM add grep to PATH
set PATH=%DMD_DIR%\tools;%PATH%
echo %PATH%
Expand All @@ -48,10 +44,7 @@ echo [STEP]: Building druntime
make -j%N% -C "%DMD_DIR%\druntime" MODEL=%MODEL% "DMD=%DMD%" || exit /B 2

echo [STEP]: Building phobos
cd "%DMD_DIR%\..\phobos"
"%DM_MAKE%" -f win64.mak MODEL=%MODEL% "DMD=%DMD%" "VCDIR=%VCINSTALLDIR%." "CC=%MSVC_CC%" "AR=%MSVC_AR%" "MAKE=%DM_MAKE%" "DRUNTIME=%DMD_DIR%\druntime" "DRUNTIMELIB=%DMD_DIR%\generated\windows\release\%MODEL%\druntime.lib" || exit /B 3
:: The expected Phobos filename for 32-bit COFF is phobos32mscoff.lib, not phobos32.lib.
if "%MODEL%" == "32" ren phobos32.lib phobos32mscoff.lib || exit /B 3
make -j%N% -C "%DMD_DIR%\..\phobos" MODEL=%MODEL% "DMD=%DMD%" "DMD_DIR=%DMD_DIR%" || exit /B 3

echo [STEP]: Building run.d testrunner and its tools
REM needs to be done before tampering with LIB and DFLAGS env variables (affecting the ldmd2 host compiler too)
Expand Down Expand Up @@ -94,11 +87,11 @@ if not "%C_RUNTIME%" == "mingw" goto not_mingw

echo [STEP]: Building and running druntime tests
cd "%DMD_DIR%\druntime"
make -j%N% MODEL=%MODEL% "DMD=%DMD%" "CC=%MSVC_CC%" %DRUNTIME_TESTS_TARGET% || exit /B 5
make -j%N% MODEL=%MODEL% "DMD=%DMD%" %DRUNTIME_TESTS_TARGET% || exit /B 5

echo [STEP]: Running DMD testsuite
cd "%DMD_DIR%\compiler\test"
run.exe --environment --jobs=%N% %DMD_TESTS% "ARGS=-O -inline -g" "BUILD=%CONFIGURATION%" "DMD_MODEL=%PLATFORM%" "CC=%MSVC_CC%" || exit /B 6
run.exe --environment --jobs=%N% %DMD_TESTS% "ARGS=-O -inline -g" "BUILD=%CONFIGURATION%" "DMD_MODEL=%PLATFORM%" CC=cl.exe || exit /B 6

echo [STEP]: Building and running Phobos unittests
rem FIXME: lld-link fails to link phobos unittests ("error: relocation against symbol in discarded section: __TMP2427")
Expand All @@ -108,4 +101,4 @@ if "%D_COMPILER%_%MODEL%" == "ldc_64" copy %LDC_DIR%\lib64\libcurl.dll .
if "%D_COMPILER%_%MODEL%" == "ldc_32" copy %LDC_DIR%\lib32\libcurl.dll .
if "%D_COMPILER%_%MODEL%" == "dmd_64" copy %DMD_DIR%\dmd2\windows\bin64\libcurl.dll .
if "%D_COMPILER%_%MODEL%" == "dmd_32" copy %DMD_DIR%\dmd2\windows\bin\libcurl.dll .
"%DM_MAKE%" -f win64.mak MODEL=%MODEL% "DMD=%DMD%" "VCDIR=%VCINSTALLDIR%." "CC=%MSVC_CC%" "MAKE=%DM_MAKE%" "DRUNTIME=%DMD_DIR%\druntime" "DRUNTIMELIB=%DMD_DIR%\generated\windows\release\%MODEL%\druntime.lib" unittest || exit /B 7
make -j%N% MODEL=%MODEL% "DMD=%DMD%" "DMD_DIR=%DMD_DIR%" unittest || exit /B 7
16 changes: 0 additions & 16 deletions .azure-pipelines/windows-visual-studio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ visuald() {
fi
}

################################################################################
# Download DigitalMars Make
################################################################################

dm_make() {
download "https://downloads.dlang.org/other/dm857c.zip" dmc.zip
unzip dmc.zip > /dev/null
export DMC="$PWD/dm/bin/dmc.exe"
export DM_MAKE="$PWD/dm/bin/make.exe"
mkdir -p dm/path
cp "$DMC" "$DM_MAKE" "dm/path"
}

if [ "$D_COMPILER" == "ldc" ]; then
echo "[STEP]: Downloading LDC"
ldc
Expand All @@ -64,9 +51,6 @@ fi
echo "[STEP]: Downloading VisualD"
visuald

echo "[STEP]: Downloading DigitalMars make"
dm_make

echo "[STEP]: Downloading grep"
install_grep

Expand Down
18 changes: 4 additions & 14 deletions .azure-pipelines/windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ echo "GREP_VERSION: $(grep --version)"
# Prepare DigitalMars make and C compiler
################################################################################

GNU_MAKE="$(which make)" # must be done before installing dmd (tampers with PATH)
install_host_dmc
DM_MAKE="$PWD/dm/bin/make.exe"
GNU_MAKE="$(which make)" # must be done before installing dmc (tampers with PATH)

if [ "$MODEL" == "32omf" ] ; then
install_host_dmc
CC="$PWD/dm/bin/dmc.exe"
AR="$PWD/dm/bin/lib.exe"
export CPPCMD="$PWD/dm/bin/sppn.exe"
else
CC="cl.exe"
AR="$(where lib.exe)" # must be done before installing dmd
fi

################################################################################
Expand Down Expand Up @@ -98,16 +95,9 @@ DMD_BIN_PATH="$DMD_DIR/generated/windows/release/$TOOL_MODEL/dmd.exe"
# Build Druntime and Phobos
################################################################################

LIBS_MAKE_ARGS=(-f "$MAKE_FILE" MODEL=$MODEL DMD="$DMD_BIN_PATH" VCDIR=. CC="$CC" AR="$AR" MAKE="$DM_MAKE")

"$GNU_MAKE" -j$N -C "$DMD_DIR/druntime" MODEL=$MODEL DMD="$DMD_BIN_PATH"

cd "$DMD_DIR/../phobos"
"$DM_MAKE" "${LIBS_MAKE_ARGS[@]}" DRUNTIME="$DMD_DIR\druntime" DRUNTIMELIB="$DMD_DIR/generated/windows/release/$MODEL/druntime.lib"
if [[ "$MODEL" == "32" ]]; then
# the expected Phobos filename for 32-bit COFF is phobos32mscoff.lib, not phobos32.lib
mv phobos32.lib phobos32mscoff.lib
fi
"$GNU_MAKE" -j$N -C "$DMD_DIR/../phobos" MODEL=$MODEL DMD="$DMD_BIN_PATH" CC="$CC" DMD_DIR="$DMD_DIR"

################################################################################
# Run DMD testsuite
Expand Down Expand Up @@ -183,7 +173,7 @@ else
else
cp "$DMD_DIR/tools/dmd2/windows/bin/libcurl.dll" .
fi
"$DM_MAKE" "${LIBS_MAKE_ARGS[@]}" DRUNTIME="$DMD_DIR\druntime" DRUNTIMELIB="$DMD_DIR/generated/windows/release/$MODEL/druntime.lib" unittest
"$GNU_MAKE" -j$N MODEL=$MODEL DMD="$DMD_BIN_PATH" CC="$CC" DMD_DIR="$DMD_DIR" unittest
fi

################################################################################
Expand Down
4 changes: 2 additions & 2 deletions .circleci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ coverage()
# build dmd, druntime, and phobos
$builder MODEL=$MODEL HOST_DMD=$DMD BUILD=$BUILD all
make -j$N -C druntime MODEL=$MODEL BUILD=$BUILD
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL BUILD=$BUILD
make -j$N -C ../phobos MODEL=$MODEL BUILD=$BUILD

# save the built dmd as host compiler this time
# `generated` gets removed in 'clean', so we create another _generated
Expand Down Expand Up @@ -190,7 +190,7 @@ test_cxx()
echo "Test CXX frontend.h header generation"
./compiler/src/build.d
make -j$N -C druntime MODEL=$MODEL BUILD=$BUILD
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL BUILD=$BUILD
make -j$N -C ../phobos MODEL=$MODEL BUILD=$BUILD
./compiler/src/build.d cxx-headers-test
deactivate
}
Expand Down
40 changes: 5 additions & 35 deletions .github/workflows/runnable_cxx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,31 +277,6 @@ jobs:
exit 1
fi
# Restore or install dmc (and DM make)
- name: '[Windows] Restore dmc from cache'
id: cache-dmc
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: ${{ github.workspace }}\tools\
key: ${{ matrix.os }}-dmc857

- name: '[Windows] Install dmc'
if: runner.os == 'Windows' && steps.cache-dmc.outputs.cache-hit != 'true'
shell: powershell
run: |
$url = "http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm857c.zip"
$sha256hash = "F51CDFEB45EAF4FFBF7ABF0FE9B3D548B202B4528401005C2C3192B00BC32367"
Write-Host ('Downloading {0} ...' -f $url)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue'
New-Item -ItemType directory -Path ${{ github.workspace }}\tools\
Invoke-WebRequest -Uri $url -OutFile '${{ github.workspace }}\tools\dmc.zip'
if ((Get-FileHash '${{ github.workspace }}\tools\dmc.zip' -Algorithm "SHA256").Hash -ne $sha256hash) {
exit 1
}
Expand-Archive '${{ github.workspace }}\tools\dmc.zip' -DestinationPath ${{ github.workspace }}\tools\
- name: '[Windows] Add VC toolset to PATH'
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
Expand All @@ -310,10 +285,7 @@ jobs:
if: runner.os == 'Windows'
shell: bash
run: |
echo "VISUAL_STUDIO_LIB_NOT_DM=$(which lib.exe)" >> $GITHUB_ENV
echo "HOST_DMD=${{ env.DC }}" >> $GITHUB_ENV
echo "GNU_MAKE=$(which make.exe)" >> $GITHUB_ENV
echo "${{ github.workspace }}/tools/dm/bin/" >> $GITHUB_PATH
########################################
# Building DMD, druntime, Phobos #
Expand All @@ -326,13 +298,13 @@ jobs:
# All hosts are 64 bits but let's be explicit
./dmd/compiler/src/build.d -j2 MODEL=64
make -C dmd/druntime -j2 MODEL=64
make -C phobos -f posix.mak -j2 MODEL=64
make -C phobos -j2 MODEL=64
# Both version can live side by side (they end up in a different directory)
# However, since clang does not provide a multilib package, only test 32 bits with g++
if [ ${{ matrix.compiler }} == "g++" ]; then
./dmd/compiler/src/build.d install -j2 MODEL=32
make -C dmd/druntime install -j2 MODEL=32
make -C phobos -f posix.mak install -j2 MODEL=32
make -C phobos install -j2 MODEL=32
fi
- name: '[Windows] Build compiler & standard library'
Expand All @@ -344,12 +316,10 @@ jobs:
# Note: Only CC for druntime and AR for Phobos are required ATM,
# but providing all three to avoid surprise for future contributors
# Those should really be in the path, though.
"$GNU_MAKE" -j2 -C dmd/druntime
make -j2 -C dmd/druntime
if [ $? -ne 0 ]; then return 1; fi
cd phobos/
make -f win64.mak CC=cl.exe LD=link "AR=$VISUAL_STUDIO_LIB_NOT_DM" "DRUNTIMELIB=../dmd/generated/windows/release/64/druntime.lib"
make -j2 -C phobos
if [ $? -ne 0 ]; then return 1; fi
cd ../
########################################
# Running the test suite #
Expand All @@ -370,7 +340,7 @@ jobs:
if: runner.os == 'Windows'
shell: bash
run: |
"$GNU_MAKE" -j2 -C dmd/druntime test/stdcpp/.run CC=cl.exe LD=link "AR=$VISUAL_STUDIO_LIB_NOT_DM"
make -j2 -C dmd/druntime test/stdcpp/.run
if [ $? -ne 0 ]; then return 1; fi
########################################
Expand Down
4 changes: 2 additions & 2 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ build() {
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS="$CI_DFLAGS" BUILD=debug unittest
generated/build -j$N MODEL=$MODEL HOST_DMD=$DMD DFLAGS="$CI_DFLAGS" ENABLE_RELEASE=1 dmd
make -j$N -C druntime MODEL=$MODEL
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL
make -j$N -C ../phobos MODEL=$MODEL
deactivate # deactivate host compiler
}

Expand Down Expand Up @@ -119,7 +119,7 @@ test_druntime() {

# build and run Phobos unit tests
test_phobos() {
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL unittest
make -j$N -C ../phobos MODEL=$MODEL unittest
}

# test dub package
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ alias dmdPGO = makeRule!((builder, rule) {
// Run phobos unittests
//TODO makefiles
//generated/linux/release/64/unittest/test_runner builds the unittests without running them.
const scope cmd = ["make", "-C", "../phobos", "-j" ~ jobs.to!string, "-fposix.mak", "generated/linux/release/64/unittest/test_runner", "DMD_DIR="~compilerDir];
const scope cmd = ["make", "-C", "../phobos", "-j" ~ jobs.to!string, "generated/linux/release/64/unittest/test_runner", "DMD_DIR="~compilerDir];
log("%-(%s %)", cmd);
if (spawnProcess(cmd, null, Config.init, compilerDir).wait())
stderr.writeln("Phobos Tests failed! This will not end the PGO build because some data may have been gathered");
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ void setDefaultLibrary(ref Param params, const ref Target target)

if (driverParams.debuglibname is null)
driverParams.debuglibname = driverParams.defaultlibname;
else if (!driverParams.debuglibname.length) // if `-debuglib=` (i.e. an empty debuglib)
driverParams.debuglibname = null;
}

void printPredefinedVersions(FILE* stream)
Expand Down

0 comments on commit f3f89ca

Please sign in to comment.