Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 587408 - www-client/chromium[gn] ignores CXX and CXXFLAGS environment variables
Summary: www-client/chromium[gn] ignores CXX and CXXFLAGS environment variables
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Chromium Project
: 593668 (view as bug list)
Depends on:
Blocks: tc-directly
  Show dependency tree
Reported: 2016-06-28 12:54 UTC by Mike Gilbert
Modified: 2016-11-19 02:09 UTC (History)
3 users (show)

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


Note You need to log in before you can comment on or make changes to this bug.
Description Mike Gilbert gentoo-dev 2016-06-28 12:54:54 UTC
Looking at a build log, I see g++ in place of x86_64-pc-linux-gnu-g++, and -march=native is missing.

I suspect the other usual build variables (like LDFLAGS) are also ignored.
Comment 1 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2016-06-29 11:02:48 UTC
Great catch. Posted .
Comment 2 Jason A. Donenfeld gentoo-dev 2016-09-12 01:13:15 UTC
I would very happily settle for something like this, which would cover many people's use case:

[[ $CXXFLAGS == *-march=native* ]] && { sed -i 's/"-march=[^"]\+"/"-march=native"/g' build/config/compiler/; sed -i "s/'-march=[^']\\+'/'-march=native'/g" build/common.gypi; }

Sure it's ugly and far from perfect, but it certainly gets me where I need to go...
Comment 3 Mike Gilbert gentoo-dev 2016-09-13 15:20:14 UTC
*** Bug 593668 has been marked as a duplicate of this bug. ***
Comment 4 Mike Lothian 2016-09-14 07:49:35 UTC
With GCC 6 you'll also need -fno-delete-null-pointer-checks -flifetime-dse=1 to prevent segfaults
Comment 5 Mike Gilbert gentoo-dev 2016-09-15 04:06:34 UTC
Looking at how toolchains work in GN, I think we could probably make this work with a custom toolchain file.

Something like this:


gcc_toolchain("amd64") {
  cc = getenv("CC")
  cxx = getenv("CXX")
  ar = getenv("AR")
  nm = getenv("NM")
  ld = cxx

  extra_cflags = getenv("CFLAGS")
  extra_cppflags = getenv("CPPFLAGS")
  extra_cxxflags = getenv("CXXFLAGS")
  extra_ldflags = getenv("LDFLAGS")

  toolchain_args = {
    current_cpu = getenv("CPU")
    current_os = "linux"

We would then tell gn to use this via the custom_toolchain arg.

I'll see if I can get something working like this.
Comment 6 Mike Gilbert gentoo-dev 2016-09-16 17:31:55 UTC
This seems to work, at least for native builds. It will probably break for cross-compiles.

phajdan.jr: Can you take a look and let me know what you think?
Comment 7 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2016-09-20 04:48:37 UTC
Yay, nice work! Let's do this.

I can ask chromium developers to possibly help us refine that later.
Comment 8 zasire 2016-09-20 09:39:56 UTC
Chromium also ignores MAKEOPTS which is pretty bad if you have a laptop with heating problems. I usually use it to force updates to one core only which solves this mostly. Especially since Chromium is quite large to compile it heats up my laptop to the point where i have to cancel it.
Comment 9 Mike Gilbert gentoo-dev 2016-09-21 02:02:41 UTC
(In reply to zasire from comment #8)

Please report this separately; I have not seen any evidence of this.
Comment 10 Mike Gilbert gentoo-dev 2016-09-21 02:03:51 UTC
commit d6ba7bef53246b8132d81b5ef0620e32b9fbcb89
Author: Mike Gilbert <>
Date:   Thu Sep 15 23:13:40 2016 -0400

    www-client/chromium: use custom toolchain for GN builds

 www-client/chromium/chromium-55.0.2859.0.ebuild |  3 +++
 www-client/chromium/files/toolchain/    | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)