Index: lib/Driver/ToolChain.cpp =================================================================== --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -309,7 +309,13 @@ std::string ToolChain::getCompilerRTPath() const { SmallString<128> Path(getDriver().ResourceDir); - StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS(); + StringRef OSLibName; + if (Triple.isOSFreeBSD()) + OSLibName = "freebsd"; + else if (Triple.isOSBinFormatWasm()) + OSLibName = "wasm"; + else + OSLibName = getOS(); llvm::sys::path::append(Path, "lib", OSLibName); return Path.str(); } Index: lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -1025,17 +1025,10 @@ // Make use of compiler-rt if --rtlib option is used ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(Args); + printf("%d\n", TC.getTriple().getOS()); switch (RLT) { case ToolChain::RLT_CompilerRT: - switch (TC.getTriple().getOS()) { - default: - llvm_unreachable("unsupported OS"); - case llvm::Triple::Win32: - case llvm::Triple::Linux: - case llvm::Triple::Fuchsia: - CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins")); - break; - } + CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins")); break; case ToolChain::RLT_Libgcc: // Make sure libgcc is not used under MSVC environment by default Index: lib/Driver/ToolChains/WebAssembly.cpp =================================================================== --- lib/Driver/ToolChains/WebAssembly.cpp +++ lib/Driver/ToolChains/WebAssembly.cpp @@ -61,7 +61,7 @@ CmdArgs.push_back("-allow-undefined-file"); CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("wasm.syms"))); CmdArgs.push_back("-lc"); - CmdArgs.push_back("-lcompiler_rt"); + AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args); } CmdArgs.push_back("-o");