|
|
Created:
5 years, 2 months ago by Mostyn Bramley-Moore Modified:
5 years, 1 month ago Reviewers:
Nico CC:
chromium-reviews, oilpan-reviews, Mads Ager (chromium), Raymond Toy, haraken, blink-reviews, blink-reviews-wtf_chromium.org, kouhei+heap_chromium.org, Mikhail Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
Descriptiondocument COMPILER(GCC) and COMPILER(MSVC) a little better
Clang pretends to be gcc 4.4 by defining __GNUC__ and some related macros,
and therefore COMPILER(GCC) evaluates to 1 there. To check for GCC
specifically, you need to check something like COMPILER(GCC) && !COMPILER(CLANG).
A similar situation happens with COMPILER(MSVC) in Clang when building for
windows (since Clang emulates MSVC there).
Committed: https://crrev.com/a5ee6277d60307ce8998670b1b4914d64816498b
Cr-Commit-Position: refs/heads/master@{#357260}
Patch Set 1 #Patch Set 2 : document COMPILER(GCC) and COMPILER(MSVC) a little better #Messages
Total messages: 24 (10 generated)
The CQ bit was checked by mostynb@opera.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1420613005/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1420613005/1
Description was changed from ========== make COMPILER(GCC) evaluate to 0 when using clang Clang pretends to be gcc 4.4 by defining __GNUC__ and some related macros. This fools WTF's COMPILER(GCC) macro, returning 1. I think it makes sense for COMPILER(GCC) to be more accurate, let's make it return 0 when using clang, and update all existing uses of COMPILER(GCC) to (COMPILER(GCC) || COMPILER(CLANG)), unless there's an earlier COMPILER(CLANG) clause in an #if or #elif block. BUG=546937 ========== to ========== make COMPILER(GCC) evaluate to 0 when using clang Clang pretends to be gcc 4.4 by defining __GNUC__ and some related macros. This fools WTF's COMPILER(GCC) macro, returning 1. I think it makes sense for COMPILER(GCC) to be more accurate, let's make it return 0 when using clang, and update all existing uses of COMPILER(GCC) to (COMPILER(GCC) || COMPILER(CLANG)), unless there's an earlier COMPILER(CLANG) clause in an #if or #elif block. BUG=546937 ==========
Description was changed from ========== make COMPILER(GCC) evaluate to 0 when using clang Clang pretends to be gcc 4.4 by defining __GNUC__ and some related macros. This fools WTF's COMPILER(GCC) macro, returning 1. I think it makes sense for COMPILER(GCC) to be more accurate, let's make it return 0 when using clang, and update all existing uses of COMPILER(GCC) to (COMPILER(GCC) || COMPILER(CLANG)), unless there's an earlier COMPILER(CLANG) clause in an #if or #elif block. BUG=546937 ========== to ========== make COMPILER(GCC) evaluate to 0 when using clang Clang pretends to be gcc 4.4 by defining __GNUC__ and some related macros. This fools WTF's COMPILER(GCC) macro, returning 1. I think it makes sense for COMPILER(GCC) to be more accurate, let's make it return 0 when using clang, and update all existing uses of COMPILER(GCC) to (COMPILER(GCC) || COMPILER(CLANG)), unless there's an earlier COMPILER(CLANG) clause in an #if or #elif block. BUG=546937 ==========
mostynb@opera.com changed reviewers: + jochen@chromium.org, thakis@chromium.org
mostynb@opera.com changed reviewers: - jochen@chromium.org
@Nico: Does this look OK to you? IMO the current setup is surprising, and this CL makes things more explicit/obvious.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2015/10/23 12:11:31, commit-bot: I haz the power wrote: > Dry run: This issue passed the CQ dry run. Not lgtm, no. This is good as is.
> Not lgtm, no. This is good as is. Don't you find it confusing? We had some downstream clang build breakage when one of my colleagues landed a patch of the form: #if COMPILER(GCC) <use some GCC-specific attributes that clang doesn't support> #endif <function definition...> It's trivial to use a different #if condition to solve the problem (COMPILER(GCC) && !COMPILER(CLANG)), but surely it would be more readable with this patch. I would not be surprised if some of the existing uses of #if COMPILER(GCC) are not needed for clang, but are used anyway. If you still disagree, would you accept a patch which documents this case in wtf/Compiler.h ?
On 2015/10/23 18:20:41, Mostyn Bramley-Moore wrote: > > Not lgtm, no. This is good as is. > > Don't you find it confusing? Yes, it's slightly confusing, but it's better than not doing it imo. It matches how the "native" macros work: clang sets __clang__ but it also sets __GNUC__ in gnu mode and _MSC_VER in clang-cl mode, and thanks to that most compiler detection macros go down the right path without much work. > > We had some downstream clang build breakage when one of my colleagues landed a > patch of the form: > #if COMPILER(GCC) > <use some GCC-specific attributes that clang doesn't support> > #endif > <function definition...> > > It's trivial to use a different #if condition to solve the problem > (COMPILER(GCC) && !COMPILER(CLANG)), but surely it would be more readable with > this patch. I would not be surprised if some of the existing uses of #if > COMPILER(GCC) are not needed for clang, but are used anyway. > > If you still disagree, would you accept a patch which documents this case in > wtf/Compiler.h ? Sure, some comment saying "true for gcc and clang in gcc mode" here and "true for msvc and clang in msvc mode" for the compiler(msvc) one seems fine
Description was changed from ========== make COMPILER(GCC) evaluate to 0 when using clang Clang pretends to be gcc 4.4 by defining __GNUC__ and some related macros. This fools WTF's COMPILER(GCC) macro, returning 1. I think it makes sense for COMPILER(GCC) to be more accurate, let's make it return 0 when using clang, and update all existing uses of COMPILER(GCC) to (COMPILER(GCC) || COMPILER(CLANG)), unless there's an earlier COMPILER(CLANG) clause in an #if or #elif block. BUG=546937 ========== to ========== document COMPILER(GCC) and COMPILER(MSVC) a little better Clang pretends to be gcc 4.4 by defining __GNUC__ and some related macros, and therefore COMPILER(GCC) evaluates to 1 there. To check for GCC specifically, you need to check something like COMPILER(GCC) && !COMPILER(CLANG). A similar situation happens with COMPILER(MSVC) in Clang when building for windows (since Clang emulates MSVC there). ==========
> > If you still disagree, would you accept a patch which documents this case in > > wtf/Compiler.h ? > > Sure, some comment saying "true for gcc and clang in gcc mode" here and "true > for msvc and clang in msvc mode" for the compiler(msvc) one seems fine Done. I'm not familiar with Clang on platforms other than linux, so I'm not sure the addition to the MSVC section is 100% accurate (but better than not mentioning it, I think).
*ping* (non-urgent)
lgtm (sorry, forgot about this)
The CQ bit was checked by mostynb@opera.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1420613005/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1420613005/20001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: win_chromium_x64_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by mostynb@opera.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1420613005/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1420613005/20001
Message was sent while issue was closed.
Committed patchset #2 (id:20001)
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/a5ee6277d60307ce8998670b1b4914d64816498b Cr-Commit-Position: refs/heads/master@{#357260} |