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

Issue 611894 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS , Mac
Pri: 2
Type: Bug



Sign in to add a comment

source_sets, component build, and ObjC classes do not play nice

Project Member Reported by rsesek@chromium.org, May 13 2016

Issue description

When working on the component build, I came upon a problem with the way source_sets interact with ObjC classes. Example, here: https://codereview.chromium.org/1961473003/diff/40001/media/base/mac/BUILD.gn

Since source_sets do not form a linking boundary, if multiple targets depend on the same source_set, you can end up with the same class being declared in two modules. This happens in the component build, and the ObjC runtime warns about it, since it can cause issues:

objc[82840]: Class CrZombie is implemented in both /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/./libsessions.dylib and /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/libchrome_dll.dylib. One of the two will be used. Which one is undefined.
objc[82840]: Class CrFatZombie is implemented in both /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/./libsessions.dylib and /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/libchrome_dll.dylib. One of the two will be used. Which one is undefined.

It should be easy enough to fix these one-off, but it seems like an issue made more frequent by source_sets, compared with GYP.
 

Comment 1 by thakis@chromium.org, May 13 2016

Blocking: 431177
I think this is the same issue you'd have with any other kind of object file that is included into multiple shared libraries. The correct answer is, don't do that.

Though perhaps GN should be smart enough to warn about this ...
Cc: sdefresne@chromium.org justincohen@chromium.org
Owner: rsesek@chromium.org
Status: Assigned (was: Untriaged)
rsesek@, I think this one is yours.
Project Member

Comment 5 by bugdroid1@chromium.org, Jun 15 2016

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

commit 73d41be15a231987117bd4e932219de569f37a9c
Author: rsesek <rsesek@chromium.org>
Date: Wed Jun 15 16:33:55 2016

[Mac/GN] Make //components/crash/core/common a static_library.

On Mac, if it is a source_set, error messages like this will be printed, since
the .o file ends up in multiple targets:

objc[56710]: Class CrZombie is implemented in both /Volumes/Build/src/out/shared/./libsessions.dylib and
    /Volumes/Build/src/out/shared/libchrome_dll.dylib. One of the two will be used.
    Which one is undefined.

BUG= 611894 
R=mark@chromium.org

Review-Url: https://codereview.chromium.org/2069543006
Cr-Commit-Position: refs/heads/master@{#399922}

[modify] https://crrev.com/73d41be15a231987117bd4e932219de569f37a9c/components/crash/core/common/BUILD.gn

Comment 6 by rsesek@chromium.org, Jun 20 2016

objc[19048]: Class MockCrApp is implemented in both /Volumes/Build/src/out/shared/libtest_runner.dylib and /Volumes/Build/src/out/shared/Content Shell.app/Contents/Frameworks/Content Shell Framework.framework/Content Shell Framework. One of the two will be used. Which one is undefined.
objc[19048]: Class CocoaTestHelperWindow is implemented in both /Volumes/Build/src/out/shared/libtest_runner.dylib and /Volumes/Build/src/out/shared/Content Shell.app/Contents/Frameworks/Content Shell Framework.framework/Content Shell Framework. One of the two will be used. Which one is undefined.

Blocking: 621679
Is there actually anything to do here in GN itself? Or is this more an issue that we have badly defined targets in some cases?

Does fixing this need to block anything?
Labels: -Pri-3 M-53 Pri-2
Blocking: -621679
Labels: -M-53
Blocking: -431177
As suggested by laforge@ and a conversation w/ the monorail folks, I'm going to try tracking GN-Migration related issues by *just* using the Proj-GN-Migration label, and not using blocking/rollup bugs, so that we can use blocking for just tasks that truly need to be completed before other tasks can make progress.
Cc: shrike@chromium.org
Project Member

Comment 12 by bugdroid1@chromium.org, Jul 13 2016

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

commit d295e88072c54f74421d8d9ba3dff50d6d5c9a0d
Author: sdy <sdy@chromium.org>
Date: Wed Jul 13 23:53:33 2016

Componentize zombies to silence ObjC runtime errors in component builds

With //components/crash/core/common as a static library, its classes can
end up in multiple components and frustrate the ObjC runtime:

    objc[82840]: Class CrZombie is implemented in both /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/./libsessions.dylib and /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/libchrome_dll.dylib. One of the two will be used. Which one is undefined.
    objc[82840]: Class CrFatZombie is implemented in both /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/./libsessions.dylib and /b/swarm_slave/work/isolated/runpsh5q4/out/Debug/libchrome_dll.dylib. One of the two will be used. Which one is undefined.

Making the implementation its own component stops this.

(rsesek@chromium.org did all of the thinking on this — my main
contribution was getting tired enough of the warnings to grab him.)

BUG= 611894 
TEST=Build Chromium for Mac with gn and `is_component_build = true`, run it from a terminal, and look for warnings like the above.

Review-Url: https://codereview.chromium.org/2148803003
Cr-Commit-Position: refs/heads/master@{#405351}

[modify] https://crrev.com/d295e88072c54f74421d8d9ba3dff50d6d5c9a0d/components/crash/core/common/BUILD.gn
[add] https://crrev.com/d295e88072c54f74421d8d9ba3dff50d6d5c9a0d/components/crash/core/common/crash_export.h
[modify] https://crrev.com/d295e88072c54f74421d8d9ba3dff50d6d5c9a0d/components/crash/core/common/objc_zombie.h

Labels: -Proj-GN-Migration
Is this still an issue?
Status: Fixed (was: Assigned)
I think it's mostly resolved.

Sign in to add a comment