Skip to content

Add -mno-unaligned-access and -mbig-endian to ARM and AArch64 multilib flags #114782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

simpal01
Copy link
Contributor

@simpal01 simpal01 commented Nov 4, 2024

This adds the -mno-unaligned-access and -mbig-endian command line options to the set of flags used by the multilib selection for ARM and AArch64 targets.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Nov 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 4, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: None (simpal01)

Changes

This adds the -mno-unaligned-access and -mbig-endian command line options to the set of flags used by the multilib selection for ARM and AArch64 targets.


Full diff: https://github.com/llvm/llvm-project/pull/114782.diff

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChain.cpp (+25)
  • (modified) clang/test/Driver/print-multi-selection-flags.c (+8)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index bdf3da0c96adca..dec9af62ad79e4 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -230,6 +230,18 @@ static void getAArch64MultilibFlags(const Driver &D,
     Result.push_back(BranchProtectionArg->getAsString(Args));
   }
 
+  const Arg *StrictAlignArg =
+      Args.getLastArgNoClaim(options::OPT_mstrict_align, options::OPT_mno_unaligned_access);
+  if (StrictAlignArg) {
+    Result.push_back(StrictAlignArg->getAsString(Args));
+  }
+
+  const Arg *BigEndian =
+      Args.getLastArgNoClaim(options::OPT_mbig_endian);
+  if (BigEndian) {
+    Result.push_back(BigEndian->getAsString(Args));
+  }
+
   const Arg *ABIArg = Args.getLastArgNoClaim(options::OPT_mabi_EQ);
   if (ABIArg) {
     Result.push_back(ABIArg->getAsString(Args));
@@ -287,6 +299,19 @@ static void getARMMultilibFlags(const Driver &D,
   if (BranchProtectionArg) {
     Result.push_back(BranchProtectionArg->getAsString(Args));
   }
+
+  const Arg *StrictAlignArg =
+      Args.getLastArgNoClaim(options::OPT_mstrict_align, options::
+OPT_mno_unaligned_access);
+  if (StrictAlignArg) {
+    Result.push_back(StrictAlignArg->getAsString(Args));
+  }
+
+  const Arg *BigEndian =
+      Args.getLastArgNoClaim(options::OPT_mbig_endian);
+  if (BigEndian) {
+    Result.push_back(BigEndian->getAsString(Args));
+  }
 }
 
 static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple,
diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c
index 4bb62665ad8981..5bf6dca5096a73 100644
--- a/clang/test/Driver/print-multi-selection-flags.c
+++ b/clang/test/Driver/print-multi-selection-flags.c
@@ -68,6 +68,14 @@
 // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s
 // CHECK-BRANCH-PROTECTION: -mbranch-protection=standard
 
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s
+// CHECK-NO-UNALIGNED-ACCESS: -mno-unaligned-access
+
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s
+// CHECK-BIG-ENDIAN: -mbig-endian
+
 // RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32g | FileCheck --check-prefix=CHECK-RV32 %s
 // CHECK-RV32: --target=riscv32-unknown-none-elf
 // CHECK-RV32: -mabi=ilp32d

Copy link

github-actions bot commented Nov 4, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@pratlucas pratlucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@simpal01 simpal01 merged commit f9fecab into llvm:main Nov 7, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants