From 0a9fc9233e172601e26381810d093e02ef410f65 Mon Sep 17 00:00:00 2001 From: Sjoerd Meijer Date: Tue, 3 Mar 2020 09:12:43 +0000 Subject: [Driver] Default to -fno-common for all targets This makes -fno-common the default for all targets because this has performance and code-size benefits and is more language conforming for C code. Additionally, GCC10 also defaults to -fno-common and so we get consistent behaviour with GCC. With this change, C code that uses tentative definitions as definitions of a variable in multiple translation units will trigger multiple-definition linker errors. Generally, this occurs when the use of the extern keyword is neglected in the declaration of a variable in a header file. In some cases, no specific translation unit provides a definition of the variable. The previous behavior can be restored by specifying -fcommon. As GCC has switched already, we benefit from applications already being ported and existing documentation how to do this. For example: - https://gcc.gnu.org/gcc-10/porting_to.html - https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common Differential revision: https://reviews.llvm.org/D75056 --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 8638d43..e7b7e0f 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_fno_common); + Opts.NoCommon = !Args.hasArg(OPT_fcommon); Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables); Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float); Opts.OptimizeSize = getOptimizationLevelSize(Args); -- cgit v1.1