[all-commits] [llvm/llvm-project] 1042de: [Driver] Add CLANG_DEFAULT_PIE_ON_LINUX to emulate...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Dec 14 10:09:13 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1042de90589c74c6998c127d1ee1b33ff3efb8cc
      https://github.com/llvm/llvm-project/commit/1042de90589c74c6998c127d1ee1b33ff3efb8cc
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-12-14 (Tue, 14 Dec 2021)

  Changed paths:
    M clang/CMakeLists.txt
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Config/config.h.cmake
    M clang/lib/Driver/ToolChains/Linux.cpp
    M clang/test/Driver/fsanitize.c
    A clang/test/Driver/linux-default-pie.c
    M clang/test/Driver/linux-ld.c
    M clang/test/lit.cfg.py
    M clang/test/lit.site.cfg.py.in
    M llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
    M utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

  Log Message:
  -----------
  [Driver] Add CLANG_DEFAULT_PIE_ON_LINUX to emulate GCC --enable-default-pie

In 2015-05, GCC added the configure option `--enable-default-pie`. When enabled,

* in the absence of -fno-pic/-fpie/-fpic (and their upper-case variants), -fPIE is the default.
* in the absence of -no-pie/-pie/-shared/-static/-static-pie, -pie is the default.

This has been adopted by all(?) major distros.

I think default PIE is the majority in the Linux world, but
--disable-default-pie users is not that uncommon because GCC upstream hasn't
switched the default yet (https://gcc.gnu.org/PR103398).

This patch add CLANG_DEFAULT_PIE_ON_LINUX which allows distros to use default PIE.
The option is justified as its adoption can be very high among Linux distros
to make Clang default match GCC, and is likely a future-new-default, at which
point we will remove CLANG_DEFAULT_PIE_ON_LINUX.
The lit feature `default-pie-on-linux` can be handy to exclude default PIE sensitive tests.

Reviewed By: foutrelis, sylvestre.ledru, thesamesam

Differential Revision: https://reviews.llvm.org/D113372




More information about the All-commits mailing list