Skip to content

Commit 20bb841

Browse files
committed
fixed various mac issues
1 parent 54d631a commit 20bb841

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/backend/src/BackEnd.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,21 @@ static mlir::LogicalResult getLinkerInvocation(
340340
driver.ResourceDir =
341341
llvm::StringRef(clangResourceDir.data(), clangResourceDir.size());
342342
if (targetMac and not llvm::sys::Process::GetEnv("SDKROOT"))
343-
driver.SysRoot = "/Applications/Xcode.app/Contents/Developer/Platforms/"
344-
"MacOSX.platform/Developer/SDKs/MacOSX.sdk";
343+
{
344+
if (llvm::sys::fs::exists(
345+
"/Applications/Xcode.app/Contents/Developer/Platforms/"
346+
"MacOSX.platform/Developer/SDKs/MacOSX.sdk"))
347+
driver.SysRoot = "/Applications/Xcode.app/Contents/Developer/Platforms/"
348+
"MacOSX.platform/Developer/SDKs/MacOSX.sdk";
349+
else if (llvm::sys::fs::exists(
350+
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"))
351+
driver.SysRoot = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk";
352+
else
353+
{
354+
llvm::errs() << "could not find SDKROOT, set it with export "
355+
"SDKROOT=$(xcrun --sdk macosx --show-sdk-path)";
356+
}
357+
}
345358

346359
std::unique_ptr<clang::driver::Compilation> C(driver.BuildCompilation(args));
347360
if (!C)
@@ -465,7 +478,7 @@ static int linkLibraries(
465478
else
466479
{
467480
argSource.push_back("-undefined");
468-
argSource.push_back("suppress");
481+
argSource.push_back("dynamic_lookup");
469482
}
470483

471484
argSource.push_back("-o");

0 commit comments

Comments
 (0)