Skip to content

Commit

Permalink
DMD tests on Windows: Default CC to cl.exe in PATH for MSVC models
Browse files Browse the repository at this point in the history
Instead of defaulting to some old hardcoded version.
  • Loading branch information
kinke authored and thewilsonator committed Dec 23, 2023
1 parent 174bbc5 commit d03a4d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/windows-msbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ 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=cl.exe || exit /B 6
run.exe --environment --jobs=%N% %DMD_TESTS% "ARGS=-O -inline -g" "BUILD=%CONFIGURATION%" "DMD_MODEL=%PLATFORM%" || 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 Down
17 changes: 7 additions & 10 deletions compiler/test/tools/d_do_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ struct EnvData
bool coverage_build; /// `COVERAGE`: coverage build, skip linking & executing to save time
bool autoUpdate; /// `AUTO_UPDATE`: update `(TEST|RUN)_OUTPUT` on missmatch
bool printRuntime; /// `PRINT_RUNTIME`: Print time spent on a single test
bool usingMicrosoftCompiler; /// Using Visual Studio toolchain
bool tryDisabled; /// `TRY_DISABLED`:Silently try disabled tests (ignore failure and report success)
}

Expand Down Expand Up @@ -198,18 +197,16 @@ immutable(EnvData) processEnvironment()
else if (envData.model == "32omf")
envData.ccompiler = "dmc";
else if (envData.model == "64")
envData.ccompiler = `C:\"Program Files (x86)"\"Microsoft Visual Studio 10.0"\VC\bin\amd64\cl.exe`;
envData.ccompiler = "cl";
else if (envData.model == "32mscoff")
envData.ccompiler = `C:\"Program Files (x86)"\"Microsoft Visual Studio 10.0"\VC\bin\amd64_x86\cl.exe`;
envData.ccompiler = "cl";
else
{
writeln("Unknown $OS$MODEL combination: ", envData.os, envData.model);
throw new SilentQuit();
}
}

envData.usingMicrosoftCompiler = envData.ccompiler.toLower.endsWith("cl.exe");

version (Windows) {} else
{
version(X86_64)
Expand Down Expand Up @@ -1098,13 +1095,13 @@ bool collectExtraSources (in string input_dir, in string output_dir, in string[]
auto curSrc = input_dir ~ envData.sep ~"extra-files" ~ envData.sep ~ cur;
auto curObj = output_dir ~ envData.sep ~ cur ~ envData.obj;
string command = quoteSpaces(compiler);
if (envData.usingMicrosoftCompiler)
if (envData.model == "32omf") // dmc.exe
{
command ~= ` /c /nologo `~curSrc~` /Fo`~curObj;
command ~= " -c "~curSrc~" -o"~curObj;
}
else if (envData.compiler == "dmd" && envData.os == "windows" && envData.model == "32omf")
else if (envData.os == "windows") // cl.exe
{
command ~= " -c "~curSrc~" -o"~curObj;
command ~= ` /c /nologo `~curSrc~` /Fo`~curObj;
}
else
{
Expand Down Expand Up @@ -1832,7 +1829,7 @@ int tryMain(string[] args)
{
toCleanup ~= test_app_dmd;
version(Windows)
if (envData.usingMicrosoftCompiler)
if (envData.model != "32omf")
{
toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".ilk";
toCleanup ~= test_app_dmd_base ~ to!string(permuteIndex) ~ ".pdb";
Expand Down

0 comments on commit d03a4d4

Please sign in to comment.