From ef760264df6734ec7d804efc503e00b994e1229b Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 6 Oct 2024 04:22:12 +0000 Subject: [PATCH] [clang][WebAssembly] Link with profile runtime libraries if requested This patch teaches the WebAssembly toolchain to link with the profile runtime libraries if profile instrumentation is requested. With this change, the following command will work with profile rt installed: ``` $ clang -target wasm32-unknown-wasi -fprofile-instr-generate \ -lwasi-emulated-getpid -lwasi-emulated-mman -o foo.wasm foo.c ``` --- clang/lib/Driver/ToolChains/WebAssembly.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp index 9aec11e69fde1db..44a6894d30fb29b 100644 --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -163,6 +163,8 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args); } + ToolChain.addProfileRTLibs(Args, CmdArgs); + CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename());