Skip to content
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

[flang] Expose -m64 option #132409

Merged
merged 1 commit into from
Mar 28, 2025
Merged

Conversation

JDPailleux
Copy link
Contributor

Exposes -m32 and -m64 options for Flang.
These options can be used to build libraries or tools (e.g. OpenBlas).

@llvmbot llvmbot added clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category labels Mar 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 21, 2025

@llvm/pr-subscribers-clang

Author: Jean-Didier PAILLEUX (JDPailleux)

Changes

Exposes -m32 and -m64 options for Flang.
These options can be used to build libraries or tools (e.g. OpenBlas).


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

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+2-2)
  • (added) flang/test/Driver/driver-options.f90 (+6)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 66ae8f1c7f064..ddeb94e7b929f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4671,14 +4671,14 @@ def EB : Flag<["-"], "EB">, Alias<mbig_endian>;
 def m16 : Flag<["-"], "m16">, Group<m_Group>, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption]>;
 def m32 : Flag<["-"], "m32">, Group<m_Group>, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
 def maix32 : Flag<["-"], "maix32">, Group<m_Group>, Flags<[NoXarchOption]>;
 def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, Group<m_Group>,
   Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Enable hexagon-qdsp6 backward compatibility">,
   MarshallingInfoFlag<LangOpts<"HexagonQdsp6Compat">>;
 def m64 : Flag<["-"], "m64">, Group<m_Group>, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
 def maix64 : Flag<["-"], "maix64">, Group<m_Group>, Flags<[NoXarchOption]>;
 def mx32 : Flag<["-"], "mx32">, Group<m_Group>, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption]>;
diff --git a/flang/test/Driver/driver-options.f90 b/flang/test/Driver/driver-options.f90
new file mode 100644
index 0000000000000..db7d5ba84d49e
--- /dev/null
+++ b/flang/test/Driver/driver-options.f90
@@ -0,0 +1,6 @@
+! Check support of -m32 and -m64.
+! RUN: %flang -target x86_64-pc-win32 -m32 -### - %s 2>&1 | FileCheck -check-prefix=M32 %s
+! RUN: %flang -target i386-pc-win32 -m64 -### - %s 2>&1 | FileCheck -check-prefix=M64 %s
+
+! M32: "-triple" "i{{[0-9]}}86-{{.*}}"
+! M64: "-triple" "{{[^-]+}}64-{{.*}}"

@llvmbot
Copy link
Member

llvmbot commented Mar 21, 2025

@llvm/pr-subscribers-flang-driver

Author: Jean-Didier PAILLEUX (JDPailleux)

Changes

Exposes -m32 and -m64 options for Flang.
These options can be used to build libraries or tools (e.g. OpenBlas).


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

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+2-2)
  • (added) flang/test/Driver/driver-options.f90 (+6)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 66ae8f1c7f064..ddeb94e7b929f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4671,14 +4671,14 @@ def EB : Flag<["-"], "EB">, Alias<mbig_endian>;
 def m16 : Flag<["-"], "m16">, Group<m_Group>, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption]>;
 def m32 : Flag<["-"], "m32">, Group<m_Group>, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
 def maix32 : Flag<["-"], "maix32">, Group<m_Group>, Flags<[NoXarchOption]>;
 def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, Group<m_Group>,
   Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Enable hexagon-qdsp6 backward compatibility">,
   MarshallingInfoFlag<LangOpts<"HexagonQdsp6Compat">>;
 def m64 : Flag<["-"], "m64">, Group<m_Group>, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
 def maix64 : Flag<["-"], "maix64">, Group<m_Group>, Flags<[NoXarchOption]>;
 def mx32 : Flag<["-"], "mx32">, Group<m_Group>, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption]>;
diff --git a/flang/test/Driver/driver-options.f90 b/flang/test/Driver/driver-options.f90
new file mode 100644
index 0000000000000..db7d5ba84d49e
--- /dev/null
+++ b/flang/test/Driver/driver-options.f90
@@ -0,0 +1,6 @@
+! Check support of -m32 and -m64.
+! RUN: %flang -target x86_64-pc-win32 -m32 -### - %s 2>&1 | FileCheck -check-prefix=M32 %s
+! RUN: %flang -target i386-pc-win32 -m64 -### - %s 2>&1 | FileCheck -check-prefix=M64 %s
+
+! M32: "-triple" "i{{[0-9]}}86-{{.*}}"
+! M64: "-triple" "{{[^-]+}}64-{{.*}}"

@JDPailleux JDPailleux force-pushed the jdp/flang/m32_m64_flags branch from ca9e4c2 to 10add87 Compare March 27, 2025 12:27
@JDPailleux JDPailleux force-pushed the jdp/flang/m32_m64_flags branch from 10add87 to 9522fe0 Compare March 27, 2025 12:34
@JDPailleux JDPailleux changed the title [flang] Expose -m32 and -m64 options [flang] Expose -m64 option Mar 27, 2025
Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

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

LG.

@JDPailleux JDPailleux merged commit 5b36835 into llvm:main Mar 28, 2025
11 checks passed
@DanielCChen
Copy link
Contributor

@JDPailleux @kiranchandramohan
We are planning to add support for flang to compile 32-bit application as well as building 32-bit flang-rt on AIX. The first thing would be to enable -m32 for flang in the driver. I saw Kiran's comment. Would it be possible to make -m32 available in the driver but disable it in front_end if desired?

@kiranchandramohan
Copy link
Contributor

@JDPailleux @kiranchandramohan We are planning to add support for flang to compile 32-bit application as well as building 32-bit flang-rt on AIX. The first thing would be to enable -m32 for flang in the driver. I saw Kiran's comment. Would it be possible to make -m32 available in the driver but disable it in front_end if desired?

When you start working on 32-bit flang-rt support, you should feel free to add the -m32 flag to the driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants