|
14 | 14 |
|
15 | 15 | load(
|
16 | 16 | "//go/private:common.bzl",
|
17 |
| - "as_iterable", |
18 | 17 | "has_simple_shared_lib_extension",
|
19 | 18 | "has_versioned_shared_lib_extension",
|
20 | 19 | "hdr_exts",
|
@@ -109,7 +108,7 @@ def cgo_configure(go, srcs, cdeps, cppopts, copts, cxxopts, clinkopts):
|
109 | 108 | if CcInfo in d:
|
110 | 109 | cc_transitive_headers = d[CcInfo].compilation_context.headers
|
111 | 110 | inputs_transitive.append(cc_transitive_headers)
|
112 |
| - cc_libs = _cc_libs(d) |
| 111 | + cc_libs, cc_link_flags = _cc_libs_and_flags(d) |
113 | 112 | inputs_direct.extend(cc_libs)
|
114 | 113 | deps_direct.extend(cc_libs)
|
115 | 114 | cc_defines = d[CcInfo].compilation_context.defines.to_list()
|
@@ -146,7 +145,6 @@ def cgo_configure(go, srcs, cdeps, cppopts, copts, cxxopts, clinkopts):
|
146 | 145 | inputs_direct.append(lib)
|
147 | 146 | else:
|
148 | 147 | lib_opts.append(lib.path)
|
149 |
| - cc_link_flags = d[CcInfo].linking_context.user_link_flags |
150 | 148 | clinkopts.extend(cc_link_flags)
|
151 | 149 |
|
152 | 150 | elif hasattr(d, "objc"):
|
@@ -185,21 +183,23 @@ def cgo_configure(go, srcs, cdeps, cppopts, copts, cxxopts, clinkopts):
|
185 | 183 | clinkopts = clinkopts,
|
186 | 184 | )
|
187 | 185 |
|
188 |
| -def _cc_libs(target): |
| 186 | +def _cc_libs_and_flags(target): |
189 | 187 | # Copied from get_libs_for_static_executable in migration instructions
|
190 | 188 | # from bazelbuild/bazel#7036.
|
191 |
| - libraries_to_link = as_iterable(target[CcInfo].linking_context.libraries_to_link) |
192 | 189 | libs = []
|
193 |
| - for library_to_link in libraries_to_link: |
194 |
| - if library_to_link.static_library != None: |
195 |
| - libs.append(library_to_link.static_library) |
196 |
| - elif library_to_link.pic_static_library != None: |
197 |
| - libs.append(library_to_link.pic_static_library) |
198 |
| - elif library_to_link.interface_library != None: |
199 |
| - libs.append(library_to_link.interface_library) |
200 |
| - elif library_to_link.dynamic_library != None: |
201 |
| - libs.append(library_to_link.dynamic_library) |
202 |
| - return libs |
| 190 | + flags = [] |
| 191 | + for li in target[CcInfo].linking_context.linker_inputs.to_list(): |
| 192 | + flags.extend(li.user_link_flags) |
| 193 | + for library_to_link in li.libraries: |
| 194 | + if library_to_link.static_library != None: |
| 195 | + libs.append(library_to_link.static_library) |
| 196 | + elif library_to_link.pic_static_library != None: |
| 197 | + libs.append(library_to_link.pic_static_library) |
| 198 | + elif library_to_link.interface_library != None: |
| 199 | + libs.append(library_to_link.interface_library) |
| 200 | + elif library_to_link.dynamic_library != None: |
| 201 | + libs.append(library_to_link.dynamic_library) |
| 202 | + return libs, flags |
203 | 203 |
|
204 | 204 | _DEFAULT_PLATFORM_COPTS = select({
|
205 | 205 | "@io_bazel_rules_go//go/platform:darwin": [],
|
|
0 commit comments