From 9bf4394e71e00bc967ee620b51ba17ead8d23dbc Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Thu, 29 Jun 2017 17:42:24 +0000 Subject: [profile] Move __llvm_profile_filename into a separate object Users can specify the path a raw profile is written to by passing -fprofile-instr-generate=, but this functionality broke on Darwin after __llvm_profile_filename was made weak [1], resulting in profiles being written to "default.profraw" even when is specified. The situation is that instrumented programs provide a weak definition of __llvm_profile_filename, which conflicts with a weak redefinition provided by the profiling runtime. The linker appears to pick the 'winning' definition arbitrarily: on Darwin, it usually prefers the larger definition, which is probably why the instrprof-override-filename.c test has been passing. The fix is to move the runtime's definition into a separate object file within the archive. This means that the linker won't "see" the runtime's definition unless the user program has not provided one. I couldn't think of a great way to test this other than to mimic the Darwin failure: use -fprofile-instr-generate=. Testing: check-{clang,profile}, modified instrprof-override-filename.c. [1] [Profile] deprecate __llvm_profile_override_default_filename https://reviews.llvm.org/D22613 https://reviews.llvm.org/D22614 Differential Revision: https://reviews.llvm.org/D34797 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306710 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/profile/InstrProfiling.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/profile/InstrProfiling.c') diff --git a/lib/profile/InstrProfiling.c b/lib/profile/InstrProfiling.c index 6828a3d27..fe66fec50 100644 --- a/lib/profile/InstrProfiling.c +++ b/lib/profile/InstrProfiling.c @@ -19,8 +19,6 @@ COMPILER_RT_WEAK uint64_t INSTR_PROF_RAW_VERSION_VAR = INSTR_PROF_RAW_VERSION; -COMPILER_RT_WEAK char INSTR_PROF_PROFILE_NAME_VAR[1] = {0}; - COMPILER_RT_VISIBILITY uint64_t __llvm_profile_get_magic(void) { return sizeof(void *) == sizeof(uint64_t) ? (INSTR_PROF_RAW_MAGIC_64) : (INSTR_PROF_RAW_MAGIC_32); -- cgit v1.2.3