aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorSjoerd Meijer <sjoerd.meijer@arm.com>2020-03-09 10:37:28 +0000
committerSjoerd Meijer <sjoerd.meijer@arm.com>2020-03-09 10:37:28 +0000
commitf35d112efdb33abee853aeab8a5ed4a4743e204d (patch)
tree39e1fd13c0a373bd51c72538e10a83ad104f4432 /clang/lib
parent25f2639fab1187c3aca5570f23809721cc0a8f76 (diff)
downloadllvm-f35d112efdb33abee853aeab8a5ed4a4743e204d.zip
llvm-f35d112efdb33abee853aeab8a5ed4a4743e204d.tar.gz
llvm-f35d112efdb33abee853aeab8a5ed4a4743e204d.tar.bz2
Revert "Recommit "[Driver] Default to -fno-common for all targets""
This reverts commit 2c36c23f3476baf3b9283ea387c579419a70b112. Still problems in the test-suite, which I really thought I had fixed...
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp22
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp2
2 files changed, 20 insertions, 4 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 5b85a51..99faae3 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1408,6 +1408,20 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) {
}
}
+static bool isNoCommonDefault(const llvm::Triple &Triple) {
+ switch (Triple.getArch()) {
+ default:
+ if (Triple.isOSFuchsia())
+ return true;
+ return false;
+
+ case llvm::Triple::xcore:
+ case llvm::Triple::wasm32:
+ case llvm::Triple::wasm64:
+ return true;
+ }
+}
+
static bool hasMultipleInvocations(const llvm::Triple &Triple,
const ArgList &Args) {
// Supported only on Darwin where we invoke the compiler multiple times
@@ -5678,9 +5692,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasFlag(options::OPT_Qy, options::OPT_Qn, true))
CmdArgs.push_back("-Qn");
- // -fno-common is the default, set -fcommon only when that flag is set.
- if (Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common, false))
- CmdArgs.push_back("-fcommon");
+ // -fcommon is the default unless compiling kernel code or the target says so
+ bool NoCommonDefault = KernelOrKext || isNoCommonDefault(RawTriple);
+ if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common,
+ !NoCommonDefault))
+ CmdArgs.push_back("-fno-common");
// -fsigned-bitfields is default, and clang doesn't yet support
// -funsigned-bitfields.
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 6d5a23e..9f3522a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -809,7 +809,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.RecordCommandLine =
std::string(Args.getLastArgValue(OPT_record_command_line));
Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
- Opts.NoCommon = !Args.hasArg(OPT_fcommon);
+ Opts.NoCommon = Args.hasArg(OPT_fno_common);
Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Opts.OptimizeSize = getOptimizationLevelSize(Args);