Chromium Code Reviews| Index: build/toolchain/gcc_toolchain.gni |
| diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni |
| index 9e53ef667e049ae8334475373de738342b5df3ad..91baa11b8473190d519cc501fb01378a5a5a6147 100644 |
| --- a/build/toolchain/gcc_toolchain.gni |
| +++ b/build/toolchain/gcc_toolchain.gni |
| @@ -14,6 +14,13 @@ |
| # build using this toolchain.) |
| # - toolchain_os (What "os" should be set to when invoking a build using this |
| # toolchain.) |
| +# |
| +# Optional parameters: |
| +# - libs_section_prefix |
| +# - libs_section_postfix |
| +# The contents of these strings, if specified, will be placed around |
| +# the libs section of the linker line. It allows one to inject libraries |
| +# at the beginning and end for all targets in a toolchain. |
| template("gcc_toolchain") { |
| toolchain(target_name) { |
| assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") |
| @@ -33,6 +40,19 @@ template("gcc_toolchain") { |
| ar = invoker.ar |
| ld = invoker.ld |
| + # Bring these into our scope for string interpolation with default values. |
|
awong
2014/05/12 19:23:02
I think we should experiment with default libs. W
brettw
2014/05/12 21:00:08
Sorry, but I am totally not touching this with a 1
cjhopman
2014/05/12 21:04:19
Maybe we should try to do this with the gyp build
awong
2014/05/12 21:34:23
Okay. I'll take this.
|
| + if (defined(invoker.libs_section_prefix)) { |
| + libs_section_prefix = invoker.libs_section_prefix |
| + } else { |
| + libs_section_prefix = "" |
| + } |
| + |
| + if (defined(invoker.libs_section_postfix)) { |
| + libs_section_postfix = invoker.libs_section_postfix |
| + } else { |
| + libs_section_postfix = "" |
| + } |
| + |
| # Make these apply to all tools below. |
| lib_prefix = "-l" |
| lib_dir_prefix="-L" |
| @@ -56,13 +76,13 @@ template("gcc_toolchain") { |
| description = "AR \$out" |
| } |
| tool("solink") { |
| - command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" |
| + command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive $libs_section_prefix \$libs $libs_section_postfix && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi" |
| description = "SOLINK \$lib" |
| #pool = "link_pool" |
| restat = "1" |
| } |
| tool("link") { |
| - command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs" |
| + command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group $libs_section_prefix \$libs $libs_section_postfix" |
| description = "LINK \$out" |
| #pool = "link_pool" |
| } |