Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 372813002: Fix solink and add a postsolink hook (use the hook for android strip) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-arm
Patch Set: Add comment for new arg Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/android/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # This template defines a toolchain for something that works like gcc 5 # This template defines a toolchain for something that works like gcc
6 # (including clang). 6 # (including clang).
7 # 7 #
8 # It requires the following variables specifying the executables to run: 8 # It requires the following variables specifying the executables to run:
9 # - cc 9 # - cc
10 # - cxx 10 # - cxx
11 # - ar 11 # - ar
12 # - ld 12 # - ld
13 # and the following which is used in the toolchain_args 13 # and the following which is used in the toolchain_args
14 # - toolchain_cpu_arch (What "cpu_arch" should be set to when invoking a 14 # - toolchain_cpu_arch (What "cpu_arch" should be set to when invoking a
15 # build using this toolchain.) 15 # build using this toolchain.)
16 # - toolchain_os (What "os" should be set to when invoking a build using this 16 # - toolchain_os (What "os" should be set to when invoking a build using this
17 # toolchain.) 17 # toolchain.)
18 # 18 #
19 # Optional parameters: 19 # Optional parameters:
20 # - libs_section_prefix 20 # - libs_section_prefix
21 # - libs_section_postfix 21 # - libs_section_postfix
22 # The contents of these strings, if specified, will be placed around 22 # The contents of these strings, if specified, will be placed around
23 # the libs section of the linker line. It allows one to inject libraries 23 # the libs section of the linker line. It allows one to inject libraries
24 # at the beginning and end for all targets in a toolchain. 24 # at the beginning and end for all targets in a toolchain.
25 # - solink_libs_section_prefix 25 # - solink_libs_section_prefix
26 # - solink_libs_section_postfix 26 # - solink_libs_section_postfix
27 # Same as libs_section_{pre,post}fix except used for solink instead of link . 27 # Same as libs_section_{pre,post}fix except used for solink instead of link .
28 # - post_solink
29 # The content of this string, if specified, will be appended to the solink
30 # command.
28 # - deps 31 # - deps
29 # Just fowarded to the toolchain definition. 32 # Just forwarded to the toolchain definition.
30 # - is_clang 33 # - is_clang
31 template("gcc_toolchain") { 34 template("gcc_toolchain") {
32 toolchain(target_name) { 35 toolchain(target_name) {
33 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") 36 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
34 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") 37 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
35 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") 38 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
36 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") 39 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")
37 assert(defined(invoker.toolchain_cpu_arch), 40 assert(defined(invoker.toolchain_cpu_arch),
38 "gcc_toolchain() must specify a \"toolchain_cpu_arch\"") 41 "gcc_toolchain() must specify a \"toolchain_cpu_arch\"")
39 assert(defined(invoker.toolchain_os), 42 assert(defined(invoker.toolchain_os),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 depfile = "\$out.d" 93 depfile = "\$out.d"
91 depsformat = "gcc" 94 depsformat = "gcc"
92 } 95 }
93 tool("alink") { 96 tool("alink") {
94 command = "rm -f \$out && $ar rcs \$out @\$rspfile" 97 command = "rm -f \$out && $ar rcs \$out @\$rspfile"
95 description = "AR \$out" 98 description = "AR \$out"
96 rspfile = "\$out.rsp" 99 rspfile = "\$out.rsp"
97 rspfile_content = "\$in" 100 rspfile_content = "\$in"
98 } 101 }
99 tool("solink") { 102 tool("solink") {
100 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldfla gs -o \$lib -Wl,-soname=\$soname @\$rspfile && { readelf -d \${lib} | grep SONAM E ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$l dflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no- whole-archive $solink_libs_section_prefix \$libs $solink_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" 103 rspfile = "\$out.rsp"
104 rspfile_content = "-Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archiv e $solink_libs_section_prefix \$libs $solink_libs_section_postfix"
105
106 # TODO(cjhopman): There needs to be a way for gn to correctly figure out
107 # the outputs of a solink command.
108
109 link_command = "$ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname $rspfi le_content"
110 toc_command = "{ readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp"
111 replace_command = "if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tm p \${lib}.TOC; fi"
112 command = "$link_command && $toc_command && $replace_command"
113
114 if (defined(invoker.postsolink)) {
115 command += " && " + invoker.postsolink
116 }
117
101 description = "SOLINK \$lib" 118 description = "SOLINK \$lib"
102 rspfile = "\$out.rsp"
103 rspfile_content = "-Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archiv e \$libs"
104 #pool = "link_pool" 119 #pool = "link_pool"
105 restat = "1" 120 restat = "1"
106 } 121 }
107 tool("link") { 122 tool("link") {
108 command = "$ld \$ldflags -o \$out -Wl,--start-group @\$rspfile \$solibs -W l,--end-group $libs_section_prefix \$libs $libs_section_postfix" 123 command = "$ld \$ldflags -o \$out -Wl,--start-group @\$rspfile \$solibs -W l,--end-group $libs_section_prefix \$libs $libs_section_postfix"
109 description = "LINK \$out" 124 description = "LINK \$out"
110 rspfile = "\$out.rsp" 125 rspfile = "\$out.rsp"
111 rspfile_content = "\$in" 126 rspfile_content = "\$in"
112 #pool = "link_pool" 127 #pool = "link_pool"
113 } 128 }
(...skipping 14 matching lines...) Expand all
128 if (defined(invoker.is_clang)) { 143 if (defined(invoker.is_clang)) {
129 is_clang = invoker.is_clang 144 is_clang = invoker.is_clang
130 } 145 }
131 } 146 }
132 147
133 if (defined(invoker.deps)) { 148 if (defined(invoker.deps)) {
134 deps = invoker.deps 149 deps = invoker.deps
135 } 150 }
136 } 151 }
137 } 152 }
OLDNEW
« no previous file with comments | « build/toolchain/android/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698