@@ -143,9 +143,10 @@ def _build_rustdoc_flags(ctx, dep_info, crate_info, toolchain):
143
143
rust_lib_files = depset (transitive = [toolchain .rust_lib .files , toolchain .rustc_lib .files ])
144
144
rust_lib_paths = depset ([file .short_path for file in rust_lib_files .to_list ()]).to_list ()
145
145
rust_lib_dirs = depset ([file .rsplit ("/" , 1 )[0 ] for file in rust_lib_paths ]).to_list ()
146
+ rust_lib_dirs = ["${{pwd}}/{}" .format (lib ) for lib in rust_lib_dirs ]
146
147
147
148
# Tell Rustc where to find the standard library
148
- link_search_flags .extend (["-L ${{pwd}}/ {}" .format (lib ) for lib in rust_lib_dirs ])
149
+ link_search_flags .extend (["-L {}" .format (lib ) for lib in rust_lib_dirs ])
149
150
150
151
sysroot = find_sysroot (toolchain , short_path = True )
151
152
if sysroot :
@@ -170,8 +171,11 @@ def _build_rustdoc_flags(ctx, dep_info, crate_info, toolchain):
170
171
171
172
flags = link_search_flags + link_flags + edition_flags
172
173
174
+ # Start with the default shell env, which contains any --action_env
175
+ # settings passed in on the command line.
176
+ env = dict (ctx .configuration .default_shell_env )
177
+
173
178
# Build a set of environment variables to use for the test
174
- env = {}
175
179
toolchain_tools = []
176
180
cc_toolchain , feature_configuration = find_cc_toolchain (ctx )
177
181
cc_env = get_cc_compile_env (cc_toolchain , feature_configuration )
@@ -197,7 +201,9 @@ def _build_rustdoc_flags(ctx, dep_info, crate_info, toolchain):
197
201
if cc_toolchain .sysroot :
198
202
env ["SYSROOT" ] = cc_toolchain .sysroot
199
203
200
- env ["SYSROOT" ] = "${{pwd}}/{}" .format (sysroot )
204
+ # env["SYSROOT"] = "${{pwd}}/{}".format(sysroot)
205
+ env ["LD_LIBRARY_PATH" ] = env .get ("LD_LIBRARY_PATH" , "" ) + ":" .join (rust_lib_dirs )
206
+ env ["DYLD_LIBRARY_PATH" ] = env .get ("DYLD_LIBRARY_PATH" , "" ) + ":" .join (rust_lib_dirs )
201
207
return flags , env , toolchain_tools
202
208
203
209
rust_doc_test = rule (
0 commit comments