Closed Bug 574346 (clang-macosx) Opened 14 years ago Closed 13 years ago

[meta] Support building with Clang

Categories

(Firefox Build System :: General, defect)

All
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Nomis101, Unassigned)

References

Details

(Keywords: meta)

Apple is moving from GCC to LLVM/Clang. Therefore gcc-4.0 doesn't exist anymore in Xcode 4 and gcc-4.2 isn't actively maintained anymore ("...because we're just not fixing bugs in GCC anymore.", WWDC 2010 Session Video, Session 312, 6:22 min). So it is necessary to be able to build Mozilla applications with LLVM/Clang. 

To build with Clang you need Xcode 4, because only Xcode 4 includes clang++ (for Xcode 4 OS X 10.6.3 or higher is required). You also can get Clang from http://clang.llvm.org/get_started.html. Apple says building with Clang is faster, it gives a performance win, it has great user features and better error messages. Clang had successfully built the Boost library, and had passed almost all tests: http://blog.llvm.org/2010/05/clang-builds-boost.html

For more informations I recommend the WWDC 2010 Session Videos about LLVM:
http://developer.apple.com/videos/wwdc/2010/ (in the section "Developer Tools").

Note that LLVM-GCC is different to Clang:
GCC-4.2 -> Parser (GCC) / Code Generator (GCC)
LLVM-GCC -> Parser (GCC) / Code Generator (LLVM)
Clang -> Parser (Clang-LLVM) / Code Generator (LLVM)

Note to the C++ language feature:
"Clang strives to strictly conform to the C++ standard. That means it will reject invalid C++ code that another compiler may accept. If Clang reports errors in your code, please check the C++ Compatibility page to see whether they are C++-conformance bugs and how you can fix them."
http://clang.llvm.org/docs/UsersManual.html#cxx

Error messages from Clang are different from gcc error messages.
Because Xcode 4 isn't officially released yet, I've only tested to build with
clang version 2.0 (trunk 106670)
And I found two issues. As soon as Xcode 4 is available I will test it with Xcode 4 clang version to see if it gives me the same issues.
See http://llvm.org/bugs/show_bug.cgi?id=5511 ; I'm working on submitting the necessary patches.
Depends on: 576355
Keywords: meta
Depends on: 579686
Depends on: 583283
Depends on: 583460
Depends on: 583485
Summary: [meta] Do anything that is necessary to build with Clang on Mac OS X 10.6 → [meta] Support building with Clang on Mac
Depends on: 600900
Depends on: 600901
Depends on: 601360
Depends on: 601974
OS: Mac OS X → Windows 7
OS: Windows 7 → Mac OS X
Depends on: 623303
Depends on: 624180
Depends on: 627979
Depends on: 627981
Alias: clang
Blocks: 629459
Depends on: 629884
Depends on: 630012
Depends on: 631809
Depends on: 628378
Depends on: 628371
OS: Mac OS X → All
Hardware: x86_64 → All
Summary: [meta] Support building with Clang on Mac → [meta] Support building with Clang
(In reply to comment #1)
> Because Xcode 4 isn't officially released yet

Now it is, Apple has today releases Xcode 4 with clang++
http://developer.apple.com/xcode/
Depends on: 647580
On OS X it is possible to build firefox with clang 2.9 and on Linux with 3.0. I am closing this bug. Bug 647580 tracks building with xcode 4.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Unfortunately the Linux build with 3.0 fails:

...
var/tmp/mozilla-central/js/src/jsinterp.cpp:3467:5: error: indirect goto might cross protected scopes
    RELATIONAL_OP(<=);
    ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:3457:9: note: instantiated from:
        TRY_BRANCH_AFTER_COND(cond, 2);                                       \
        ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:3005:17: note: instantiated from:
                BRANCH(len);                                                  \
                ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:2422:9: note: instantiated from:
        DO_OP();                                                              \
        ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:2193:33: note: instantiated from:
                                JS_EXTENSION_(goto *jumpTable[op]);           \
                                ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:3467:5: note: instantiated from:
    RELATIONAL_OP(<=);
    ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:3457:9: note: instantiated from:
        TRY_BRANCH_AFTER_COND(cond, 2);                                       \
        ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:3005:17: note: instantiated from:
                BRANCH(len);                                                  \
                ^
/var/tmp/mozilla-central/js/src/jsinterp.cpp:2422:9: note: instantiated from:
        DO_OP();                                                              \
        ^
...
Depends on: 664252
(In reply to comment #5)
> Unfortunately the Linux build with 3.0 fails:

See bug 664252.
Depends on: 666135
Depends on: 672501
Depends on: 686462
Depends on: 692782
Depends on: 693323
Depends on: 695243
Depends on: 707648
Depends on: 717713
Depends on: 719575
Spurred by the multiple (I think it was 3) breakages of Clang/m-c in the past week or so, I set up a personal Jenkins builder to continuously build m-c using Clang. You can find the build information at http://jenkins.gregoryszorc.com:9000/

There are 4 build configurations. Each is running on Ubuntu 11.10 x64. I have debug and release builds going for each of LLVM 3.0 and LLVM built from the LLVM Subversion repository.

Currently, Jenkins will alert #pymake on build failures. If you want additional notifications (I can configure it to send email, etc), drop me a line on IRC and I'll hook you up.

Also, I make no guarantees for the availability of the service.
Depends on: 729425
Depends on: 731316
Depends on: 734490
Depends on: 740943
Depends on: 744543
Blocks: winclang
Depends on: 755145
No longer depends on: 755145
Depends on: 758153
Depends on: 764166
Depends on: 765381
Depends on: 774077
Depends on: 776079
Depends on: 776077
Depends on: 776085
Depends on: 778997
Depends on: 784776
Depends on: 787730
Does Firefox3.6.10 supported for building with Clang? We have build errors when building firefox3.6.10 with Clang on Mac OS X Lion.
(In reply to Yun Guo from comment #8)
> Does Firefox3.6.10 supported for building with Clang? We have build errors
> when building firefox3.6.10 with Clang on Mac OS X Lion.

I never tried (joined mozilla during the firefox4 days), but would be surprised if 3.6.10 would build with clang.
Building 3.6.10 with anything is not supported anymore, and has not been for months or years.
Depends on: 854936
Depends on: 884022
Depends on: 1167846
Product: Core → Firefox Build System
Alias: clang → clang-macosx
OS: All → Mac OS X
You need to log in before you can comment on or make changes to this bug.