microsoft / qsharp-runtime

Runtime components for Q#
https://docs.microsoft.com/quantum
MIT License
285 stars 93 forks source link

Default Output Path for QIR Generation Should be Under obj\qsharp Folder #628

Open ScottCarda-MS opened 3 years ago

ScottCarda-MS commented 3 years ago

Please describe what you would like the feature to accomplish.
When the <QirOutputPath> is not provided in a Q# project, the system sets a default path for this to be a folder in the project file's directory, adjacent to the obj folder. This is an issue because when a dotnet clean is done, it will not clean out the generated QIR when it is placed here.

Describe the solution you'd like
The default path for the QIR output should be under the obj\qsharp folder, just as the response file, config file, and other output files are. This would make the default for QIR output more consistent with the location of other output files, making them easier to find and reason about, as well as ensure that they are properly dealt with during a dotnet clean.

Describe alternatives you've considered
none so far

Additional context
none so far

bettinaheim commented 3 years ago

@ScottCarda-MS The output path for the .bc file (the bitcode) is actually under obj\qsharp, right next to where the bond representation for the AST lives, and in the same way that the bond data structure is attached as resource to the dll, so is the .bc file. The human readable version (.ll file) is just for exactly that: so that people who want to take a look at the QIR can easily find it. For all tooling, you should rely directly on the .bc file or the resource in the dll (we should add a routine to the compiler to load that one - I haven't gotten around to it yet). Ultimately, the idea is that QIR emission is turned on by default and only the bc file is generated and attached, unless a user explicitly asked for the ll output for the sake of reading it.

ScottCarda-MS commented 3 years ago

@bettinaheim If the .ll file is not actually used for anything beyond providing something for people to read for themselves, then it is not as much of an issue if it is not removed during a dotnet clean. Does the Main.cs (the driver for the QIR) always apear under obj\qsharp? And if so, is there really any importance to the specific path specified by the <QirOutputPath>?

ScottCarda-MS commented 3 years ago

Hmm, as I use QIR generation more and more, this still bugs me that the default qir output location is not susceptible to a dotnet clean. It may not be a priority, but I still would like to see something done so that the output file is clean-able, even if it is only for human readability.

ScottCarda-MS commented 3 years ago

This would also help to make sure the .ll files are not pushed to the repo, without having to make a special rule for them in the gitignore.