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

Include search paths not honored for asm(".include foo.s"); #25185

Closed
jyknight opened this issue Sep 14, 2015 · 6 comments
Closed

Include search paths not honored for asm(".include foo.s"); #25185

jyknight opened this issue Sep 14, 2015 · 6 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla

Comments

@jyknight
Copy link
Member

Bugzilla Link 24811
Resolution FIXED
Resolved on Jan 05, 2017 10:03
Version unspecified
OS Linux
CC @compnerd,@hfinkel

Extended Description

If you write a C file "foo.c" that says:
asm(".include "test-asm.s"");

And have an asm file named "/whatever/test-asm.s".

And if you run:
clang -I /whatever -c foo.c

Then, what should happen:
a) With integrated assembler, the search paths should be used by the integrated assembler to find the file.

b) Without an integrated assembler, the -I path arguments should be passed to the /usr/bin/as program, so it can handle the .include with the right paths. (note: gcc does indeed do this)

What happens now:

It fails to find the test-asm.s file, because search paths aren't passed into either assembler. It can the file (and does include it properly, even!), if the path is specified as relative to your current working directory.

Of course, writing C code like this is INCREDIBLY EVIL and nobody should ever do it. So I'm not planning to fix this. But, having discovered it, I thought I'd at least record a bug.

(Of course if you use this feature, -M can't work, because that stops after preprocessing, and this .include is not processed in the preprocessor. -MD could be made to work, IF you're using the integrated assembler, but that might be a bit of a confusing distinction?)

@jyknight
Copy link
Member Author

assigned to @compnerd

@jyknight
Copy link
Member Author

jyknight commented Jun 1, 2016

*** Bug llvm/llvm-bugzilla-archive#26897 has been marked as a duplicate of this bug. ***

@compnerd
Copy link
Member

Hmm, this is interesting since this is in the inline assembler.

At this point we have already lost the invocation and so we cannot really reconstruct the search path. The alternative way to think about this is what would we do if you constructed a module from clang, and then moved the module and compiled that with llc?

I don't know if this is really something we should support.

@jyknight
Copy link
Member Author

I think what it comes down to is that the system assemblers unfortunately take a -I argument, and llvm's integrated assembler is generally supposed to be able to compile the same code that you can with -fno-integrated-as.

Your objection appears to be to the entire concept of .include from inline assembly, not just setting the include path. I strongly share that distaste. But, people in the real world do seem to expect it to work, unfortunately.

So, IMO, it ought to be supported, even though that does mean being able to push search paths into the integrated assembler, even when compiling from bitcode.

@compnerd
Copy link
Member

compnerd commented Jan 5, 2017

SVN r291123.

@jyknight
Copy link
Member Author

mentioned in issue llvm/llvm-bugzilla-archive#26897

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants