[llvm] r183830 - Fix 'gcc -flto' builds for unittest binaries (undefined reference to

David Blaikie dblaikie at gmail.com
Wed Jun 12 11:37:38 PDT 2013


On Wed, Jun 12, 2013 at 11:24 AM, Nick Lewycky <nicholas at mxc.ca> wrote:
> Patrik Hagglund wrote:
>>
>> Author: patha
>> Date: Wed Jun 12 09:15:21 2013
>> New Revision: 183830
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=183830&view=rev
>> Log:
>> Fix 'gcc -flto' builds for unittest binaries (undefined reference to
>> `typeinfo for llvm::cl::GenericOptionValue').
>>
>> Remove an "anchor" method for an abstract class. (This does not
>> increase the number of vtables.)
>>
>> Modified:
>>      llvm/trunk/include/llvm/Support/CommandLine.h
>>      llvm/trunk/lib/Support/CommandLine.cpp
>>
>> Modified: llvm/trunk/include/llvm/Support/CommandLine.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=183830&r1=183829&r2=183830&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Support/CommandLine.h (original)
>> +++ llvm/trunk/include/llvm/Support/CommandLine.h Wed Jun 12 09:15:21 2013
>> @@ -350,8 +350,6 @@ struct cat {
>>   struct GenericOptionValue {
>>     virtual ~GenericOptionValue() {}
>
>
> Any reason this (the destructor) isn't declared here ...
>
>>     virtual bool compare(const GenericOptionValue&V) const = 0;
>>
>> -private:
>> -  virtual void anchor();
>>   };
>>
>>   template<class DataType>  struct OptionValue;
>>
>> Modified: llvm/trunk/lib/Support/CommandLine.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=183830&r1=183829&r2=183830&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Support/CommandLine.cpp (original)
>> +++ llvm/trunk/lib/Support/CommandLine.cpp Wed Jun 12 09:15:21 2013
>> @@ -59,7 +59,6 @@ TEMPLATE_INSTANTIATION(class opt<char>);
>>   TEMPLATE_INSTANTIATION(class opt<bool>);
>>   } } // end namespace llvm::cl
>>
>> -void GenericOptionValue::anchor() {}
>
>
> ... and defined here?
>
> Giving the key method a definition in a single TU instead of in all TUs
> could cut down on .o size -- though this is a class with little/no
> associated code, it would still shrink debug .o sizes?

& technically it's an LLVM style requirement (the wording is fairly
firm): http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers

(though I'd be happy to see that changed or at least validated with
some numbers that show it's /actually/ important to build times)

>
> Nick
>
>
>>   void OptionValue<boolOrDefault>::anchor() {}
>>   void OptionValue<std::string>::anchor() {}
>>   void Option::anchor() {}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list