[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-offload-amdgpu-runtime` running on `omp-vega20-0` while building `clang` at step 7 "Add check check-offload". Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/15350 Here is the relevant piece of the build log for the reference ``` Step 7 (Add check check-offload) failure: test (failure) TEST 'libomptarget :: amdgcn-amd-amdhsa :: offloading/pgo1.c' FAILED Exit Code: 1 Command Output (stdout): -- # RUN: at line 1 /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang -fopenmp-I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c -o /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a -fprofile-instr-generate -Xclang "-fprofile-instrument=clang" # executed command: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang -fopenmp -I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c -o /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a -fprofile-instr-generate -Xclang -fprofile-instrument=clang # note: command had no output on stdout or stderr # RUN: at line 3 /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp 2>&1 | /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c --check-prefix="CLANG-PGO" # executed command: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp # note: command had no output on stdout or stderr # executed command: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c --check-prefix=CLANG-PGO # .---command stderr # | /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c:32:20: error: CLANG-PGO-NEXT: expected string not found in input # | // CLANG-PGO-NEXT: [ 0 11 20 ] # |^ # | :3:28: note: scanning from here # | Counters = # |^ # | :4:1: note: possible intended match here # | [ 0 12 20 ] # | ^ # | # | Input file: # | Check file: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c # | # | -dump-input=help explains the following input dump. # | # | Input was: # | << # |1: === GPU Profile === # |2: Target: amdgcn-amd-amdhsa # |3: Counters = # | next:32'0X error: no match found # |4: [ 0 12 20 ] # | next:32'0 # | next:32'1 ?
[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/125392 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
https://github.com/brad0 updated
https://github.com/llvm/llvm-project/pull/125392
>From c4c2716546cb4203468c81947adbd7c953a052fe Mon Sep 17 00:00:00 2001
From: Brad Smith
Date: Sun, 2 Feb 2025 05:09:59 -0500
Subject: [PATCH] [PAC][Driver] Enable BTI and PAC by default on
OpenBSD/aarch64
---
clang/lib/Driver/ToolChains/Clang.cpp | 12 +---
clang/test/Driver/openbsd.c | 5 +
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9b5132c5625faa0..fce3f5e3c8c528c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1560,15 +1560,21 @@ static void handlePAuthABI(const ArgList &DriverArgs,
ArgStringList &CC1Args) {
static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs, bool isAArch64) {
+ const llvm::Triple &Triple = TC.getEffectiveTriple();
const Arg *A = isAArch64
? Args.getLastArg(options::OPT_msign_return_address_EQ,
options::OPT_mbranch_protection_EQ)
: Args.getLastArg(options::OPT_mbranch_protection_EQ);
- if (!A)
+ if (!A) {
+if (Triple.isOSOpenBSD() && isAArch64) {
+ CmdArgs.push_back("-msign-return-address=non-leaf");
+ CmdArgs.push_back("-msign-return-address-key=a_key");
+ CmdArgs.push_back("-mbranch-target-enforce");
+}
return;
+ }
const Driver &D = TC.getDriver();
- const llvm::Triple &Triple = TC.getEffectiveTriple();
if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
D.Diag(diag::warn_incompatible_branch_protection_option)
<< Triple.getArchName();
@@ -1582,7 +1588,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC,
const ArgList &Args,
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getSpelling() << Scope;
Key = "a_key";
-IndirectBranches = false;
+IndirectBranches = Triple.isOSOpenBSD() && isAArch64;
BranchProtectionPAuthLR = false;
GuardedControlStack = false;
} else {
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 672cd3adf44a691..68c114f063d04cd 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -136,3 +136,8 @@
// RUN: %clang --target=amd64-unknown-openbsd -flto -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LTO-FLAGS %s
// CHECK-LTO-FLAGS: "-plugin-opt=mcpu=x86-64"
+
+// Check 64-bit ARM for BTI and PAC flags
+// RUN: %clang --target=aarch64-unknown-openbsd -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-AARCH64-BTI-PAC %s
+// CHECK-AARCH64-BTI-PAC: "-msign-return-address=non-leaf"
"-msign-return-address-key=a_key" "-mbranch-target-enforce"
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
@@ -1582,7 +1588,10 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args, D.Diag(diag::err_drv_unsupported_option_argument) << A->getSpelling() << Scope; Key = "a_key"; -IndirectBranches = false; +if (Triple.isOSOpenBSD() && isAArch64) MaskRay wrote: IndirectBranches = Triple.isOSOpenBSD() && isAArch64 https://github.com/llvm/llvm-project/pull/125392 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/125392 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Brad Smith (brad0)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/125392.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+12-3)
- (modified) clang/test/Driver/openbsd.c (+5)
``diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9b5132c5625faa0..710086cbc0ece43 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1560,15 +1560,21 @@ static void handlePAuthABI(const ArgList &DriverArgs,
ArgStringList &CC1Args) {
static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs, bool isAArch64) {
+ const llvm::Triple &Triple = TC.getEffectiveTriple();
const Arg *A = isAArch64
? Args.getLastArg(options::OPT_msign_return_address_EQ,
options::OPT_mbranch_protection_EQ)
: Args.getLastArg(options::OPT_mbranch_protection_EQ);
- if (!A)
+ if (!A) {
+if (Triple.isOSOpenBSD() && isAArch64) {
+ CmdArgs.push_back("-msign-return-address=non-leaf");
+ CmdArgs.push_back("-msign-return-address-key=a_key");
+ CmdArgs.push_back("-mbranch-target-enforce");
+}
return;
+ }
const Driver &D = TC.getDriver();
- const llvm::Triple &Triple = TC.getEffectiveTriple();
if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
D.Diag(diag::warn_incompatible_branch_protection_option)
<< Triple.getArchName();
@@ -1582,7 +1588,10 @@ static void CollectARMPACBTIOptions(const ToolChain &TC,
const ArgList &Args,
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getSpelling() << Scope;
Key = "a_key";
-IndirectBranches = false;
+if (Triple.isOSOpenBSD() && isAArch64)
+ IndirectBranches = true;
+else
+ IndirectBranches = false;
BranchProtectionPAuthLR = false;
GuardedControlStack = false;
} else {
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 672cd3adf44a691..68c114f063d04cd 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -136,3 +136,8 @@
// RUN: %clang --target=amd64-unknown-openbsd -flto -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LTO-FLAGS %s
// CHECK-LTO-FLAGS: "-plugin-opt=mcpu=x86-64"
+
+// Check 64-bit ARM for BTI and PAC flags
+// RUN: %clang --target=aarch64-unknown-openbsd -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-AARCH64-BTI-PAC %s
+// CHECK-AARCH64-BTI-PAC: "-msign-return-address=non-leaf"
"-msign-return-address-key=a_key" "-mbranch-target-enforce"
``
https://github.com/llvm/llvm-project/pull/125392
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
llvmbot wrote:
@llvm/pr-subscribers-clang-driver
Author: Brad Smith (brad0)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/125392.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+12-3)
- (modified) clang/test/Driver/openbsd.c (+5)
``diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9b5132c5625faa..710086cbc0ece4 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1560,15 +1560,21 @@ static void handlePAuthABI(const ArgList &DriverArgs,
ArgStringList &CC1Args) {
static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs, bool isAArch64) {
+ const llvm::Triple &Triple = TC.getEffectiveTriple();
const Arg *A = isAArch64
? Args.getLastArg(options::OPT_msign_return_address_EQ,
options::OPT_mbranch_protection_EQ)
: Args.getLastArg(options::OPT_mbranch_protection_EQ);
- if (!A)
+ if (!A) {
+if (Triple.isOSOpenBSD() && isAArch64) {
+ CmdArgs.push_back("-msign-return-address=non-leaf");
+ CmdArgs.push_back("-msign-return-address-key=a_key");
+ CmdArgs.push_back("-mbranch-target-enforce");
+}
return;
+ }
const Driver &D = TC.getDriver();
- const llvm::Triple &Triple = TC.getEffectiveTriple();
if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
D.Diag(diag::warn_incompatible_branch_protection_option)
<< Triple.getArchName();
@@ -1582,7 +1588,10 @@ static void CollectARMPACBTIOptions(const ToolChain &TC,
const ArgList &Args,
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getSpelling() << Scope;
Key = "a_key";
-IndirectBranches = false;
+if (Triple.isOSOpenBSD() && isAArch64)
+ IndirectBranches = true;
+else
+ IndirectBranches = false;
BranchProtectionPAuthLR = false;
GuardedControlStack = false;
} else {
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 672cd3adf44a69..68c114f063d04c 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -136,3 +136,8 @@
// RUN: %clang --target=amd64-unknown-openbsd -flto -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LTO-FLAGS %s
// CHECK-LTO-FLAGS: "-plugin-opt=mcpu=x86-64"
+
+// Check 64-bit ARM for BTI and PAC flags
+// RUN: %clang --target=aarch64-unknown-openbsd -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-AARCH64-BTI-PAC %s
+// CHECK-AARCH64-BTI-PAC: "-msign-return-address=non-leaf"
"-msign-return-address-key=a_key" "-mbranch-target-enforce"
``
https://github.com/llvm/llvm-project/pull/125392
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PAC][Driver] Enable BTI and PAC by default on OpenBSD/aarch64 (PR #125392)
https://github.com/brad0 created
https://github.com/llvm/llvm-project/pull/125392
None
>From 2c3d81ae56975f9aa2aa8ad7476e482fd77ab355 Mon Sep 17 00:00:00 2001
From: Brad Smith
Date: Sun, 2 Feb 2025 05:09:59 -0500
Subject: [PATCH] [PAC][Driver] Enable BTI and PAC by default on
OpenBSD/aarch64
---
clang/lib/Driver/ToolChains/Clang.cpp | 15 ---
clang/test/Driver/openbsd.c | 5 +
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9b5132c5625faa..710086cbc0ece4 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1560,15 +1560,21 @@ static void handlePAuthABI(const ArgList &DriverArgs,
ArgStringList &CC1Args) {
static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs, bool isAArch64) {
+ const llvm::Triple &Triple = TC.getEffectiveTriple();
const Arg *A = isAArch64
? Args.getLastArg(options::OPT_msign_return_address_EQ,
options::OPT_mbranch_protection_EQ)
: Args.getLastArg(options::OPT_mbranch_protection_EQ);
- if (!A)
+ if (!A) {
+if (Triple.isOSOpenBSD() && isAArch64) {
+ CmdArgs.push_back("-msign-return-address=non-leaf");
+ CmdArgs.push_back("-msign-return-address-key=a_key");
+ CmdArgs.push_back("-mbranch-target-enforce");
+}
return;
+ }
const Driver &D = TC.getDriver();
- const llvm::Triple &Triple = TC.getEffectiveTriple();
if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
D.Diag(diag::warn_incompatible_branch_protection_option)
<< Triple.getArchName();
@@ -1582,7 +1588,10 @@ static void CollectARMPACBTIOptions(const ToolChain &TC,
const ArgList &Args,
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getSpelling() << Scope;
Key = "a_key";
-IndirectBranches = false;
+if (Triple.isOSOpenBSD() && isAArch64)
+ IndirectBranches = true;
+else
+ IndirectBranches = false;
BranchProtectionPAuthLR = false;
GuardedControlStack = false;
} else {
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 672cd3adf44a69..68c114f063d04c 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -136,3 +136,8 @@
// RUN: %clang --target=amd64-unknown-openbsd -flto -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LTO-FLAGS %s
// CHECK-LTO-FLAGS: "-plugin-opt=mcpu=x86-64"
+
+// Check 64-bit ARM for BTI and PAC flags
+// RUN: %clang --target=aarch64-unknown-openbsd -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-AARCH64-BTI-PAC %s
+// CHECK-AARCH64-BTI-PAC: "-msign-return-address=non-leaf"
"-msign-return-address-key=a_key" "-mbranch-target-enforce"
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
