diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6266,7 +6266,6 @@ if (!Args.hasFlag( options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit, !RawTriple.isOSAIX() && !RawTriple.isOSWindows() && - TC.getArch() != llvm::Triple::xcore && ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) || RawTriple.hasEnvironment())) || KernelOrKext) diff --git a/clang/lib/Driver/ToolChains/XCore.cpp b/clang/lib/Driver/ToolChains/XCore.cpp --- a/clang/lib/Driver/ToolChains/XCore.cpp +++ b/clang/lib/Driver/ToolChains/XCore.cpp @@ -130,6 +130,10 @@ ArgStringList &CC1Args, Action::OffloadKind) const { CC1Args.push_back("-nostdsysteminc"); + // Set `-fno-use-cxa-atexit` to default. + if (!DriverArgs.hasFlag(options::OPT_fuse_cxa_atexit, + options::OPT_fno_use_cxa_atexit, false)) + CC1Args.push_back("-fno-use-cxa-atexit"); } void XCoreToolChain::AddClangCXXStdlibIncludeArgs( diff --git a/clang/test/Driver/xcore-opts.c b/clang/test/Driver/xcore-opts.c --- a/clang/test/Driver/xcore-opts.c +++ b/clang/test/Driver/xcore-opts.c @@ -4,9 +4,8 @@ // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s // CHECK: "-mframe-pointer=none" -// CHECK: "-nostdsysteminc" +// CHECK: "-nostdsysteminc" "-fno-use-cxa-atexit" // CHECK: "-fno-signed-char" -// CHECK: "-fno-use-cxa-atexit" // CHECK-NOT: "-fcxx-exceptions" // CHECK-NOT: "-fexceptions" // CHECK-NOT: "-fcommon" @@ -30,4 +29,3 @@ // CHECK-G0: xcc" // CHECK-G0-NOT: "-g" // CHECK-G0: xcc" -