This is an archive of the discontinued LLVM Phabricator instance.

Skip -fPIE for AMDGPU and HIP toolchain
ClosedPublic

Authored by yaxunl on Sep 28 2020, 9:11 AM.

Details

Summary

AMDGPU toolchain does not support -fPIE, therefore skip it if specified by driver.

Diff Detail

Event Timeline

yaxunl created this revision.Sep 28 2020, 9:11 AM
yaxunl requested review of this revision.Sep 28 2020, 9:11 AM
tra accepted this revision.Sep 28 2020, 9:55 AM

LGTM

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

Should there be some sort of DEV-NOT: -pic-is-pie instead? This line seems to implicitly rely on -pic-is-pie` would come before -mframe-pointer and it's not at all obvious that the key is the absence of -pic-is-pie.

This revision is now accepted and ready to land.Sep 28 2020, 9:55 AM
yaxunl marked an inline comment as done.Sep 28 2020, 10:36 AM
yaxunl added inline comments.
clang/test/Driver/hip-fpie-option.hip
35

will add when commit

This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2020, 7:25 PM

I plan to default CMake CLANG_DEFAULT_PIE_ON_LINUX to on in D120305 and hip-fpie-option.hip will fail. Do you mind investigating the issue?

yaxunl added a comment.EditedFeb 22 2022, 11:42 AM

I plan to default CMake CLANG_DEFAULT_PIE_ON_LINUX to on in D120305 and hip-fpie-option.hip will fail. Do you mind investigating the issue?

You need the following change. It is due to the default PIE change for the host toolchain.

diff --git a/clang/test/Driver/hip-fpie-option.hip b/clang/test/Driver/hip-fpie-option.hip
index 2e296a099dea..d8a15ffbaa43 100644
--- a/clang/test/Driver/hip-fpie-option.hip
+++ b/clang/test/Driver/hip-fpie-option.hip
@@ -5,11 +5,11 @@

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

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

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

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