teresajohnson wrote:

> > I assume this will give a duplicate symbol linker error if used 
> > inappropriately? Any chance of more subtle bugs?
> 
> As far as LTO is concerned I think it can only result in a duplicate symbol 
> error as the resulting symbols will have external strong linkage. There are 
> two non-LTO uses of `getModuleUniqueId` in the tree:
> 
> * The PowerPC AsmPrinter. It looks like this one is used to produce symbols 
> with external linkage, so the usage error would be detected at link time.
> * The ASan pass. It's unclear what would happen if used incorrectly (a 
> discarded section error I think?) but it doesn't look like we can do much 
> about it anyway because LTO isn't necessarily enabled with ASan.
Could that be addressed by only allowing this flag under LTO?

> 
> > Should there be some error detection at LTO link time? I.e. if the module 
> > flag is set on the LTO linked modules can and should we detect and error on 
> > duplicate source file names?
> 
> I don't think it is needed as the LTO-specific cases are already detectable.

Probably at least add a note to the new documentation for the option that it 
will result in linker errors if used inappropriately.

I was mostly thinking that detecting and erroring at LTO time would result in a 
clearer error (like at the start of LTO::addModule, where it is looking for 
partially split LTO units, which we do by adding the module flag to the index 
flags). E.g. I could see a case where someone adds this option to their 
makefiles, time passes and they forget about it, a new file is added that 
violates the constraints, and boom they get a linker error that they don't 
understand (and then the compiler gets an bug report).

https://github.com/llvm/llvm-project/pull/135728
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to