New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 627924 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 1
Type: Bug

Blocked on:
issue 647315

Blocking:
issue 631771



Sign in to add a comment

Windows: chrome_elf target fails to link with GYP (maybe also a bug in GN?)

Project Member Reported by marshall@chromium.org, Jul 13 2016

Issue description

Version: Chromium master revision 68623971 (#403382)
OS: Windows 10 64-bit

What steps will reproduce the problem?
(1) Try to create a Debug build of the chrome_elf target with GYP (this target is depended on by chrome.gyp:browser).

What is the expected output?
The build should succeed.

What do you see instead?
The build fails with the following errors:

[1296/5150] LINK_EMBED(DLL) chrome_elf.dll
FAILED: chrome_elf.dll chrome_elf.dll.lib chrome_elf.dll.pdb
c:\code\depot_tools\python276_bin\python.exe gyp-win-tool link-with-manifests environment.x86 True chrome_elf.dll "c:\code\depot_tools\python276_bin\python.exe gyp-win-tool link-wrapper environment.x86 False link.exe /nologo /IMPLIB:chrome_elf.dll.lib /DLL /OUT:chrome_elf.dll @chrome_elf.dll.rsp" 2 mt.exe rc.exe "obj\chrome_elf\chrome_elf.chrome_elf.dll.intermediate.manifest" obj\chrome_elf\chrome_elf.chrome_elf.dll.generated.manifest
base.lib(base.logging.obj) : error LNK2019: unresolved external symbol __imp__MessageBoxW@16 referenced in function "void __cdecl logging::DisplayDebugMessageInDialog(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?DisplayDebugMessageInDialog@logging@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
base.lib(base.message_pump_win.obj) : error LNK2019: unresolved external symbol __imp__PeekMessageW@20 referenced in function "private: bool __thiscall base::MessagePumpForUI::ProcessPumpReplacementMessage(void)" (?ProcessPumpReplacementMessage@MessagePumpForUI@base@@AAE_NXZ)
chrome_elf.dll : fatal error LNK1120: 2 unresolved externals

Please use labels and text to provide additional information.
The chrome_elf.gyp configuration explicitly excludes user32.dll [1], the lib which exports these symbols. Removing that exclusion causes the build to succeed:

diff --git a/chrome_elf/chrome_elf.gyp b/chrome_elf/chrome_elf.gyp
index 7a49fe8..b4be214 100644
--- a/chrome_elf/chrome_elf.gyp
+++ b/chrome_elf/chrome_elf.gyp
@@ -59,12 +59,6 @@
           ],
           # Set /SUBSYSTEM:WINDOWS.
           'SubSystem': '2',
-          'AdditionalDependencies!': [
-            'user32.lib',
-          ],
-          'IgnoreDefaultLibraryNames': [
-            'user32.lib',
-          ],
         },
       },
     },

The build succeeds when using GN with no changes. If the intent is to completely exclude user32.dll from linking (not sure why you want to do that?) then this issue might also be considered a bug in GN, since GN still includes user32.lib in the 'libs' section of obj\chrome_elf\chrome_elf.ninja despite the attempts to exclude it in chrome_elf/BUILD.gn.

[1] https://cs.chromium.org/chromium/src/chrome_elf/chrome_elf.gyp?rcl=0&l=62
 
Cc: penny...@chromium.org
+Penny who is looking into elf stuff nowadays. 

That GN doesn't exclude user32.dll is bad. chrome_elf must not depend on user32.dll, otherwise it gets loaded too late in the process startup sequence for it to work properly. 

If it does this in Release mode as well, then Chrome's startup sequence won't run as expected. 
Cc: brettw@chromium.org
FWIW, it looks like this is two bugs:

1) a base/ dependency has snuck into elf via logging (logging::DisplayDebugMessageInDialog). This appears to be wrapped in a #if !defined(NDEBUG) check, so might not affect Release builds. 

2) the GN build doesn't properly exclude user32.dll from chrome_elf's link line. This is weird because the BUILD.gn file does include "/NODEFAULTLIB:user32.lib"

Cc: brucedaw...@chromium.org
Labels: -Build-Tools-GN -Pri-3 Proj-GN-Migration Pri-1
The gn build's chrome_elf.dll.rsp file includes "/DELAYLOAD:user32.dll" - maybe that is overriding /NODEFAULTLIB:user32.lib?
Owner: penny...@chromium.org
Blocking: 631771
Labels: -Proj-GN-Migration Proj-GN-Migration-Ship
I assume we need to fix this prior to shipping a GN build, yes?
It would be safer to fix it, since the current behavior means we could accidentally ship a dependency on user32.dll.
Status: Started (was: Untriaged)
Just letting folks know that work is underway for this.  It's not a super quick fix to remove the dependencies that snuck in with the change to crashpad in chrome_elf.

I want gyp to die too, so I'm sorry this work is holding up GN.  FYI it's underway though.
Question for anyone: what GN args are we using on the try/official Windows bots?  I'm interested in both the officials builds, and also the testing.
I'm asking because we should have seen a test bot failure when these new dependencies snuck in (with either gyp or gn), and the fact that we didn't means we may be testing with either COMPONENT_BUILD, or only DEBUG.

https://cs.chromium.org/chromium/src/chrome_elf/elf_imports_unittest.cc?q=ELFImportsTest&sq=package:chromium&dr=CSs&l=65

That would not be good for chrome_elf testing.
We are using lots of GN args on the try/official Windows bots. I checked a few of the try bots by looking at the generate_build_files with patch stage:

https://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/264756/steps/generate_build_files%20%28with%20patch%29/logs/stdio

and for the win_chromium_rel_ng builder linked above the settings are:

dcheck_always_on = true
ffmpeg_branding = "Chrome"
goma_dir = "E:\\b\\c\\cipd\\goma"
is_component_build = false
is_debug = false
proprietary_codecs = true
symbol_level = 1
target_cpu = "x86"
use_goma = true

So, non-component, non-debug.

We definitely don't have coverage of all permutations and targets, but non-component, non-debug is covered.

An alternate way of seeing what settings we build with is to look at src\tools\mb\mb_config.pyl, or use MB to recreate the settings from a particular builder:

  python tools\mb\mb.py gen //out/win8_chromium_rel -m tryserver.chromium.win -b win8_chromium_ng
@pennymac - this isn't (really) holding up GN, but presumably we need to fix this before we ship a GN-built binary in M54. Have all of your questions been answered?


For now Dirk, thanks.

I'll focus on getting user32 out of chrome_elf first.  Then I'll try to figure out why the try bots aren't running the tests that would have failed and flagged this bad dependency.
FYI: https://bugs.chromium.org/p/chromium/issues/detail?id=647315

I'm thinking of shutting down this ticket now (shout if you disagree).

1) The linker should fail out on user32 if it is configured in GN. (The new bug above.)
2) Our sanity backup are some automated chrome_elf tests that watch for user32.lib immediately loading.  (Example symptom: https://bugs.chromium.org/p/chromium/issues/detail?id=646414)


When one of the above situations fail, someone has introduced a bad dependency (or there's a toolchain failure), and it needs fixing.
Blockedon: 647315
Labels: -Proj-GN-Migration-Ship
Closing seems reasonable if we have sufficient coverage for this issue now. If there is still an outstanding gn issue then we should fix it.
Status: Fixed (was: Started)

Sign in to add a comment