Index: build/toolchain/gcc_toolchain.gni |
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni |
index f38b5a3bfd50ef2fc47581e3dd9a826ecd3ddc82..c463909a73c7ca7de61d7a5bd6bf4b01f3b046d4 100644 |
--- a/build/toolchain/gcc_toolchain.gni |
+++ b/build/toolchain/gcc_toolchain.gni |
@@ -34,6 +34,15 @@ if (allow_posix_link_time_opt || is_cfi) { |
# |
# Optional parameters that control the tools: |
# |
+# - extra_cflags |
+# Extra flags to be appended when compiling C files |
+# - extra_cppflags |
hashimoto
2016/05/17 06:26:31
nit: It'd be nice to make it clear the difference
Dirk Pranke
2016/05/17 21:37:45
Will add comments.
|
+# Extra flags to be appended when compiling C or C++ files |
+# - extra_cxxflags |
+# Extra flags to be appended when compiling C or C++ files |
hashimoto
2016/05/17 06:26:31
nit: Not when compiling C?
Dirk Pranke
2016/05/17 21:37:45
Whoops. Will fix.
|
+# - extra_ldflags |
+# Extra flags to be appended when linking |
+# |
# - libs_section_prefix |
# - libs_section_postfix |
# The contents of these strings, if specified, will be placed around |
@@ -180,6 +189,30 @@ template("gcc_toolchain") { |
solink_libs_section_postfix = "" |
} |
+ if (defined(invoker.extra_cflags) && invoker.extra_cflags != "") { |
+ extra_cflags = " " + invoker.extra_cflags |
+ } else { |
+ extra_cflags = "" |
+ } |
+ |
+ if (defined(invoker.extra_cppflags) && invoker.extra_cppflags != "") { |
+ extra_cppflags = " " + invoker.extra_cppflags |
+ } else { |
+ extra_cppflags = "" |
+ } |
+ |
+ if (defined(invoker.extra_cxxflags) && invoker.extra_cxxflags != "") { |
+ extra_cxxflags = " " + invoker.extra_cxxflags |
+ } else { |
+ extra_cxxflags = "" |
+ } |
+ |
+ if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") { |
+ extra_ldflags = " " + invoker.extra_ldflags |
+ } else { |
+ extra_ldflags = "" |
+ } |
+ |
# These library switches can apply to all tools below. |
lib_switch = "-l" |
lib_dir_switch = "-L" |
@@ -189,7 +222,7 @@ template("gcc_toolchain") { |
tool("cc") { |
depfile = "{{output}}.d" |
- command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
+ command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{output}}" |
depsformat = "gcc" |
description = "CC {{output}}" |
outputs = [ |
@@ -199,7 +232,7 @@ template("gcc_toolchain") { |
tool("cxx") { |
depfile = "{{output}}.d" |
- command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" |
+ command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} -o {{output}}" |
depsformat = "gcc" |
description = "CXX {{output}}" |
outputs = [ |
@@ -257,7 +290,7 @@ template("gcc_toolchain") { |
# .TOC file, overwrite it, otherwise, don't change it. |
tocfile = sofile + ".TOC" |
- link_command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
+ link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
assert(defined(readelf), "to solink you must have a readelf") |
assert(defined(nm), "to solink you must have an nm") |
@@ -317,7 +350,7 @@ template("gcc_toolchain") { |
unstripped_sofile = sofile |
} |
- command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
+ command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" |
if (defined(invoker.strip)) { |
strip_command = "${invoker.strip} --strip-unneeded -o \"$sofile\" \"$unstripped_sofile\"" |
@@ -368,7 +401,7 @@ template("gcc_toolchain") { |
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" |
} |
- command = "$ld {{ldflags}} -o \"$unstripped_outfile\" -Wl,--start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" |
+ command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" -Wl,--start-group @\"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" |
if (defined(invoker.strip)) { |
link_wrapper = |
rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir) |
@@ -428,6 +461,9 @@ template("gcc_toolchain") { |
if (defined(invoker.use_gold)) { |
use_gold = invoker.use_gold |
} |
+ if (defined(invoker.use_sysroot)) { |
+ use_sysroot = invoker.use_sysroot |
hashimoto
2016/05/17 06:26:31
Sorry, I'm not familiar enough with GN to understa
Dirk Pranke
2016/05/17 21:37:45
Yes, exactly.
See https://chromium.googlesource.
|
+ } |
if (defined(invoker.clear_sanitizers) && invoker.clear_sanitizers) { |
is_asan = false |