Skip to content

Commit 6073f87

Browse files
committed
sysroot.py: add support for non-darwin platforms
CMAKE_SYSROOT works fine here, and `sysroot.py make-fake` borders on trivial here, but I suppose it's still nice to have a consistent script to set these up across platforms. And these are the platforms where we can do real sysroot management one day. Differential Revision: https://reviews.llvm.org/D96882
1 parent 14bda03 commit 6073f87

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

llvm/utils/gn/build/BUILD.gn

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,14 @@ config("compiler_defaults") {
285285
}
286286
}
287287
if (sysroot != "") {
288-
assert(current_os == "win", "FIXME: Make sysroot work on non-win")
289-
assert(is_clang, "sysroot only works with clang-cl as host compiler")
290-
cflags += [ "/winsysroot" + rebase_path(sysroot, root_build_dir) ]
288+
assert(current_os != "mac" && current_os != "ios",
289+
"FIXME: Make sysroot work on darwin")
290+
if (current_os == "win") {
291+
assert(is_clang, "sysroot only works with clang-cl as host compiler")
292+
cflags += [ "/winsysroot" + rebase_path(sysroot, root_build_dir) ]
293+
} else {
294+
cflags += [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
295+
}
291296
}
292297

293298
if (use_ubsan) {

llvm/utils/sysroot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ def mkjunction(dst, src):
3535
os.path.join(vsinstalldir, 'VC'))
3636
os.mkdir(os.path.join(out_dir, 'Windows Kits'))
3737
mkjunction(os.path.join(out_dir, 'Windows Kits', '10'), winsdk)
38+
elif sys.platform == 'darwin':
39+
assert False, "FIXME: Implement on darwin"
3840
else:
39-
assert False, "FIXME: Implement on non-win"
41+
os.symlink('/', out_dir)
4042

4143
print('Done.')
44+
abs_out_dir = os.path.abspath(out_dir)
4245
if sys.platform == 'win32':
4346
# CMake doesn't like backslashes in commandline args.
44-
abs_out_dir = os.path.abspath(out_dir).replace(os.path.sep, '/')
47+
abs_out_dir = abs_out_dir.replace(os.path.sep, '/')
4548
print('Pass -DLLVM_WINSYSROOT=' + abs_out_dir + ' to cmake.')
4649
else:
4750
print('Pass -DCMAKE_SYSROOT=' + abs_out_dir + ' to cmake.')

0 commit comments

Comments
 (0)