<div dir="ltr">So I talked with Shankar on IRC on this topic, and here's a suggestion.<div><br></div><div>1. Use a magic comment to determine if it's a YAML file. I'd propose "#!obj" as a YAML file magic because of similarity of Unix shebang. YAML reader skips this first line because it's a comment line in YAML grammar.</div>
<div><br></div><div>2. Add "target" field to YAML to represent what machine type the object type represents. For example, if a YAML object has "target: x86_64-linux-elf", it's decoded as a x86-64 Linux object file.</div>
<div><br></div><div>3. Let the YAML reader to interpret "target" field to handle target-specific fields if needed.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 7:44 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ah Sorry. Totally forgot about that.<div class="im"><br>
<br>
On 10/10/2013 8:24 PM, Rui Ueyama wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
# is a line comment chracter in YAML so it's valid. That's why I wrote a<br>
simple magic "comment".<br>
<br>
<br>
On Thu, Oct 10, 2013 at 6:21 PM, Shankar Easwaran<br>
<<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>><u></u>wrote:<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 10/10/2013 5:00 PM, Rui Ueyama wrote:<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Thu, Oct 10, 2013 at 9:16 AM, Shankar Easwaran<br></div>
<<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>>**<u></u>wrote:<div><div class="h5"><br>
<br>
On 10/9/2013 11:19 PM, Rui Ueyama wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Isnt having a YAML file starting with the below better, so that you dont<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
need to go through file extensions.<br>
<br>
magic :<br>
arch:<br>
<br>
I guess we will use a fixed file extension anyway (we probaly don't want<br>
to<br>
use .txt for YAML object file for example), so what do you think is the<br>
benefit of depending on special file magic compared to using file<br>
extension?<br>
<br>
<br>
I would like to support usecases like this.<br>
<br>
</blockquote>
(a)<br>
$ cat simple.s<br>
.text<br>
.global _start<br>
.type _start,@function<br>
_start:<br>
callq bar<br>
ret<br>
<br>
clang simple.s -c- -o- | lld -flavor gnu -target x86_64<br>
--output-filetype=yaml -r - | lld -flavor gnu -target x86_64 -<br>
<br>
Which is certainly not doable because you dont have a file created on the<br>
filesystem.<br>
<br>
This is an interesting example but I doubt the actual value of doing<br>
</blockquote>
that,<br>
especially because it cannot handle multiple input files. An alternative<br>
command line would be<br>
<br>
lld -flavor gnu -target x86_64 <(clang simple.s -c- -o- | lld -flavor<br>
gnu<br>
-target x86_64 --output-filetype=yaml -r -)<br>
<br>
which could handle multiple inputs, but it works only on bash and may be<br>
too tricky.<br>
<br>
The compiler usually depends on the file extension to distinguish file<br>
type, and your file has a non standard file extension, you can explicitly<br>
specify the language type by -x*language* option. Adding a similar option<br>
<br>
to the linker would be an option for us too.<br>
<br>
Even if we go with a magic, I'd like to make it a simple magic comment,<br>
such as "#!obj" at the beginning of a file. A magic string which is valid<br>
as a YAML, such as "magic:" is IMO less flexible and should be avoided.<br>
<br>
</div></div></blockquote><div><div class="h5">
YAML only allows key-value pairs. #!obj are all invalid characters for<br>
YAML files.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
PS: This has been snipped from an earlier discussion with Tim.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(b)<br>
<br>
lld -flavor gnu -target x86_64 input.o --output-filetype=yaml -o<br>
atoms.objtxt (Create a atom file using x86_64 target)<br>
lld -flavor gnu -target hexagon atoms.objtxt (use it with hexagon)<br>
<br>
You can create yaml files from each flavor and pass it to the wrong<br>
flavor, too.<br>
<br>
If we have the magic and arch in the yaml file (or) one entry combined<br>
triple(that combines flavor, operating system and target) this would work<br>
and there is no need to create new types of extensions.<br>
<br>
<br>
Thanks<br>
<br>
Shankar Easwaran<br>
<br>
-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,<br>
hosted by the Linux Foundation<br>
<br>
<br>
<br>
</blockquote></blockquote>
--<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted<br>
by the Linux Foundation<br>
<br>
<br>
</div></div></blockquote></blockquote><div class="HOEnZb"><div class="h5">
<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation<br>
<br>
</div></div></blockquote></div><br></div>