[all-commits] [llvm/llvm-project] 0a9fc9: [Driver] Default to -fno-common for all targets

sjoerdmeijer via All-commits all-commits at lists.llvm.org
Tue Mar 3 01:18:16 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0a9fc9233e172601e26381810d093e02ef410f65
      https://github.com/llvm/llvm-project/commit/0a9fc9233e172601e26381810d093e02ef410f65
  Author: Sjoerd Meijer <sjoerd.meijer at arm.com>
  Date:   2020-03-03 (Tue, 03 Mar 2020)

  Changed paths:
    M clang/docs/ClangCommandLineReference.rst
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
    M clang/test/CodeGen/2009-10-20-GlobalDebug.c
    M clang/test/CodeGen/aarch64-sve.c
    M clang/test/CodeGen/address-space.c
    M clang/test/CodeGen/alias.c
    M clang/test/CodeGen/align-systemz.c
    M clang/test/CodeGen/alignment.c
    M clang/test/CodeGen/asm-label.c
    M clang/test/CodeGen/attr-weak-import.c
    M clang/test/CodeGen/attr-weakref2.c
    M clang/test/CodeGen/attributes.c
    M clang/test/CodeGen/blocks-windows.c
    M clang/test/CodeGen/bool-convert.c
    M clang/test/CodeGen/c11atomics.c
    M clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
    M clang/test/CodeGen/cfstring-windows.c
    M clang/test/CodeGen/default-address-space.c
    M clang/test/CodeGen/dllexport-1.c
    M clang/test/CodeGen/dllexport.c
    M clang/test/CodeGen/dllimport.c
    M clang/test/CodeGen/microsoft-no-common-align.c
    M clang/test/CodeGen/no-common.c
    M clang/test/CodeGen/pr25786.c
    M clang/test/CodeGen/pragma-pack-1.c
    M clang/test/CodeGen/pragma-weak.c
    M clang/test/CodeGen/private-extern-redef.c
    M clang/test/CodeGen/tentative-decls.c
    M clang/test/CodeGen/tls-model.c
    M clang/test/CodeGen/visibility.c
    M clang/test/CodeGen/vlt_to_pointer.c
    M clang/test/CodeGen/volatile-1.c
    R clang/test/CodeGen/weak-global.c
    M clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
    M clang/test/CodeGenCXX/clang-sections-tentative.c
    M clang/test/CodeGenObjC/constant-string-class.m
    M clang/test/CodeGenObjC/tentative-cfconstantstring.m
    M clang/test/CodeGenOpenCL/address-spaces.cl
    M clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
    M clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
    M clang/test/Driver/apple-kext-mkernel.c
    M clang/test/Driver/clang_f_opts.c
    M clang/test/Driver/fuchsia.c
    A clang/test/Driver/no-common.c
    M clang/test/Driver/xcore-opts.c
    M clang/test/Frontend/ast-codegen.c
    M clang/test/Headers/xmmintrin.c
    M clang/test/PCH/chain-external-defs.c
    M clang/test/PCH/external-defs.c
    M clang/test/PCH/tentative-defs.c
    M clang/test/Parser/pragma-visibility2.c

  Log Message:
  -----------
  [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




More information about the All-commits mailing list