Skip to content

Commit 8887175

Browse files
committed
[Driver] Pass the profiling runtime hook to the linker
We need to force-load a hook symbol from the profiling runtime to convince the Linux linker to load the rest of the library. This fixes SR-2109.
1 parent 3542ea3 commit 8887175

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/Driver/ToolChains.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/ADT/StringSwitch.h"
2929
#include "llvm/Option/Arg.h"
3030
#include "llvm/Option/ArgList.h"
31+
#include "llvm/ProfileData/InstrProf.h"
3132
#include "llvm/Support/FileSystem.h"
3233
#include "llvm/Support/Path.h"
3334
#include "llvm/Support/Process.h"
@@ -1366,6 +1367,8 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
13661367
getTriple().getArchName() +
13671368
".a");
13681369
Arguments.push_back(context.Args.MakeArgString(LibProfile));
1370+
Arguments.push_back(context.Args.MakeArgString(
1371+
Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
13691372
}
13701373

13711374
// Always add the stdlib

test/Driver/profiling.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545

4646
// LINUX: clang++{{"? }}
4747
// LINUX: lib/swift/clang/lib/linux/libclang_rt.profile-x86_64.a
48-
48+
// LINUX: -u__llvm_profile_runtime

0 commit comments

Comments
 (0)