[cfe-dev] Error: undefined reference to '__llvm_profile_register_function' with -fprofile-instr-generate

Alexey Samsonov vonosmas at gmail.com
Wed Jul 9 18:02:53 PDT 2014


I've submitted this patch in r212665, thanks!

On Tue, Jul 8, 2014 at 10:38 AM, Justin Bogner <mail at justinbogner.com>
wrote:

> p2282 <ganesh.faq at gmail.com> writes:
> > Hi all,
> >
> > I am facing following error with "-fprofile-instr-generate".
> > Please let me know your inputs to resolve this error
>
> It looks like compiler-rt's configure + make build isn't set up build
> the profile libraries on linux. Taking a look at the FUNCTIONS.profile
> variables in make/platform/clang_linux.mk compared to those in
> clang_darwin.mk, I guess that something like the following (untested)
> patch would help.
>
>
>
> Alternatively, you can probably get this working by using cmake rather
> than configure.
>

But, yes, please use CMake instead. It's better maintained at the moment.


>
> > Thanks,
> >
> > *Error:*
> > export PATH=/home/user/llvm_install/bin:$PATH
> > export LD_LIBRARY_PATH=/home/user/llvm_install/lib
> > $ clang++ -O2 -fprofile-instr-generate hello.cpp
> > /tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_runtime_user:
> error:
> > undefined reference to '__llvm_profile_runtime'
> > clang: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> >
> > *Above error says , 'use -v'. Output of -v is as follows*
> > --snip start--
> > "/usr/local/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr
> -m
> > elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out
> > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o
> > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o
> > /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o
> > -L/usr/lib/gcc/x86_64-linux-gnu/4.8
> > -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu
> > -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
> > -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..
> -L/home/LLVM_install/bin/../lib
> > -L/lib -L/usr/lib /tmp/hello-c8552f.o
> >
> */home/LLVM_install/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.profile-x86_64.a*
> > -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
> > /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o
> > /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
> > /tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error:
> undefined
> > reference to '__llvm_profile_register_function'
> > /tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_runtime_user:
> error:
> > undefined reference to '__llvm_profile_runtime'
> > clang: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> > --snip end--
> >
> >
> > *Clang version:* clang version 3.5.0 (
> http://llvm.org/git/clang.git841710be7cbcd4c5b6d355ffa37d2739b21b2fd8) (
> http://llvm.org/git/llvm.git682e019983ba91576ecf02a0dd93edfde0d705f3)
> >
> > *OS:* Ubuntu 14.04
> >
> > *LD version:*GNU gold (GNU Binutils 2.24.51.20140522) 1.11
> >
> > *LLVM Configure options:* configure --enable-profiling --enable-optimized
> > --enable-shared --disable-debug-runtime --enable-targets=all
> > --prefix=/home/user/llvm_install
> > --with-binutils-include=/gold_linker/binutils/include
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>


-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140709/d821e700/attachment.html>


More information about the cfe-dev mailing list