[PATCH] D33852: Enable __declspec(selectany) on linux

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 20 09:41:44 PDT 2017


rnk added inline comments.


================
Comment at: include/clang/Basic/Attr.td:2421
 
-def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
+def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindowsAndLinux> {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
----------------
Prazek wrote:
> davide wrote:
> > rnk wrote:
> > > Prazek wrote:
> > > > rnk wrote:
> > > > > davide wrote:
> > > > > > Prazek wrote:
> > > > > > > majnemer wrote:
> > > > > > > > selectany should work on targets other than "x86", "x86_64", "arm", "thumb", etc. I think it is only necessary to require that it be a COFF or ELF target.
> > > > > > > Should we allow other OSes than Win32 and Linux?
> > > > > > I guess everything ELF should be allowed.
> > > > > Why not use weak_odr / linkonce_odr on MachO? Microsoft builds Office for Mac and I suspect they use `__declspec(selectany)`.
> > > > I think this is what would happen right now. The question is - should we warn about using declspec on macho? Beause not using comdat looks like "not supporting" it, but I am not sure about it.
> > > I'm pretty sure weak_odr / linkonce_odr with ld64 on macho are the same as having a comdat. LLVM didn't always have comdats, but it's supported inline functions for a very long time. We should support selectany there.
> > I agree with @rnk here.
> So does it actually mean that we don't have any requirements for declscpec(any)? It can run on every OS and target
I guess so. I think `__declspec` spellings are controlled by -fdeclspec-extensions, which is off by default except on Windows & PS4. If we remove this constraint, `__attribute__((selectany))` will become available everywhere. I guess that's OK.


https://reviews.llvm.org/D33852





More information about the cfe-commits mailing list