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

Issue 771718 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Oct 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 1
Type: Bug



Sign in to add a comment

GN flag "enable_nacl" overrides "is_clang" value

Project Member Reported by mmoroz@chromium.org, Oct 4 2017

Issue description

That doesn't sound to be correct, as "is_clang" is defined as following:


  # Set to true when compiling with the Clang compiler. Typically this is used
  # to configure warnings.

https://cs.chromium.org/chromium/src/build/config/BUILDCONFIG.gn?q=%22is_clang+%3D%22&sq=package:chromium&dr=C&l=136
 
Cc: dpranke@chromium.org brettw@chromium.org och...@chromium.org infe...@chromium.org
Summary: GN flag "enable_nacl" overrides "is_clang" value (was: GN flag "enable_nacl" re-defines "is_clang" value)
For example, if you have an assert similar the following one (https://chromium-review.googlesource.com/c/chromium/src/+/700974/2/build/config/coverage/coverage.gni):

assert(!use_clang_coverage || is_clang,
       "Clang Source-based Code Coverage requires clang.")


And do the following GN gen command:


$ gn gen out/coverage --args='use_clang_coverage=true use_libfuzzer=true'
ERROR at //build/config/coverage/coverage.gni:12:1: Assertion failed.
assert(!use_clang_coverage || is_clang,
^-----
Clang Source-based Code Coverage requires clang.
See //build/config/coverage/BUILD.gn:5:1: whence it was imported.
import("//build/config/coverage/coverage.gni")
^--------------------------------------------
See //build/config/BUILDCONFIG.gn:530:3: which caused the file to be included.
 "//build/config/coverage:default_coverage",
 ^-----------------------------------------


which kind of implies that "is_clang=false" despite that fact the you are actually building with clang.

Even if you explicitly set is_clang=true (e.g. "gn gen out/coverage --args='is_clang=true use_clang_coverage=true use_libfuzzer=true'"), the same error would happen.

It won't happen though if you add "enable_nacl=false".


At the same time, similar asserts in sanitizer.gni are not failing (https://cs.chromium.org/chromium/src/build/config/sanitizers/sanitizers.gni?q=%22is_clang+%3D%22&sq=package:chromium&dr=C&l=164):

assert(!using_sanitizer || is_clang,
       "Sanitizers (is_*san) require setting is_clang = true in 'gn args'")

assert(!is_cfi || is_clang,
       "is_cfi requires setting is_clang = true in 'gn args'")


I guess those are executed before nacl stuff, so at that point is_clang value is still true as defined in BUILDCONFIG.gn
Status: Available (was: Untriaged)
Variables can be re-evaluated in the context of every toolchain that we use. The NaCl toolchains are not-clang based, and so this assert is actually wrong; use_clang_coverage is true in every toolchain, but is_clang (which is toolchain-specific) is not.

You probably want to change the assert to restrict it to just enable coverage for (!is_nacl), or possibly (current_toolchain == target_toolchain) || (current_toolchain == host_toolchain), depending on whether you want code coverage for the host tools.
Project Member

Comment 3 by bugdroid1@chromium.org, Oct 4 2017

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

commit 74106e986dfbde1caf33410d77cbe1096926db94
Author: Max Moroz <mmoroz@chromium.org>
Date: Wed Oct 04 20:36:28 2017

Remove an assert due to corrupted "is_clang" variable + add a missing import.

TBR=brettw@chromium.org,inferno@chromium.org

Bug:  771718 ,  759794 
Change-Id: I1fc3ab8b054ce6eeee24d0c1c0599be216b2e386
Reviewed-on: https://chromium-review.googlesource.com/700974
Reviewed-by: Max Moroz <mmoroz@chromium.org>
Commit-Queue: Max Moroz <mmoroz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506502}
[modify] https://crrev.com/74106e986dfbde1caf33410d77cbe1096926db94/build/config/compiler/BUILD.gn
[modify] https://crrev.com/74106e986dfbde1caf33410d77cbe1096926db94/build/config/coverage/coverage.gni

Status: WontFix (was: Available)
The GN definition of is_clang is correct. Nacl is compiled with clang as Dirk mentioned. The bug is that clang_coverage should not be set when compiling with nacl, not that the assert is incorrect. I left a comment on the CL about this.
Thanks Dirk and Brett for the explanation!
Project Member

Comment 6 by bugdroid1@chromium.org, Oct 6 2017

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

commit 433d48700283e612dcafe76ec8b05c837a48a920
Author: Abhishek Arya <inferno@chromium.org>
Date: Fri Oct 06 20:35:04 2017

Add back clang requirement assert for use_clang_coverage flag.

R=brettw@chromium.org,mmoroz@chromium.org

Bug:  771718 ,  759794 
Change-Id: I77d5f83587777d8ed4b23cf00d8f55ae48015ce0
Reviewed-on: https://chromium-review.googlesource.com/701619
Reviewed-by: Max Moroz <mmoroz@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: Abhishek Arya <inferno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507165}
[modify] https://crrev.com/433d48700283e612dcafe76ec8b05c837a48a920/build/config/coverage/coverage.gni
[modify] https://crrev.com/433d48700283e612dcafe76ec8b05c837a48a920/build/toolchain/nacl_toolchain.gni

Sign in to add a comment