Skip to content

[clang-repl] Add call to 'InitializeAllAsmParsers' #86727

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
Apr 4, 2024

Conversation

aytey
Copy link
Contributor

@aytey aytey commented Mar 26, 2024

This PR fixes the following issue when working with clang-repl:

fatal error: error in backend: Inline asm not supported by this streamer because we don't have an asm parser for this target

When working with the following input (named "unit.cpp"):

__asm(".globl _ZSt21ios_base_library_initv");
int x;

and then in clang-repl:

#include "unit.cpp"
x = 10;

Signed-off-by: Andrew V. Teylu [email protected]

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Mar 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2024

@llvm/pr-subscribers-clang

Author: Andrew V. Teylu (aytey)

Changes

This PR fixes the following issue when working with clang-repl:

fatal error: error in backend: Inline asm not supported by this streamer because we don't have an asm parser for this target

When working with the following input (named "unit.cpp"):

__asm(".globl _ZSt21ios_base_library_initv");
int x;

and then in clang-repl:

#include "unit.cpp"
x = 10;

Signed-off-by: Andrew V. Teylu <[email protected]>


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

1 Files Affected:

  • (modified) clang/tools/clang-repl/ClangRepl.cpp (+1)
diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp
index 5bad8145324d06..aecf61b97fc719 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -152,6 +152,7 @@ int main(int argc, const char **argv) {
   llvm::InitializeAllTargets();
   llvm::InitializeAllTargetMCs();
   llvm::InitializeAllAsmPrinters();
+  llvm::InitializeAllAsmParsers();
 
   if (OptHostSupportsJit) {
     auto J = llvm::orc::LLJITBuilder().create();

@aytey
Copy link
Contributor Author

aytey commented Mar 26, 2024

This my first PR against LLVM; does something like this need tests? I'm 100% happy to add tests for this, but are there some examples of "good" clang-repl tests I can learn from/extend from?

@aytey
Copy link
Contributor Author

aytey commented Mar 26, 2024

This my first PR against LLVM; does something like this need tests? I'm 100% happy to add tests for this, but are there some examples of "good" clang-repl tests I can learn from/extend from?

Maybe this is reasonable:

// REQUIRES: host-supports-jit, x86_64-linux
// UNSUPPORTED: system-aix
//
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: cat %t/inline-asm.txt | clang-repl -Xcc="-I%t"

//--- inline-asm.cpp
__asm(".globl _ZSt21ios_base_library_initv");
int x;

//--- inline-asm.txt
#include "inline-asm.cpp"
x = 10;
%quit

@aytey
Copy link
Contributor Author

aytey commented Mar 26, 2024

llvm-lit: /tmp/llvm-project/llvm/utils/lit/lit/llvm/config.py:502: note: using clang: /tmp/clang_build/bin/clang
-- Testing: 1 tests, 1 workers --
PASS: Clang :: Interpreter/inline-asm.cpp (1 of 1)

Testing Time: 0.10s

Total Discovered Tests: 1
  Passed: 1 (100.00%)

@aytey aytey force-pushed the clang_repl_all_asm_parsers branch from 04e6bbd to d1e1049 Compare April 2, 2024 11:41
@aytey
Copy link
Contributor Author

aytey commented Apr 2, 2024

@weliveindetail @vgvassilev @junaire: sorry for pinging you directly, but could you take a look at this PR? I see you're all active on other clang-repl PRs, so thought you might be the best place to start to take a look at this one 🤞

@junaire
Copy link
Member

junaire commented Apr 2, 2024

@weliveindetail @vgvassilev @junaire: sorry for pinging you directly, but could you take a look at this PR? I see you're all active on other clang-repl PRs, so thought you might be the best place to start to take a look at this one 🤞

Hi, thanks for the PR. I think the change looks reasonable but I'm no longer working on this so I've picked some reviewers for you. They should be able to look at this soon.

@aytey
Copy link
Contributor Author

aytey commented Apr 2, 2024

@weliveindetail @vgvassilev @junaire: sorry for pinging you directly, but could you take a look at this PR? I see you're all active on other clang-repl PRs, so thought you might be the best place to start to take a look at this one 🤞

Hi, thanks for the PR. I think the change looks reasonable but I'm no longer working on this so I've picked some reviewers for you. They should be able to look at this soon.

Thank you very much :)

Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@weliveindetail weliveindetail left a comment

Choose a reason for hiding this comment

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

Yes, perfect. Thanks!

@weliveindetail
Copy link
Member

@aytey We can land patches through GitHub nowadays. Is the Squash and merge button accessible for you?

@aytey
Copy link
Contributor Author

aytey commented Apr 4, 2024

@aytey We can land patches through GitHub nowadays. Is the Squash and merge button accessible for you?

Unfortunately, I don't have write access to the repo, so that's not available to me. The only action I have is "update branch".

@junaire junaire merged commit cbdc86e into llvm:main Apr 4, 2024
Copy link

github-actions bot commented Apr 4, 2024

@aytey Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants