Skip to content

Conversation

@kinke
Copy link
Contributor

@kinke kinke commented Jun 24, 2020

No description provided.

@kinke kinke force-pushed the ci_phobos branch 7 times, most recently from 91f5457 to 4b6abd1 Compare June 25, 2020 02:20
@kinke
Copy link
Contributor Author

kinke commented Jun 25, 2020

@rainers: What a mess, thx for the pointers wrt. Optlink. I find it very surprising that the issue (tools compiled by host compiler, but linked against fresh phobos.lib) only begins to show up now with dlang/druntime#3141 and dlang/druntime#3142.

Optlink apparently unconditionally reading from sc.ini in the containing directory, even when running DMD with -conf= is totally unexpected, and I'm surprised this hasn't caused enough problems for someone to fix it. As the config file seems to take precedence over the LIB env variable, I guess the only way to enforce a dir from which to take phobos.lib etc. would be specifying that dir in the linker cmdline via some -L... in the DMD cmdline. No idea how Optlink's CLI option needs to look like though.
And that still wouldn't be enough, as the run command would need 2 different sets of arguments, one for the tools compiled by the host compiler, and one for the regular tests using the fresh compiler. Some tools being built by Makefile and others by run.d doesn't make this mess any easier.

Previously, the tools were compiled by the DMD host compiler, but linked
with freshly compiled druntime/Phobos, leading to inevitable issues
popping up in dlang/druntime#3141 and dlang/druntime#3142.
@kinke kinke changed the title Azure CI experiment Azure CI OMF job: Link testsuite tools with correct phobos.lib Jun 26, 2020
@rainers
Copy link
Member

rainers commented Jun 26, 2020

The (rather surprising) way to pass a library search path to optlink as a command line argument is to specify it in place of a library, but with a trailing \, see lib in https://www.digitalmars.com/ctg/optlink.html.

Another option should be to pass phobos.lib explicitly on the command line, Not sure how to integrate that with the ci scripts and tools, though.

@kinke
Copy link
Contributor Author

kinke commented Jun 26, 2020

I was wondering how/why the autotester works. And well, it's not using the host compiler for building any tools, but the fresh compiler exclusively:

HOST_DC=/home/braddr/sandbox/at-client/release-build/dmd-2.079.0/windows/bin/dmd.exe
HOST_DC=D:\sandbox\at-client\release-build\dmd-2.079.0\windows\bin\dmd.exe
cd test
gmake -j4
Makefile:103: Please use HOST_DMD instead of HOST_DC!
Creating output directory: test_results
Building d_do_test tool
OS: 'windows'
MODEL: '32'
PIC: ''
../generated/windows/release/32/dmd.exe -conf= -m32  -g -lowmem -i -Itools -version=NoMain -unittest -run tools/d_do_test.d
1 modules passed unittests
../generated/windows/release/32/dmd.exe -conf= -m32  -g -lowmem -i -Itools -version=NoMain -odtest_results -oftest_results/d_do_test.exe tools/d_do_test.d
../generated/windows/release/32/dmd.exe -conf= -m32  -g -odtest_results -oftest_results/run.exe -i -release run.d
test_results/run.exe --environment
================================================================================
DFLAGS=-ID:\sandbox\at-client\pull-4094895-Win_32\dmd\test\..\..\druntime\import -ID:\sandbox\at-client\pull-4094895-Win_32\dmd\test\..\..\phobos
ARGS=-inline -release -g -O
DMD_TEST_COVERAGE=0
OS=windows
DSEP=\\
MODEL=32
DMD_MODEL=32
RESULTS_DIR=test_results
DMD=D:\sandbox\at-client\pull-4094895-Win_32\dmd\generated\windows\release\32\dmd.exe
LIB=D:\sandbox\at-client\pull-4094895-Win_32\dmd\test\..\..\phobos
BUILD=release
OBJ=.obj
EXE=.exe
SEP=\
================================================================================
Executing: ../generated/windows/release/32/dmd.exe -m32 -oftest_results\unit_test_runner.exe D:\sandbox\at-client\pull-4094895-Win_32\dmd\test\tools\unit_test_runner.d D:\sandbox\at-client\pull-4094895-Win_32\dmd\test\tools\paths
================================================================================
DFLAGS=-ID:\sandbox\at-client\pull-4094895-Win_32\dmd\test\..\..\druntime\import -ID:\sandbox\at-client\pull-4094895-Win_32\dmd\test\..\..\phobos
ARGS=-inline -release -g -O
DMD_TEST_COVERAGE=0
OS=windows
DSEP=\\
MODEL=32
DMD_MODEL=32
RESULTS_DIR=test_results
DMD=D:\sandbox\at-client\pull-4094895-Win_32\dmd\generated\windows\release\32\dmd.exe
LIB=D:\sandbox\at-client\pull-4094895-Win_32\dmd\test\..\..\phobos
BUILD=release
OBJ=.obj
EXE=.exe
SEP=\
================================================================================
Executing: ../generated/windows/release/32/dmd.exe -m32 -oftest_results\unit_test_runner.exe D:\sandbox\at-client\pull-4094895-Win_32\dmd\test\tools\unit_test_runner.d D:\sandbox\at-client\pull-4094895-Win_32\dmd\test\tools\paths
Executing: ../generated/windows/release/32/dmd.exe -m32 -oftest_results\sanitize_json.exe D:\sandbox\at-client\pull-4094895-Win_32\dmd\test\tools\sanitize_json.d

@kinke
Copy link
Contributor Author

kinke commented Jun 26, 2020

The autotester Win_32_64 job is also using the fresh compiler, as is the Azure 'Windows x64' job. The other Azure jobs with LDC in their name (presumably LDC as host compiler) use neither the fresh compiler nor LDC, but (AFAICT) some other DMD installation; these jobs also don't use the test/Makefile, but build run.d manually and then invoke run ... directly. What. A. Mess.

@MoonlightSentinel
Copy link
Contributor

The autotester Win_32_64 job is also using the fresh compiler,

This a (unpleasant) necessity because the autotester uses 2.079 which doesn't support -lowmem. Ideally it should use another host compiler but I don't think that we'll get another DMD installation....

as is the Azure 'Windows x64' job. The other Azure jobs with LDC in their name (presumably LDC as host compiler) use neither the fresh compiler nor LDC, but (AFAICT) some other DMD installation. What. A. Mess.

That is definitly wrong.

these jobs also don't use the test/Makefile

The makefile is a legacy nowadays because we can't access the autotester...

@kinke
Copy link
Contributor Author

kinke commented Jun 26, 2020

LDC uses the fresh compiler to build the tools, always. I've had a discussion regarding this with Rainer some time ago and couldn't be persuaded that using the host compiler would help in making these tests more stable (preventing new compiler/druntime/Phobos from generating faulty tools).

@kinke
Copy link
Contributor Author

kinke commented Jun 26, 2020

Oh wow, DMD apparently also completely ignores the DFLAGS env variable if it's specified in sc.ini (it is by default).

@kinke kinke force-pushed the ci_phobos branch 4 times, most recently from 712f7cf to e2d0fde Compare June 26, 2020 16:49
@kinke
Copy link
Contributor Author

kinke commented Jun 26, 2020

AFAICT, this should be working now as intended (all testsuite tool executables built by host compiler again). I've previously added a -v to the manual DFLAGS, to make sure that var is used for all tools. The test/Makefile isn't used by any Azure Windows jobs anymore.

The Azure 'Windows x64' job now also uses the host compiler (DMD 2.084) for building those tools. -lowmem for d_do_test is only used in the Makefile, not when built via run.d. I've added -lowmem some time ago (in the Makefile), but only to enable parallel building of these tools to save some seconds, but that isn't parallelized any longer AFAICT, so it's probably superfluous now.

@kinke kinke marked this pull request as ready for review June 26, 2020 17:28
auto phobosPath = environment.get("PHOBOS_PATH", testPath(`..\..\phobos`));
env["DFLAGS"] = `-I%s\import -I%s`.format(druntimePath, phobosPath);
env["LIB"] = phobosPath;
env["LIB"] = phobosPath ~ ";" ~ environment.get("LIB");
Copy link
Contributor Author

@kinke kinke Jun 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't completely replace LIB, only prepend the dir containing fresh phobos.lib. We still need the original LIB dirs for kernel32.lib etc.

LIBNAME=phobos32mscoff.lib
else
export MODEL_FLAG="-m32"
export LIB="$PWD/dmd2/windows/lib"
Copy link
Contributor Author

@kinke kinke Jun 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is still necessary, but linking the druntime unittests failed without this (Optlink complaining about incompatible libs in MSVC libdirs). So somehow the optlink.exe used for that command seems to respect the LIB env var (which in this case is a Posix path - /c/...).

# manually for the host compiler. These 2 variables are adapted for the
# actual tests with the tested compiler (by run.d).
HOST_DMD_DIR="$(cygpath -w "$DMD_DIR/tools/dmd2")"
rm "$HOST_DMD_DIR/windows/bin/sc.ini"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this.

Instead of breaking the host compiler installation (in case someone uses the script outside of the CI), placing an empty sc.ini into the current directory should also work, because that's preferred by optlink.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick local test shows that's not the case. DMD prefers that sc.ini in the current dir, but Optlink isn't, regardless of whether it's completely empty or contains an empty [Environment] section, and regardless of whether Optlink is invoked via DMD or directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I was looking at this comment: https://github.com/DigitalMars/optlink/blob/87a85b0413d94fb8017656004a03f7fb0aa3a649/common/iniproc.asm#L52

I guess no one uses the CI build scripts locally.

Copy link
Member

@rainers rainers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how the affected druntime tests work with this.

@dlang-bot dlang-bot merged commit 2ba989e into dlang:master Jun 27, 2020
@kinke kinke deleted the ci_phobos branch June 27, 2020 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants