浏览代码

Merge pull request #100827 from OS-of-S/fixed-mold-search

Fix Mold-search in older systems
Thaddeus Crews 8 月之前
父节点
当前提交
3994e561ea
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      platform/linuxbsd/detect.py

+ 10 - 4
platform/linuxbsd/detect.py

@@ -123,10 +123,16 @@ def configure(env: "SConsEnvironment"):
                         found_wrapper = True
                         break
                 if not found_wrapper:
-                    print_error(
-                        "Couldn't locate mold installation path. Make sure it's installed in /usr or /usr/local."
-                    )
-                    sys.exit(255)
+                    for path in os.environ["PATH"].split(os.pathsep):
+                        if os.path.isfile(path + "/ld.mold"):
+                            env.Append(LINKFLAGS=["-B" + path])
+                            found_wrapper = True
+                            break
+                    if not found_wrapper:
+                        print_error(
+                            "Couldn't locate mold installation path. Make sure it's installed in /usr, /usr/local or in PATH environment variable."
+                        )
+                        sys.exit(255)
             else:
                 env.Append(LINKFLAGS=["-fuse-ld=mold"])
         else: