diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index a421d5697da9..3ff81d5de29a 100644 --- a/platform/linuxbsd/detect.py +++ b/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: