[PATCH][Solaris] Default to -fno-cxa-finalize

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 7 09:14:05 PDT 2015


On Mon, Sep 7, 2015 at 2:28 AM, Xan López <xan at igalia.com> wrote:

> On Sat, Sep 05, 2015 at 12:25:28PM -0700, Saleem Abdulrasool wrote:
> > > Ping?
> > >
> >
> > Does this break with older Solaris releases?  How far back did this
> change
> > in Solaris?  The change itself should really be accompanied with a test.
>
> Hi,
>
> turns out I'm not really sure cxa_finalize.o was ever available on
> Solaris. The initial code for Solaris was pushed in 2012, but it was
> hardcoded to work on a pretty specific Solaris/x86 environment. One
> commit from that time is r151648, which claims -fno-cxa-atexit
> produces broken code and says they'll ship their own
> cxa_finalize.o. So it seems it was not available back then
> either. I've also seen commits in OpenSolaris from 2013 creating dummy
> cxa_finalize.o files so that clang will pass the bare minimum tests.
>

That seems less than ideal.  If there seems to be no release of Solaris
with this mythical support file, it doesn't seem too terrible to just get
rid of it.


> Now that I'm slowly pushing changes to make clang/Solaris work again
> (it was totally broken) I've found this issue again. My patch allows
> me to compile clang with clang itself, and other simple C++ programs
> compile and work. So if there was a bug here it was either fixed or I
> have not found it yet. I'd say that we should probably fix whatever
> issue there is with -fno-cxa-atexit when it shows up instead of
> working around it, or maybe *actually* bundle an implementation for
> Solaris with clang itself? But suggestions are welcome.
>

Okay, so, AIUI, no release ever contained this file, __cxa_exit isn't
provided, and that using -fno-cxa-exit does (and really should) works well
enough for non-trivial applications.


> Also, what kind of test would you have in mind for this?


That -fno-cxa-exit is included by the driver when compiling for Solaris.


>
> Xan
>
> >
> >
> > > > From 014ddb164689a3452b76f85079f213d607d07840 Mon Sep 17 00:00:00
> 2001
> > > > From: =?UTF-8?q?Xan=20L=C3=B3pez?= <xan at igalia.com>
> > > > Date: Fri, 14 Aug 2015 11:36:56 +0200
> > > > Subject: [PATCH 2/4] [Solaris] Default to -fno-cxa-finalize
> > > >
> > > > There is no __cxa_finalize symbol available on recent Solaris OS
> > > > versions, so we need this flag to make non trivial C++ programs run.
> > > >
> > > > Also stop looking for cxa_finalize.o, since it won't be there.
> > > > ---
> > > >  lib/Driver/Tools.cpp | 9 +++------
> > > >  1 file changed, 3 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
> > > > index b204961..cf01d7b 100644
> > > > --- a/lib/Driver/Tools.cpp
> > > > +++ b/lib/Driver/Tools.cpp
> > > > @@ -4506,8 +4506,9 @@ void Clang::ConstructJob(Compilation &C, const
> > > JobAction &JA,
> > > >    if (!Args.hasFlag(options::OPT_fuse_cxa_atexit,
> > > >                      options::OPT_fno_use_cxa_atexit,
> > > >                      !IsWindowsCygnus && !IsWindowsGNU &&
> > > > -                        getToolChain().getArch() !=
> > > llvm::Triple::hexagon &&
> > > > -                        getToolChain().getArch() !=
> > > llvm::Triple::xcore) ||
> > > > +                    getToolChain().getTriple().getOS() !=
> > > llvm::Triple::Solaris &&
> > > > +                    getToolChain().getArch() !=
> llvm::Triple::hexagon &&
> > > > +                    getToolChain().getArch() !=
> llvm::Triple::xcore) ||
> > > >        KernelOrKext)
> > > >      CmdArgs.push_back("-fno-use-cxa-atexit");
> > > >
> > > > @@ -6882,10 +6883,6 @@ void solaris::Linker::ConstructJob(Compilation
> > > &C, const JobAction &JA,
> > > >
> Args.MakeArgString(getToolChain().GetFilePath("values-Xa.o")));
> > > >      CmdArgs.push_back(
> > > >
> Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
> > > > -
> > > > -    if (getToolChain().getDriver().CCCIsCXX())
> > > > -      CmdArgs.push_back(
> > > > -
> > > Args.MakeArgString(getToolChain().GetFilePath("cxa_finalize.o")));
> > > >    }
> > > >
> > > >    const ToolChain::path_list &Paths = getToolChain().getFilePaths();
> > > > --
> > > > 2.4.3
> > > >
> > >
> > > > _______________________________________________
> > > > cfe-commits mailing list
> > > > cfe-commits at lists.llvm.org
> > > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> > >
> > > _______________________________________________
> > > cfe-commits mailing list
> > > cfe-commits at lists.llvm.org
> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> > >
> >
> >
> >
> > --
> > Saleem Abdulrasool
> > compnerd (at) compnerd (dot) org
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150907/0722b194/attachment.html>


More information about the cfe-commits mailing list