Skip to content

Commit 0852bf5

Browse files
authored
Use paths.join for sysroot_prefix (#310)
If you specify `sysroot = "/"`, this resulted in paths like `//include` which resulted in warnings like: ``` .../toolchains_llvm~~llvm~linux_llvm_17_x86_64_toolchain/module-x86_64-linux.modulemap:1249:14: warning: umbrella directory '//include' not found [-Wincomplete-umbrella] ```
1 parent d79a746 commit 0852bf5

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

toolchain/internal/configure.bzl

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_skylib//lib:paths.bzl", "paths")
1516
load(
1617
"//toolchain:aliases.bzl",
1718
_aliased_libs = "aliased_libs",
@@ -49,6 +50,12 @@ def llvm_register_toolchains():
4950
pass
5051
""")
5152

53+
def _join(path1, path2):
54+
if path1:
55+
return paths.join(path1, path2.lstrip("/"))
56+
else:
57+
return path2
58+
5259
def llvm_config_impl(rctx):
5360
_check_os_arch_keys(rctx.attr.sysroot)
5461
_check_os_arch_keys(rctx.attr.cxx_builtin_include_directories)
@@ -321,14 +328,14 @@ def _cc_toolchain_str(
321328
sysroot_prefix = "%sysroot%"
322329
if target_os == "linux":
323330
cxx_builtin_include_directories.extend([
324-
sysroot_prefix + "/include",
325-
sysroot_prefix + "/usr/include",
326-
sysroot_prefix + "/usr/local/include",
331+
_join(sysroot_prefix, "/include"),
332+
_join(sysroot_prefix, "/usr/include"),
333+
_join(sysroot_prefix, "/usr/local/include"),
327334
])
328335
elif target_os == "darwin":
329336
cxx_builtin_include_directories.extend([
330-
sysroot_prefix + "/usr/include",
331-
sysroot_prefix + "/System/Library/Frameworks",
337+
_join(sysroot_prefix, "/usr/include"),
338+
_join(sysroot_prefix, "/System/Library/Frameworks"),
332339
])
333340
else:
334341
fail("Unreachable")

0 commit comments

Comments
 (0)