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

Xan López via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 28 10:52:17 PDT 2015


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.

(This patch sits on top of a couple of unreviewed patches that make clang actually work on Solaris, see:

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150810/292800.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150817/293971.html

It should be trivial to rebase against master if it is reviewed first though)

Xan
-------------- next part --------------
>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



More information about the cfe-commits mailing list