build/unix/build-clang.py does not work with LLVM trunk on OSX 10.9

RESOLVED INCOMPLETE

Status

Release Engineering
Platform Support
RESOLVED INCOMPLETE
3 years ago
3 months ago

People

(Reporter: decoder, Assigned: decoder)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [kanban:engops:https://mozilla.kanbanize.com/ctrl_board/6/2603] )

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
There seem to be multiple issues with build/unix/build-clang.py that prevent it from working properly with LLVM trunk on OSX 10.9. The first one makes stage1 fail immediately:

Apparently, building with MACOSX_DEPLOYMENT_TARGET=10.7 breaks the build because Clang tries to build against libc++ instead of libstdc++. Clang nowadays depends on some C++11 features which break then. The particular error I get is:

error: no template named 'enable_if' in namespace 'std'; did you mean '__gnu_cxx::__enable_if'?

By setting MACOSX_DEPLOYMENT_TARGET=10.9, the stage1 builds fine.


In stage2, it now fails with 

fatal error: 'cstddef' file not found

I've asked in the LLVM developers channel and someone pointed out, that XCode 5.1 no longer installs it's headers to /usr/lib on 10.9. On 10.8, this was still the case, which is why our build script worked and used the headers found there. Not sure yet how we would fix this problem, we can either install the headers or pass the proper -I flags for stage2.
(Assignee)

Comment 1

3 years ago
I was able to fix the second problem by adding

-I/Library/Developer/CommandLineTools/usr/lib/c++/v1/

to the extra_cxxflags variable in the python script. I am not sure though what the "proper" fix for this issue would be. We can hardcode this in the script but there is probably also a way to figure it out automatically using xcrun. I am not an XCode/Mac expert though, so I don't know how that is supposed to work.
(Assignee)

Comment 2

3 years ago
I talked to Rafael Espindola and he gave me the advice to include libcxx in the build. I made a small patch which adds the libcxx repository to projects/ and it solved the second problem (no additional includes needed then). Attaching the patch for both changes soon.
(Assignee)

Comment 3

3 years ago
Created attachment 8484237 [details] [diff] [review]
build-clang.patch

Adjustments for build-clang.py:

1. Use 10.9 as deployment target instead of 10.7 (otherwise Clang won't build on 10.9).

2. Add support for building with libcxx in-tree (otherwise Clang stage2 won't build on 10.9). If the libcxx repo is not specified in the JSON config, then it won't be used, so this should be backwards compatible for the 3.3 JSON config we have.

Tested on Linux and Mac.
Attachment #8484237 - Flags: review?(rail)
Comment on attachment 8484237 [details] [diff] [review]
build-clang.patch

Review of attachment 8484237 [details] [diff] [review]:
-----------------------------------------------------------------

Per IRC, the patch needs to be tested. Some comments below.

::: build/unix/build-clang/build-clang.py
@@ +155,5 @@
>  
> +    # Make the use of libcxx optional
> +    libcxx_repo = None
> +    if "libcxx_repo" in config:
> +        libcxx_repo = config["libcxx_repo"]

you could shortcut the 3 lines above with:
libcxx_repo = config.get("libcxx_repo")

@@ +166,5 @@
>          os.symlink("../../clang", llvm_source_dir + "/tools/clang")
>          os.symlink("../../compiler-rt",
>                     llvm_source_dir + "/projects/compiler-rt")
> +
> +        if libcxx_repo != None:

The following would be enough:
if libcxx_repo:
...
Attachment #8484237 - Flags: review?(rail)

Updated

3 years ago
Whiteboard: [kanban:engops:https://mozilla.kanbanize.com/ctrl_board/6/2603]
QA Contact: pmoore → mshal
Ehsan was wrangling this, I think he got it sorted somehow but I don't remember how. He definitely updated the clang version in use on Mac static analysis builds:
https://dxr.mozilla.org/mozilla-central/source/browser/config/tooltool-manifests/macosx64/clang.manifest
Severity: critical → normal
Component: Other → Platform Support
QA Contact: mshal → coop
I don't think this bug is useful any more.  It's probably fixed one way or another.
Status: NEW → RESOLVED
Last Resolved: 3 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.