Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 422829 - www-client/chromium - add support for building with sys-devel/clang
Summary: www-client/chromium - add support for building with sys-devel/clang
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Chromium Project
URL:
Whiteboard: ht-wanted
Keywords:
Depends on:
Blocks: systemwide-clang
  Show dependency tree
 
Reported: 2012-06-21 11:34 UTC by Ambroz Bizjak
Modified: 2012-12-19 00:04 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ebuild patch (chromium-ebuild-clang.patch,526 bytes, patch)
2012-06-21 11:35 UTC, Ambroz Bizjak
Details | Diff
chromium-22.0.1229.94 build log (failed) (chromium-22.0.1229.94-build.log.gz,747.69 KB, application/x-gzip)
2012-10-20 17:45 UTC, Paweł Hajdan, Jr. (RETIRED)
Details
chromium-23.0.1271.26 build log (failed) (chromium-23.0.1271.26-build.log.gz,895.51 KB, application/x-gzip)
2012-10-20 17:48 UTC, Paweł Hajdan, Jr. (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ambroz Bizjak 2012-06-21 11:34:37 UTC
Chromium can be built with clang, but the gyp build system needs to be told about that; otherwise, the build fails. See http://code.google.com/p/chromium/wiki/Clang

Reproducible: Always

Steps to Reproduce:
1. Install clang-3.1
2. Try to build chromium with CC=clang CXX=clang++
Actual Results:  
Build fails.
Comment 1 Ambroz Bizjak 2012-06-21 11:35:47 UTC
Created attachment 315915 [details, diff]
ebuild patch

This ebuild patch adds the required input to the build system.
With clang-3.1 and chromium-19.0.1084.56-r1, it builds and runs perfectly.
Comment 2 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-06-21 16:03:36 UTC
1. Thank you for reporting this and writing the patch. Some remarks:
   - you shouldn't need GYP_DEFINES
   - you can use grep -q instead of redirecting to /dev/null

2. What are the exact errors? I'd prefer to fix things upstream so that it works out-of-the-box rather than having to special-case clang in the ebuild. Please attach full build log.

3. Please work against the most recent version of Chromium, i.e. dev channel (hard masked) or 9999.
Comment 3 Ambroz Bizjak 2012-06-21 16:50:31 UTC
I don't have the exact errors; IIRC it's something in the skia library using the 'restrict' keyword. But that's how it was meant to be. The build system will assume that you're using gcc unless you tell it you're using clang, in which case it will do various things, like add preprocessor definitions, to compile properly.

I suggest you don't bother the developers about this; they'll probably just point you to the wiki page I linked. AFAIK, their build system doesn't do much detection of the environment in the first place, and I assume they'll be reluctant to add some compiler detection.

As far as my patch is concerned, I don't know exactly what is needed - GYP_DEFINES, the "-Dclang=1" argument, or both. Judging by the wiki page, probably just GYP_DEFINES (I'm not sure how the two differ).

I trust you'll be able to make any changes to my patch you deem necessary.
Comment 4 Ambroz Bizjak 2012-06-21 16:53:40 UTC
Upstream bug about not compiling with clang out of the box: http://code.google.com/p/chromium/issues/detail?id=94304
Comment 5 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-10-19 16:19:22 UTC
(In reply to comment #3)
> I don't have the exact errors; IIRC it's something in the skia library using
> the 'restrict' keyword. But that's how it was meant to be. The build system
> will assume that you're using gcc unless you tell it you're using clang, in
> which case it will do various things, like add preprocessor definitions, to
> compile properly.

I was able to build trunk successfully on Gentoo using clang (from the source tree, not ebuild). So far no errors.
Comment 6 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-10-20 17:45:45 UTC
Created attachment 327010 [details]
chromium-22.0.1229.94 build log (failed)

/var/tmp/portage/www-client/chromium-22.0.1229.94/work/chromium-22.0.1229.94/out/Release/obj/gen/nacl_bootstrap/../../../obj.target/nacl_bootstrap_lib/
native_client/src/trusted/service_runtime/linux/nacl_bootstrap.o: In function `handle_bss':
native_client/src/trusted/service_runtime/linux/nacl_bootstrap.c:(.text.handle_bss+0xce): undefined reference to `memset'
Comment 7 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-10-20 17:48:55 UTC
Created attachment 327012 [details]
chromium-23.0.1271.26 build log (failed)

/var/tmp/portage/www-client/chromium-22.0.1229.94/work/chromium-22.0.1229.94/out/Release/obj/gen/nacl_bootstrap/../../../obj.target/nacl_bootstrap_lib/
native_client/src/trusted/service_runtime/linux/nacl_bootstrap.o: In function `handle_bss':
native_client/src/trusted/service_runtime/linux/nacl_bootstrap.c:(.text.handle_bss+0xce): undefined reference to `memset'
Comment 8 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-10-20 17:52:15 UTC
This NaCl failure is known since at least June 2012, and chromium-19.0.1084.52.

Note this interesting snippet in src/native_client/src/trusted/service_runtime/linux/nacl_bootstrap.gyp:

      'conditions': [
        ['clang==1', {
          'cflags': [
            # Prevent llvm-opt from replacing my_bzero with a call
            # to memset
            '-ffreestanding',
            # But make its <limits.h> still work!
            '-U__STDC_HOSTED__', '-D__STDC_HOSTED__=1',
            # TODO(bbudge) Remove this when Clang supports -fno-pic.
            '-Qunused-arguments',
          ],
        }],
      ],
Comment 9 Ambroz Bizjak 2012-10-20 17:56:48 UTC
Then again, what's the problem with defining clang=1 in the ebuild, which is obviously how it's supposed to be done?
Comment 10 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-10-20 19:35:03 UTC
(In reply to comment #9)
> Then again, what's the problem with defining clang=1 in the ebuild, which is
> obviously how it's supposed to be done?

Ebuilds should not detect compiler version and act differently based on it. It's fragile, and makes the build more complicated. One part of portability is that you shouldn't manually "configure" the compiler, the size of various data types, etc.

Upstream fix submitted for review: https://codereview.chromium.org/11234020/

By the way, if one person from upstream says something about what he thinks is the right way, that doesn't necessarily mean it's the right way for Linux packaging.
Comment 11 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-12-19 00:04:33 UTC
This is fixed for chromium-24.x and newer. chromium-23.x is known not to work.

Please file new bugs if there are any regressions.