Bug 151621

Summary: Use mark pragmas only if it is supported
Product: WebKit Reporter: Csaba Osztrogonác <ossy>
Component: JavaScriptCoreAssignee: Csaba Osztrogonác <ossy>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, benjamin, commit-queue, fpizlo, ggaren, keith_miller, mark.lam, msaboff, ossy, saam
Priority: P2    
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 152248    
Attachments:
Description Flags
Patch none

Description Csaba Osztrogonác 2015-11-26 05:45:11 PST
build log:
-----------
../../Source/JavaScriptCore/b3/air/AirIteratedRegisterCoalescing.cpp:687:0: error: ignoring #pragma mark  [-Werror=unknown-pragmas]
../../Source/JavaScriptCore/b3/air/AirIteratedRegisterCoalescing.cpp:721:0: error: ignoring #pragma mark  [-Werror=unknown-pragmas]

mark pragma is an OS X only feature, we shouldn't use them unconditionally.
Comment 1 Csaba Osztrogonác 2015-11-26 06:01:26 PST
Created attachment 266182 [details]
Patch
Comment 2 Mark Lam 2015-11-26 06:45:39 PST
Comment on attachment 266182 [details]
Patch

r=me
Comment 3 Alexey Proskuryakov 2015-11-26 07:30:42 PST
What does Cocoa have to do with pragmas? Is this how we usually conditionalize these?
Comment 4 Csaba Osztrogonác 2015-11-26 08:14:37 PST
(In reply to comment #3)
> What does Cocoa have to do with pragmas? 
This pragma is for Xcode, that's why GCC 
on Linux doesn't know what to with it.

http://iosdevelopertips.com/xcode/xcode-and-pragma-mark.html

> Is this how we usually conditionalize these?
It is the first and only occurence of this pragma in platform independent code.
Comment 5 Mark Lam 2015-11-26 08:16:53 PST
(In reply to comment #3)
> What does Cocoa have to do with pragmas? Is this how we usually
> conditionalize these?

"#if PLATFORM(COCOA)" here is more like a pseudonym for "#if PLATFORM(MAC) || PLATFORM(IOS)".  The pragma appears to only be supported by Xcode, and hence maybe by Clang in general?  I would have suggested "#if COMPILER(CLANG)" except I'm not sure if Clang on linux also supports this pragma.

Ossy, can you try "#if COMPILER(CLANG)" and then building on linux with Clang?
Comment 6 Csaba Osztrogonác 2015-11-26 08:59:04 PST
(In reply to comment #5)
> (In reply to comment #3)
> > What does Cocoa have to do with pragmas? Is this how we usually
> > conditionalize these?
> 
> "#if PLATFORM(COCOA)" here is more like a pseudonym for "#if PLATFORM(MAC)
> || PLATFORM(IOS)".  The pragma appears to only be supported by Xcode, and
> hence maybe by Clang in general?  I would have suggested "#if
> COMPILER(CLANG)" except I'm not sure if Clang on linux also supports this
> pragma.
> 
> Ossy, can you try "#if COMPILER(CLANG)" and then building on linux with
> Clang?

Using COMPILER(CLANG) instead of PLATFORM(COCOA) would be very confusing.

As far as I know "#pragma mark" is useful for 
only Xcode users which is same as PLATFORM(COCOA)
( == #if PLATFORM(MAC) || PLATFORM(IOS) ).

I checked, Clang simply ignores this pragma on Linux too since an Apple
employee hacked it into Clang - https://github.com/llvm-mirror/clang/commit/2243449253475574fc6f14986ff8f7fce5d46799 .

Not to mention that pragmas are compiler directives 
originally, but Apple uses it for other purposes ...
Comment 7 WebKit Commit Bot 2015-11-27 05:02:04 PST
Comment on attachment 266182 [details]
Patch

Clearing flags on attachment: 266182

Committed r192778: <http://trac.webkit.org/changeset/192778>
Comment 8 WebKit Commit Bot 2015-11-27 05:02:09 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Alexey Proskuryakov 2015-11-27 14:03:29 PST
A less misleading way to deal with this is to use #if 0 and #endif around the pragma.

Alternatively, this style of comment is also recognized by Xcode: "// MARK: ..." The downside is that "MARK: " is also displayed in Xcode's function name menu then.