Compiling Chromium on Linux with custom compiler flags

1,322 views
Skip to first unread message

ash...@chromium.org

unread,
Dec 16, 2010, 6:00:53 PM12/16/10
to Chromium-dev, chromiu...@chromium.org
I am building Chromium for ChromiumOS and my goal is to build it with
my own set of CXXFLAGS, CFLAGS and LDFLAGS.

For other ChromiumOS packages, if I export those variables (CLFAGS,
CXXFLAGS and LDFLAGS) before doing the emerge-$BOARD, it does the
trick and the package is compiled with those flags.

Chromium, however, uses gypi files to generate the flags and appends
those at the end of the command line so my custom flags get
overridden.

The final command line for compiling .cc files looks like:

g++ <my flags here> <gypi generated flags> file.cc

An example would be this:

g++ -O1 -O3 file.cc

In this case, the O3 overrides the O1.

Can I export certain variables for the chromium ebuild or otherwise so
that the gypi flags get pre-pended to the command line instead of
being appended? That way I can override the gypi command line flags
for my experiments.

Thanks,

Adam Langley

unread,
Dec 16, 2010, 6:07:42 PM12/16/10
to ash...@chromium.org, Chromium-dev, chromiu...@chromium.org
On Thu, Dec 16, 2010 at 6:00 PM, ash...@chromium.org
<ash...@chromium.org> wrote:
> I am building Chromium for ChromiumOS and my goal is to build it with
> my own set of CXXFLAGS, CFLAGS and LDFLAGS.

Just out of interest, what are the flags that you're trying to set?


AGL

Evan Martin

unread,
Dec 16, 2010, 6:09:48 PM12/16/10
to ash...@chromium.org, Chromium-dev, chromiu...@chromium.org
We're all one family here -- why not adjust the Chrome build files directly?


To do what you wanted, take a look at the root Makefile, the line
looks like this.

cmd_cc = $(CC.$(TOOLSET)) $(CFLAGS.$(TOOLSET)) $(GYP_CFLAGS)
$(DEPFLAGS) -c -o $@ $<

CFLAGS.$(TOOLSET) comes from the environment CFLAGS, while GYP_CFLAGS
are the ones generated by gyp. So I think you want to swap the order
of those two.

But note that there is more than one line like this, and that this
file is generated, so what you really need to edit is
tools/gyp/pylib/gyp/generator/make.py. Send me the review.

> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
>    http://groups.google.com/a/chromium.org/group/chromium-dev
>

ash...@chromium.org

unread,
Dec 16, 2010, 6:12:43 PM12/16/10
to Chromium-dev


On Dec 16, 3:07 pm, Adam Langley <a...@chromium.org> wrote:
> On Thu, Dec 16, 2010 at 6:00 PM, asha...@chromium.org
>
> <asha...@chromium.org> wrote:
> > I am building Chromium for ChromiumOS and my goal is to build it with
> > my own set of CXXFLAGS, CFLAGS and LDFLAGS.
>
> Just out of interest, what are the flags that you're trying to set?

The overarching goal is to investigate any missed performance
opportunity by the compiler for ChromiumOS.

In the short-term, I want to experiment with hardfp enabled for ARM,
O1/O2/O3 options, etc.

The way I am doing it right now is to hack the .gypi files but that is
not the way it should be. :)

>
> AGL

asharif

unread,
Dec 16, 2010, 6:15:01 PM12/16/10
to Evan Martin, Chromium-dev, chromiu...@chromium.org
On Thu, Dec 16, 2010 at 3:09 PM, Evan Martin <ev...@chromium.org> wrote:
We're all one family here -- why not adjust the Chrome build files directly?


To do what you wanted, take a look at the root Makefile, the line
looks like this.

cmd_cc = $(CC.$(TOOLSET)) $(CFLAGS.$(TOOLSET)) $(GYP_CFLAGS)
$(DEPFLAGS) -c -o $@ $<

CFLAGS.$(TOOLSET) comes from the environment CFLAGS, while GYP_CFLAGS
are the ones generated by gyp.  So I think you want to swap the order
of those two.

But note that there is more than one line like this, and that this
file is generated, so what you really need to edit is
tools/gyp/pylib/gyp/generator/make.py.  Send me the review.

Thanks. Let me try that and send you a CL after testing it.

Paweł Hajdan, Jr.

unread,
Dec 17, 2010, 2:35:32 AM12/17/10
to ash...@chromium.org, Chromium-dev, chromiu...@chromium.org
On Fri, Dec 17, 2010 at 00:00, ash...@chromium.org <ash...@chromium.org> wrote:
Chromium, however, uses gypi files to generate the flags and appends
those at the end of the command line so my custom flags get
overridden.

Obviously this is the root cause. Can we fix that? I remember various bugs being reported about flags or environment not being respected by our build system. 

Trevor Bourget

unread,
Dec 17, 2010, 1:03:40 PM12/17/10
to Chromium-dev, ash...@chromium.org, chromiu...@chromium.org

> I am building Chromium for ChromiumOS and my goal is to build it with
> my own set of CXXFLAGS, CFLAGS and LDFLAGS.

The way I do this is with release_extra_cflags=-foo passed by
EXTRA_BUILD_ARGS in the chromeos-chrome ebuild.
For just the optimize level special there is a gyp setting
release_optimize=3.

-- trevor

On Thu, 16 Dec 2010 15:00:53 -0800, ash...@chromium.org
<ash...@chromium.org> wrote:


>
> For other ChromiumOS packages, if I export those variables (CLFAGS,
> CXXFLAGS and LDFLAGS) before doing the emerge-$BOARD, it does the
> trick and the package is compiled with those flags.
>
> Chromium, however, uses gypi files to generate the flags and appends
> those at the end of the command line so my custom flags get
> overridden.
>
> The final command line for compiling .cc files looks like:
>
> g++ <my flags here> <gypi generated flags> file.cc
>
> An example would be this:
>
> g++ -O1 -O3 file.cc
>
> In this case, the O3 overrides the O1.
>
> Can I export certain variables for the chromium ebuild or otherwise so
> that the gypi flags get pre-pended to the command line instead of
> being appended? That way I can override the gypi command line flags
> for my experiments.
>
> Thanks,
>


--
Using Opera's revolutionary email client: http://www.opera.com/mail/

asharif

unread,
Dec 17, 2010, 1:52:37 PM12/17/10
to Trevor Bourget, Chromium-dev, chromiu...@chromium.org
It would be nice if Chromium build respected the envvar CFLAGS.

I posted a CL here:


Note, I am not a committer.
Reply all
Reply to author
Forward
0 new messages