Page MenuHomePhabricator

Bug 290526 Write separate PDBs for test OBJs
ClosedPublic

Authored by jmux on Mar 28 2020, 9:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jul 14 2025, 1:34 PM
Unknown Object (File)
Jul 5 2025, 1:03 PM
Unknown Object (File)
Jul 5 2025, 10:52 AM
Unknown Object (File)
Jul 5 2025, 9:25 AM
Unknown Object (File)
Jul 1 2025, 11:05 PM
Unknown Object (File)
Jul 1 2025, 5:48 PM
Unknown Object (File)
Jul 1 2025, 1:09 PM
Unknown Object (File)
Jun 2 2025, 9:48 AM
Subscribers

Details

Summary

Quite often when running a parallel NSS build, I get the following
compiler error message, resulting in a build failure, despite
compiling with the -FS flag:

.../nss/nspr/pr/tests/zerolen.c: fatal error C1041:
Programmdatenbank "...\nss\nspr\out\pr\tests\vc140.pdb" kann nicht
ge<94>ffnet werden; verwenden Sie /FS, wenn mehrere CL.EXE in
dieselbe .PDB-Datei schreiben.

The failing source file is always one of the last test object
files. But the actual problem is not the compiler accessing the
PDB file, but the linker already linking the first test
executables accessing the shared PDB; at least that's my guess.

So instead of using a shared PDB for all test object files, this
uses -Fd$(@:.$(OBJ_SUFFIX)=.pdb) to write a separate PDB for every
test's object file. The linker works fine with the shared OBJ PDB.

Diff Detail

Repository
rNSPR nspr

Event Timeline

phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
jmux added a reviewer: Restricted Project.Mar 31 2020, 9:22 AM
dmajor edited reviewers, added: glandium; removed: Restricted Project.EditedMar 31 2020, 1:35 PM
dmajor added a subscriber: dmajor.

Since this is in the NSPR repo, it needs to be reviewed by an NSPR peer.

This revision now requires changes to proceed.Apr 1 2020, 6:35 AM

I'll try to reproduce the original error. These patches were done a few months ago. I saw these errors in some failed CI builds and just added this.
That was definitely some newer MSVC and NSS bundle then 2013, so the check

if test "$MSC_VER" -ge "1800"; then

should have correctly added -FS to the $CFLAGS. I'm really puzzled.

Maybe it was just some problem / conflict with some other changes I tried at the time.

FWIW the original work was done in https://gerrit.libreoffice.org/c/core/+/74751

LO tested gyp + ninja last month (some info in https://lists.freedesktop.org/archives/libreoffice/2020-February/084461.html), but had too many different failures on Windows, so that change was reverted in https://gerrit.libreoffice.org/c/core/+/91199

Hmm - thinking about it again, CFLAGS is just used for C files and -FS is not added to CXXFLAGS, but _DEBUG_FLAGS is. Maybe that was the real problem. Adding -FS also to CXXFLAGS shouldn't hurt.

Hmm - so I re-read the makefiles, and from all I can find, CXXFLAGS is never used, as it's just assigned to OS_CXXFLAGS in config/autoconf.mk.in, which is nowhere referenced. But then maybe CXXFLAGS is somehow referenced via some magic automatic make rule, when the %.cpp rule doesn't match. CCCFLAGS also uses OS_CFLAGS, for whatever reason. I'm more confused then before, as the configure.in case of "*-mingw*|*-msys*|*-cygwin*|*-mks*)" doesn't set any CXXFLAGS at all, while there are many assignments in the rest of the script.

Any idea, what might be going on?

Otherwise let's drop this.

I'll check, if LO CI now builds NSS in parallel without that patch. At least it works locally, but that wasn't a good indicator in the past, so…

jmux retitled this revision from Bug 290526 Force synchronous PDB writes to Bug 290526 Write separate PDB files.
jmux edited the summary of this revision. (Show Details)

So after a few builds, I've updated the patch. I still get parallel build failures on Windows, because of PDB access. See the patch commit message for the background of the bug, as I understand it.

It feels like it should still use -FS when compiling objects, and -Fd when linking.

This revision now requires changes to proceed.Apr 14 2020, 2:46 AM

It feels like it should still use -FS when compiling objects, and -Fd when linking.

We can't use the -Fd for linking, as NSPR on Windows directly calls the linker, like link -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO accept.obj ../../../../dist/out/lib/plc4.lib ../../../../dist/out/lib/nspr4.lib ws2_32.lib -out:accept.exe for DLLs and EXEs. The PDB for these is correctly named, as also documented in the -PDB option of the MS linker: "The default file name for the PDB has the base name of the program and the extension .pdb".

As a side note: I found the following in pr/tests/Makefile.in for WINCE: LDOPTS += -link $(DIST)/lib/mozce_shunt.lib ws2.lib -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO -PDB:$(@:.exe=.pdb). So it looks like linking on Windows CE is done via the compiler...

Previously I had just checked the DLL pdb, so I missed, that the previous substitution of accept.obj resulted in accept..pdb. The link of the accept.exe still could produce a separate accept.pdb. Therefore I settled for the .obj.pdb postfix.

It feels like it should still use -FS when compiling objects, and -Fd when linking.

We can't use the -Fd for linking, as NSPR on Windows directly calls the linker, like link -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO accept.obj ../../../../dist/out/lib/plc4.lib ../../../../dist/out/lib/nspr4.lib ws2_32.lib -out:accept.exe for DLLs and EXEs. The PDB for these is correctly named, as also documented in the -PDB option of the MS linker: "The default file name for the PDB has the base name of the program and the extension .pdb".

Then I don't see what the problem is you're trying to fix. With -FS, it should work.

As a side note: I found the following in pr/tests/Makefile.in for WINCE: LDOPTS += -link $(DIST)/lib/mozce_shunt.lib ws2.lib -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO -PDB:$(@:.exe=.pdb). So it looks like linking on Windows CE is done via the compiler...

Previously I had just checked the DLL pdb, so I missed, that the previous substitution of accept.obj resulted in accept..pdb. The link of the accept.exe still could produce a separate accept.pdb. Therefore I settled for the .obj.pdb postfix.

I mean, moving -FS to _DEBUG_FLAGS should work.

It feels like it should still use -FS when compiling objects, and -Fd when linking.

We can't use the -Fd for linking, as NSPR on Windows directly calls the linker, like link -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO accept.obj ../../../../dist/out/lib/plc4.lib ../../../../dist/out/lib/nspr4.lib ws2_32.lib -out:accept.exe for DLLs and EXEs. The PDB for these is correctly named, as also documented in the -PDB option of the MS linker: "The default file name for the PDB has the base name of the program and the extension .pdb".

Then I don't see what the problem is you're trying to fix. With -FS, it should work.

I'm trying to fix the .../nss/nspr/pr/tests/zerolen.c: fatal error C1041: Programmdatenbank "...\nss\nspr\out\pr\tests\vc140.pdb" kann nicht ge<94>ffnet werden; verwenden Sie /FS, wenn mehrere CL.EXE in dieselbe .PDB-Datei schreiben. error. As you already noticed, the build uses -FS, so that error message is misleading.

-FS is a compiler flag and I don't see an equivalent for the linker. My theory of the failure is, that the linker reads the shared PDB vc140.pdb to generate the PDB for the EXE, but the compiler still want to write to the shared PDB creating the OBJs of the last tests. Any idea how to prove this?

I tried again to build NSPR with tests on Windows, but in the mozilla setup it simply doesn't link the test EXEs and just finishes successful. which puzzles me. Building NSS via LO env incl. this patch works and fails without. And none of LOs additional NSS patches looks like it should affect linking...

I mean, moving -FS to _DEBUG_FLAGS should work.

So I exchanged

-                                                CFLAGS="$CFLAGS -FS"
+                                                _DEBUG_FLAGS="$_DEBUG_FLAGS -FS"

but that still fails in the same way.

I'm trying to build NSPR with unpatched NSPR and NSS sources using the following script:

#!/bin/sh

FLAGS="USE_64=1 MOZ_DEBUG_SYMBOLS=1 USE_DEBUG_RTL=1 OPT_CODE_SIZE=0 OS_TARGET=WIN95"

export PATH="/c/mozilla-source/gyp:$PATH"
export target_arch=x64
. nss/coreconf/msvc.sh

set -x

make -j6 -C nss clobber_nspr $FLAGS >/dev/null 2>&1
rm -rf dist/
rm -rf nspr/WIN954.0_x86_64_64_DBG.OBJ/
make -j6 -C nss build_nspr $FLAGS >nspr.log 2>&1

How can we continue with this? Building parallel NSS without this patch on Windows breaks for me in NSPR most of the time, so I see no point to land all the NSS patches without a fixed NSPR build. Do you also see my described problems?

Ok, so the problem is when there are multiple executables built in the same directory. I think I'd prefer only touching to these directories.

This revision now requires changes to proceed.Apr 24 2020, 5:41 AM
jmux retitled this revision from Bug 290526 Write separate PDB files to Bug 290526 Write separate PDBs for test OBJs.
jmux edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Apr 28 2020, 7:13 AM

I have to disconnect the NSPR change from the NSS ones, Lando can't handle both at once.