[llvm] 6073f87 - sysroot.py: add support for non-darwin platforms

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 10:57:26 PST 2021


Author: Nico Weber
Date: 2021-02-17T13:57:16-05:00
New Revision: 6073f87d7f160a9306209efd390409e7fe67e6db

URL: https://github.com/llvm/llvm-project/commit/6073f87d7f160a9306209efd390409e7fe67e6db
DIFF: https://github.com/llvm/llvm-project/commit/6073f87d7f160a9306209efd390409e7fe67e6db.diff

LOG: 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

Added: 
    

Modified: 
    llvm/utils/gn/build/BUILD.gn
    llvm/utils/sysroot.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 362924a91c35..ecfd6f92d5dc 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -285,9 +285,14 @@ config("compiler_defaults") {
     }
   }
   if (sysroot != "") {
-    assert(current_os == "win", "FIXME: Make sysroot work on non-win")
-    assert(is_clang, "sysroot only works with clang-cl as host compiler")
-    cflags += [ "/winsysroot" + rebase_path(sysroot, root_build_dir) ]
+    assert(current_os != "mac" && current_os != "ios",
+           "FIXME: Make sysroot work on darwin")
+    if (current_os == "win") {
+      assert(is_clang, "sysroot only works with clang-cl as host compiler")
+      cflags += [ "/winsysroot" + rebase_path(sysroot, root_build_dir) ]
+    } else {
+      cflags += [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
+    }
   }
 
   if (use_ubsan) {

diff  --git a/llvm/utils/sysroot.py b/llvm/utils/sysroot.py
index 3acf6bc7a73c..fb832e6a19e6 100755
--- a/llvm/utils/sysroot.py
+++ b/llvm/utils/sysroot.py
@@ -35,13 +35,16 @@ def mkjunction(dst, src):
                    os.path.join(vsinstalldir, 'VC'))
         os.mkdir(os.path.join(out_dir, 'Windows Kits'))
         mkjunction(os.path.join(out_dir, 'Windows Kits', '10'), winsdk)
+    elif sys.platform == 'darwin':
+        assert False, "FIXME: Implement on darwin"
     else:
-        assert False, "FIXME: Implement on non-win"
+        os.symlink('/', out_dir)
 
     print('Done.')
+    abs_out_dir = os.path.abspath(out_dir)
     if sys.platform == 'win32':
         # CMake doesn't like backslashes in commandline args.
-        abs_out_dir = os.path.abspath(out_dir).replace(os.path.sep, '/')
+        abs_out_dir = abs_out_dir.replace(os.path.sep, '/')
         print('Pass -DLLVM_WINSYSROOT=' + abs_out_dir + ' to cmake.')
     else:
         print('Pass -DCMAKE_SYSROOT=' + abs_out_dir + ' to cmake.')


        


More information about the llvm-commits mailing list