Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM: extraneous unwinder reference with -fprofile-arcs #42579

Open
arndb mannequin opened this issue Sep 6, 2019 · 2 comments
Open

ARM: extraneous unwinder reference with -fprofile-arcs #42579

arndb mannequin opened this issue Sep 6, 2019 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category

Comments

@arndb
Copy link
Mannequin

arndb mannequin commented Sep 6, 2019

Bugzilla Link 43234
Version 8.0
OS Linux
Blocks #4440
CC @calixteman,@kbeyls,@nickdesaulniers,@zygoloid,@smithp35,@vedantk

Extended Description

I got a link error on a 32-bit ARM kernel build with CONFIG_GCOV_KERNEL and CONFIG_UNWIND_FRAME_POINTER set:

kernel/trace/trace_clock.o:(.ARM.exidx+0x0): undefined reference to __aeabi_unwind_cpp_pr0' kernel/trace/trace_clock.o:(.ARM.exidx+0x8): undefined reference to __aeabi_unwind_cpp_pr0'
kernel/trace/trace_clock.o:(.ARM.exidx+0x10): undefined reference to `__aeabi_unwind_cpp_pr0'

I created a reduced test case at https://godbolt.org/z/gBQtAP

Basically, clang inserts __llvm_gcov_writeout/__llvm_gcov_flush/__llvm_gcov_init functions into any file it compiles, even for an empty C file input. These functions contain .fnstart/.fnend statements even when building with "-fno-omit-frame-pointer -fno-unwind-tables", which then results in unresolved references to __aeabi_unwind_cpp_pr0.

@arndb
Copy link
Mannequin Author

arndb mannequin commented Sep 6, 2019

assigned to @nickdesaulniers

@vedantk
Copy link
Collaborator

vedantk commented Sep 13, 2019

It looks like the gcov pass has a few too many ways to create functions. Maybe there should just be a single helper? Like

+ static FunctionCallee                                                                                                                                                           
+ getOrInsertGCOVHelperFunc(Module *M, StringRef Name, FunctionType *FTy,                                                                                                         
+                           const GCOVOptions &Opts,                                                                                                                              
+                           AttributeList AL = AttributeList()) {                                                                                                                 
+   FunctionCallee Callee = M->getOrInsertFunction(Name, FTy, AL);                                                                                                                
+   Function *F = cast<Function>(Callee.getCallee());                                                                                                                             
+   F->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);                                                                                                                          
+   F->setLinkage(GlobalValue::InternalLinkage);                                                                                                                                  
+   F->addFnAttr(Attribute::NoInline);                                                                                                                                            
+   F->setDoesNotThrow();                                                                                                                                                         
+   if (Opts.NoRedZone)                                                                                                                                                           
+     F->addFnAttr(Attribute::NoRedZone);                                                                                                                                         
+   return Callee;                                                                                                                                                                
+ }

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@nickdesaulniers nickdesaulniers removed their assignment Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

2 participants