Skip to content

Commit ca68038

Browse files
committed
Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
(With C++ exceptions, `clang++ --target=mips64{,el}-linux-gnu -fpie -pie -fuse-ld=lld` has link errors (lld does not implement some strange R_MIPS_64 .eh_frame handling in GNU ld). However, sanitizer-x86_64-linux-qemu used this to build ScudoUnitTests. Pined ScudoUnitTests to -no-pie.) Default the option introduced in D113372 to ON to match all(?) major Linux distros. This matches GCC and improves consistency with Android and linux-musl which always default to PIE. Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future. Differential Revision: https://reviews.llvm.org/D120305
1 parent bbb7212 commit ca68038

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

clang/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ set(PPC_LINUX_DEFAULT_IEEELONGDOUBLE OFF CACHE BOOL
245245
set(CLANG_SPAWN_CC1 OFF CACHE BOOL
246246
"Whether clang should use a new process for the CC1 invocation")
247247

248-
option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on Linux" OFF)
248+
option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on linux-gnu" ON)
249249

250250
# Manually handle default so we can change the meaning of a cached default.
251251
set(CLANG_ENABLE_OPAQUE_POINTERS "DEFAULT" CACHE STRING

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ Internal API Changes
288288
Build System Changes
289289
--------------------
290290

291+
* CMake ``-DCLANG_DEFAULT_PIE_ON_LINUX=ON`` is now the default. This is used by
292+
linux-gnu systems to decide whether ``-fPIE -pie`` is the default (instead of
293+
``-fno-pic -no-pie``). This matches GCC installations on many Linux distros.
294+
Note: linux-android and linux-musl always default to ``-fPIE -pie``, ignoring
295+
this variable. ``-DCLANG_DEFAULT_PIE_ON_LINUX`` may be removed in the future.
296+
291297
AST Matchers
292298
------------
293299

clang/test/Driver/hip-fpie-option.hip

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// REQUIRES: clang-driver, amdgpu-registered-target
1+
// REQUIRES: clang-driver, amdgpu-registered-target, default-pie-on-linux
22

33
// -fPIC and -fPIE only affects host relocation model.
44
// device compilation always uses PIC.
55

66
// RUN: %clang -### -target x86_64-unknown-linux-gnu \
77
// RUN: --offload-arch=gfx906 %s -nogpulib -nogpuinc \
8-
// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
8+
// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
99

1010
// RUN: %clang -### -target x86_64-unknown-linux-gnu \
1111
// RUN: -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
12-
// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
12+
// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
1313

1414
// RUN: %clang -### -target x86_64-unknown-linux-gnu \
1515
// RUN: --offload-arch=gfx906 %s -nogpulib -nogpuinc \
@@ -32,7 +32,6 @@
3232
// RUN: 2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
3333

3434
// DEV-DAG: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* "-mrelocation-model" "pic" "-pic-level" "[1|2]".* "-mframe-pointer=all"}}
35-
// HOST-STATIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* "-mrelocation-model" "static"}}
3635
// HOST-PIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* "-mrelocation-model" "pic" "-pic-level" "2"}}
3736
// HOST-PIC-NOT: "-pic-is-pie"
3837
// HOST-PIE-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"}}

lldb/test/API/functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from lldbsuite.test import decorators
33

44
decor = [decorators.skipUnlessHasCallSiteInfo,
5+
decorators.skipIf(archs=['arm'],oslist=["linux"]),
56
decorators.skipIf(dwarf_version=['<', '4']),
67
decorators.skipIf(compiler="clang", compiler_version=['<', '11.0'])]
78
lldbinline.MakeInlineTest(__file__, globals(), name="UnambiguousTailCalls_V5",

lldb/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# XFAIL: target-arm && linux-gnu
21
# REQUIRES: system-linux, lzma, xz
32

43
# We want to keep the symbol "multiplyByThree" in the .dynamic section and not

llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ write_cmake_config("Config") {
99
output = "$target_gen_dir/config.h"
1010
values = [
1111
"BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/",
12-
"CLANG_DEFAULT_PIE_ON_LINUX=",
12+
"CLANG_DEFAULT_PIE_ON_LINUX=1",
1313
"CLANG_DEFAULT_LINKER=",
1414
"CLANG_DEFAULT_STD_C=",
1515
"CLANG_DEFAULT_STD_CXX=",

utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/"
2424

2525
/* Default to -fPIE and -pie on Linux. */
26-
#define CLANG_DEFAULT_PIE_ON_LINUX 0
26+
#define CLANG_DEFAULT_PIE_ON_LINUX 1
2727

2828
/* Default linker to use. */
2929
#define CLANG_DEFAULT_LINKER ""

0 commit comments

Comments
 (0)