Commit 4e363563 authored by Sjoerd Meijer's avatar Sjoerd Meijer
Browse files

Revert "[Driver] Default to -fno-common for all targets"

This reverts commit 0a9fc923.

Going to look at the asan failures.

I find the failures in the test suite weird, because they look
like compile time test and I don't understand how that can be
failing, but will have a brief look at that too.
parent b2666ccc
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -1307,10 +1307,6 @@ Use colors in diagnostics

.. option:: -fcommon, -fno-common

Place definitions of variables with no storage class and no initializer
(tentative definitions) in a common block, instead of generating individual
zero-initialized definitions (default -fno-common).

.. option:: -fcompile-resource=<arg>, --resource <arg>, --resource=<arg>

.. option:: -fconstant-cfstrings, -fno-constant-cfstrings
+0 −7
Original line number Diff line number Diff line
@@ -84,13 +84,6 @@ future versions of Clang.
Modified Compiler Flags
-----------------------

- -fno-common has been enabled as the default for all targets.  Therefore, 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``.

New Pragmas in Clang
--------------------
+1 −2
Original line number Diff line number Diff line
@@ -848,8 +848,7 @@ def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
  Group<f_clang_Group>;
def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
  Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global variables in a common block">;
def fcommon : Flag<["-"], "fcommon">, Group<f_Group>;
def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group<f_Group>;
def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">, Group<f_clang_Group>,
   Flags<[CoreOption, CC1Option]>,
+19 −3
Original line number Diff line number Diff line
@@ -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
@@ -5661,9 +5675,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.
+1 −1
Original line number Diff line number Diff line
@@ -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);
Loading