New issue
Advanced search Search tips

Issue 857277 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 1
Type: Bug

Blocking:
issue 832811



Sign in to add a comment

ODR violation - two copies of ui::GenerateDomKeyboardLayoutMap on Windows builds

Project Member Reported by brucedaw...@chromium.org, Jun 28 2018

Issue description

While doing some test linking with use_lld=false I hit this warning:

[352 processes, 11477/36375 @ 150.2/s : 76.409s ] LIB obj/ui/events/dom_keyboard_layout.lib
dom_keyboard_layout_map_ozone.obj : warning LNK4006: "class base::flat_map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<void> > __cdecl ui::GenerateDomKeyboardLayoutMap(void)" (?GenerateDomKeyboardLayoutMap@ui@@YA?AV?$flat_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@X@2@@base@@XZ) already defined in dom_keyboard_layout_map_win.obj; second definition ignored

Investigation showed that, indeed, there are two functions called ui::GenerateDomKeyboardLayoutMap, one in ui\events\keycodes\dom\dom_keyboard_layout_map_win.cc and the other in ui\events\keycodes\dom\dom_keyboard_layout_map_ozone.cc

This is a One Definition Rule violation and it is undefined which one of these functions will be pulled in. I'm not sure what the fix is - perhaps adding an ifdef so that the ozone version doesn't get compiled on Windows?

 
It looks like the bug is that the ozone.cc source file is being compiled on Windows at all. I looked through my .ninja_log files to see how many other .obj files with ozone in the path are being generated on a Windows builds:

obj/ui/events/ozone/events_ozone_layout/no_keyboard_layout_engine.obj
obj/ui/events/ozone/events_ozone_layout/keyboard_layout_engine_manager.obj
obj/ui/events/ozone/events_ozone_layout/layout_util.obj
obj/ui/events/ozone/events_ozone_layout/stub_keyboard_layout_engine.obj
obj/ui/events/dom_keyboard_layout/dom_keyboard_layout_map_ozone.obj

I verified that *ozone.cc is not used for automatic source filtering (as done with set_sources_assignment_filter in build\config\BUILDCONFIG.gn) so dom_keyboard_layout_map_ozone.cc needs to be manually filtered out. Prototype CL is in crrev.com/c/1117865

Project Member

Comment 2 by bugdroid1@chromium.org, Jun 30 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1f2706b35e5382d6d095673ec4755d279f110f02

commit 1f2706b35e5382d6d095673ec4755d279f110f02
Author: Bruce Dawson <brucedawson@chromium.org>
Date: Sat Jun 30 00:34:23 2018

Don't compile ozone file for Windows or Mac

While testing with link.exe on Windows I hit a warning about duplicate
definitions of ui::GenerateDomKeyboardLayoutMap. This is because this
function is defined in three source files - *_win.cc, *_mac.mm, and
*_ozone.cc, and the *_ozone.cc file is always compiled. This means that
it is undefined which version the linker will select when building for
Windows and Mac. This ODR violation appeared in crrev.com/c/1093891

Bug:  857277 
Change-Id: I05e9a3216a5e9c2c0925bd83267b03e6cb9aa2f6
Reviewed-on: https://chromium-review.googlesource.com/1117865
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571720}
[modify] https://crrev.com/1f2706b35e5382d6d095673ec4755d279f110f02/ui/events/BUILD.gn

Status: Fixed (was: Assigned)
See also bug 726071 which covers ODR detection with lld.

Sign in to add a comment