Skip to content

Commit 2e19467

Browse files
committed
[memprof] Export __memprof_default_options_str on Darwin
1 parent 62ec7b8 commit 2e19467

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,10 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
16171617
}
16181618
}
16191619

1620+
if (Sanitize.needsMemProfRt())
1621+
if (hasExportSymbolDirective(Args))
1622+
addExportedSymbol(CmdArgs, "___memprof_default_options_str");
1623+
16201624
const XRayArgs &XRay = getXRayArgs();
16211625
if (XRay.needsXRayRt()) {
16221626
AddLinkRuntimeLib(Args, CmdArgs, "xray");

clang/test/Driver/fmemprof.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@
1717

1818
// RUN: not %clangxx --target=x86_64-linux-gnu -fprofile-generate -fmemory-profile-use=foo %s -### 2>&1 | FileCheck %s --check-prefix=CONFLICTWITHPGOINSTR
1919
// CONFLICTWITHPGOINSTR: error: invalid argument '-fmemory-profile-use=foo' not allowed with '-fprofile-generate'
20+
21+
// Test that we export the __memprof_default_options_str on Darwin because it has WeakAnyLinkage
22+
// RUN: %clangxx --target=arm64-apple-ios -fmemory-profile %s -### 2>&1 | FileCheck %s -check-prefix=EXPORT-BASE --implicit-check-not=exported_symbol
23+
// RUN: %clangxx --target=x86_64-linux-gnu -fmemory-profile %s -### 2>&1 | FileCheck %s -check-prefix=EXPORT-BASE --implicit-check-not=exported_symbol
24+
// RUN: %clangxx --target=arm64-apple-ios -fmemory-profile -exported_symbols_list /dev/null %s -### 2>&1 | FileCheck %s --check-prefixes=EXPORT-BASE,EXPORT
25+
// FIXME: Darwin needs to link in the runtime, then we can use the regular CHECK prefix
26+
// EXPORT-BASE: "-cc1" {{.*}} "-fmemory-profile"
27+
// EXPORT: "-exported_symbol" "___memprof_default_options_str"

0 commit comments

Comments
 (0)