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.
Great catch. Posted https://groups.google.com/a/chromium.org/d/msg/gn-dev/ya5YnChbR7c/UYh5b0RNAAAJ .
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...
*** Bug 593668 has been marked as a duplicate of this bug. ***
With GCC 6 you'll also need -fno-delete-null-pointer-checks -flifetime-dse=1 to prevent segfaults
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.
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?
Yay, nice work! Let's do this. I can ask chromium developers to possibly help us refine that later.
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.
(In reply to zasire from comment #8) Please report this separately; I have not seen any evidence of this.
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(+)