Skip to content

[Clang][Driver] Support linker relaxation options for LoongArch #123587

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
Jan 23, 2025

Conversation

zhaoqi5
Copy link
Contributor

@zhaoqi5 zhaoqi5 commented Jan 20, 2025

This commit completed four tasks:

  • Add -mrelax/-mno-relax options support for LoongArch in clang driver.
  • Print error for -gsplit-dwarf with LoongArch linker relaxation (-mrelax).
  • Pass -X to linker to discard a plethora of .L symbols due to linker relaxation.
  • Forward --no-relax option to linker.

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

llvmbot commented Jan 20, 2025

@llvm/pr-subscribers-backend-loongarch
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: ZhaoQi (zhaoqi5)

Changes

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

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+1-1)
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index e5db1b2f1550b8..5557ca4bf4491f 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -422,7 +422,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     return;
   }
 
-  if (Triple.isRISCV()) {
+  if (Triple.isRISCV() || Triple.isLoongArch()) {
     CmdArgs.push_back("-X");
     if (Args.hasArg(options::OPT_mno_relax))
       CmdArgs.push_back("--no-relax");

@zhaoqi5 zhaoqi5 changed the title [Clang][Driver] Pass -X and forward --no-relax to linker for LoongArch [Clang][Driver] Support linker relaxation options for LoongArch Jan 22, 2025
@llvmbot llvmbot added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Jan 22, 2025
Copy link
Contributor

@SixWeining SixWeining left a comment

Choose a reason for hiding this comment

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

LGTM. What do you think about this? Clang doesn't pass +relax or -relax by default which means the default behavior is determined by LLVM and currently the relax target feature is not enabled by any LoongArch processor. @MaskRay

@zhaoqi5 zhaoqi5 merged commit ba70368 into llvm:main Jan 23, 2025
8 checks passed
@zhaoqi5 zhaoqi5 deleted the pass-x-norelax-to-linker branch January 23, 2025 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:loongarch clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants