Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 587408

Summary: www-client/chromium[gn] ignores CXX and CXXFLAGS environment variables
Product: Gentoo Linux Reporter: Mike Gilbert <floppym>
Component: Current packagesAssignee: Chromium Project <chromium>
Status: RESOLVED FIXED    
Severity: normal CC: grzegorz.kubiak, mgorny, mike
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: https://groups.google.com/a/chromium.org/d/msg/gn-dev/ya5YnChbR7c/UYh5b0RNAAAJ
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 243502    

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 https://groups.google.com/a/chromium.org/d/msg/gn-dev/ya5YnChbR7c/UYh5b0RNAAAJ .
Comment 2 Jason A. Donenfeld archtester Gentoo Infrastructure gentoo-dev Security 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/BUILD.gn; 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:

import("//build/toolchain/gcc_toolchain.gni")

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.

https://chromium.googlesource.com/chromium/src/+/master/build/config/BUILDCONFIG.gn#144

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.

https://github.com/floppym/gentoo/commit/f34d5eb6c87d957f95abbce071f9c3c554280e53

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 <floppym@gentoo.org>
Date:   Thu Sep 15 23:13:40 2016 -0400

    www-client/chromium: use custom toolchain for GN builds
    
    Bug: https://bugs.gentoo.org/587408

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