# Chromium fails to build with clang as well as gcc46



## nileshgr (Jun 3, 2013)

Hi,

Chromium doesn't build neither with Clang 3.1 nor GCC 4.6.3. I am on 9.1-RELEASE amd64.

This is the error with Clang:

```
cd /usr/ports/www/chromium/work/chromium-courgette-redacted-27.0.1453.93 &&  GYP_DEFINES="use_cups=1  use_system_yasm=1  use_system_libxml=1  use_system_ffmpeg=0  use_system_libusb=1  use_system_libevent=1  use_system_libvpx=0  linux_breakpad=0  linux_strip_binary=1  linux_use_tcmalloc=0  linux_use_heapchecker=0  linux_link_libspeechd=1  clang_use_chrome_plugins=0  disable_nacl=1  enable_webrtc=0  enable_openmax=1  enable_one_click_signin=1  no_gc_sections=1  os_ver=901000  prefix_dir=/usr/local  python_ver=2.7 ffmpeg_branding=Chrome proprietary_codecs=1 use_gconf=0 use_pulseaudio=0 clang=1" /usr/local/bin/python2.7  ./build/gyp_chromium chrome/chrome.gyp --depth .
Updating projects from gyp files...
===>  Building for chromium-27.0.1453.93
  ACTION Generating version information out/Release/obj/gen/chrome/common/chrome_version_info_posix.h
  CXX(host) out/Release/obj.host/protobuf_full_do_not_use/third_party/protobuf/src/google/protobuf/stubs/strutil.o
  CXX(host) out/Release/obj.host/protobuf_full_do_not_use/third_party/protobuf/src/google/protobuf/stubs/substitute.o
clang++clang++: : error: error: argument unused during compilation: '--param ssp-buffer-size=4'argument unused during compilation: '--param ssp-buffer-size=4'

gmake: *** [out/Release/obj.host/protobuf_full_do_not_use/third_party/protobuf/src/google/protobuf/stubs/strutil.o] Error 1
gmake: *** Waiting for unfinished jobs....
gmake: *** [out/Release/obj.host/protobuf_full_do_not_use/third_party/protobuf/src/google/protobuf/stubs/substitute.o] Error 1
*** [do-build] Error code 1

Stop in /usr/ports/www/chromium.
*** [build] Error code 1

Stop in /usr/ports/www/chromium.
```

and this is the error with GCC, it fails somewhere in the middle of the build:


```
CXX(target) out/Release/obj.target/net/net/http/http_auth_controller.o
  CXX(target) out/Release/obj.target/net/net/http/http_auth_filter.o
  CXX(target) out/Release/obj.target/net/net/http/http_auth_gssapi_posix.o
In file included from ./net/http/http_auth_gssapi_posix.h:8:0,
                 from net/http/http_auth_gssapi_posix.cc:5:
/usr/include/gssapi.h:3:2: error: #warning "this file includes <gssapi.h> which is deprecated, use <gssapi/gssapi.h> instead" [-Werror=cpp]
cc1plus: all warnings being treated as errors
gmake: *** [out/Release/obj.target/net/net/http/http_auth_gssapi_posix.o] Error 1
gmake: *** Waiting for unfinished jobs....
*** [do-build] Error code 1

Stop in /usr/ports/www/chromium.
*** [build] Error code 1

Stop in /usr/ports/www/chromium.
```

With regard to the Clang error, I have no idea where that ssp-buffer-size comes from.

This is my make.conf:


```
CPUTYPE?=core2
CFLAGS=-O2 -mtune=native -fno-strict-aliasing -pipe
CXXFLAGS=-O2 -mtune=native -fno-strict-aliasing -pipe
DISABLE_SIZE=YES
FETCH_CMD=aria2c
FETCH_BEFORE_ARGS=-s4 -k 1M -c
MAKE_JOBS_NUMBER=2

WITH_PKGNG=YES
WITH_ALSA=YES
WITH_CUPS=YES
WITH_GSTREAMER=YES
WITH_GTK=YES
WITH_GTK2=YES
WITH_GTKSPELL=YES
WITH_GUI=YES
WITH_ICU=YES
WITH_KDE=YES
WITH_KDE4=YES
WITH_MMX=YES
WITH_MOZILLA=YES
WITH_OPTIMIZATION=YES
WITH_OPTIMIZED_CFLAGS=YES
WITH_OPTIMIZED_FLAGS=YES
WITH_READLINE=YES
WITH_SMP=YES
WITH_SSE=YES
WITH_SSE2=YES
WITH_OPENSSL=YES
WITH_UNICODE=YES
WITHOUT_DOCS=YES
WITHOUT_EXAMPLES=YES
WITHOUT_GNOME=YES
WITHOUT_GCONF=YES
WITHOUT_GTK1=YES
WITHOUT_GNUTLS=YES
WITHOUT_IPV6=YES
WITHOUT_NLS=YES
WITHOUT_TCP_WRAPPERS=YES

.include "/usr/local/etc/ports_sites.conf"
# added by use.perl 2013-06-01 11:30:14
PERL_VERSION=5.14.2
```


----------



## cpm@ (Jun 3, 2013)

Seems that doesn't build with clang-base because doesn't recognize '--param ssp-buffer-size=4' argument which corresponds to GCC Stack-Smashing Protector (SSP) implementation. Install from ports: devel/llvm and lang/clang.



			
				nileshgr said:
			
		

> And this is the error with GCC, it fails somewhere in the middle of the build:
> 
> ```
> <snip>
> ...



Remove all these in your /etc/make.conf:

```
CFLAGS=-O2 -mtune=native -fno-strict-aliasing -pipe
CXXFLAGS=-O2 -mtune=native -fno-strict-aliasing -pipe
```

Try to build again.


----------



## nileshgr (Jun 4, 2013)

That worked, but I was getting warnings for unused option ssp-buffer-size. Also it worked with the default clang (3.1) which is there in base.

I don't know how to add directory based flags in make.conf, can you help?


----------



## cpm@ (Jun 4, 2013)

FYI when you currently set CFLAGS and/or CXXFLAGS in make.conf(5)(), some ports will break. Unless you know exactly what you're doing is better don't set up. Anyway, read  /usr/share/examples/etc/make.conf if you want go ahead.

Clang will return a lot of 'unused argument' warnings: they are harmless. Add this to /etc/make.conf if you want to hide them:

```
.if ${CC:T} == "clang"
CFLAGS+=        -Qunused-arguments
.endif
```


----------



## nileshgr (Jun 4, 2013)

cpu82 said:
			
		

> FYI when you currently set CFLAGS and/or CXXFLAGS in make.conf(5)(), some ports will break. Unless you know exactly what you're doing is better don't set up. Anyway, read  /usr/share/examples/etc/make.conf if you want go ahead.



Well, those flags were indeed taken from /usr/share/examples/etc/make.conf. 
I only added -mtune=native thing, which usually does no harm.


----------



## youngunix (Jun 10, 2013)

If you want to build it using Clang instead of GCC, it can be done using the following configurations available for chromium-27.0.1453.110_1:

```
CLANG=on: Build Chromium with Clang instead of GCC 4.6+
     CODECS=on: Compile and enable patented codecs like H.264
     DEBUG=off: Install debug symbols
     GCONF=on: GConf configuration backend support
     PULSEAUDIO=off: PulseAudio sound server support
```

All you need to do to use the above configurations is:
`cd /usr/ports/www/chromium/ && make config && make install clean`


----------

