LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 24811 - Include search paths not honored for asm(".include foo.s");
Summary: Include search paths not honored for asm(".include foo.s");
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Saleem Abdulrasool
URL:
Keywords:
: 26897 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-09-14 08:48 PDT by James Y Knight
Modified: 2017-01-05 10:03 PST (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Y Knight 2015-09-14 08:48:47 PDT
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?)
Comment 1 James Y Knight 2016-05-31 17:17:04 PDT
*** Bug 26897 has been marked as a duplicate of this bug. ***
Comment 2 Saleem Abdulrasool 2016-12-28 22:07:37 PST
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.
Comment 3 James Y Knight 2016-12-29 08:35:27 PST
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.
Comment 4 Saleem Abdulrasool 2017-01-05 10:03:24 PST
SVN r291123.