<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> On Mon, Mar 30, 2015 at 9:52 AM Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br>
> From PR18808 I said a few things and that I was going to redirect to the mailing list for further discussion. So here we are, go.<br>
><br>
> 1) Whether or not to allow changing of target-cpu/target-feature/triple at link time code generation.<br>
><br>
> - Not convinced here of the facility to do so. Could just recompile the individual bitcode files to get what you want, but there are some users that are trying to ship bitcode (as crazy as that sounds).<br>
<br>
</span>IMO, it's cleanest of the target-cpu/target-feature/etc. are set at<br>
compile time.  That's where users are accustomed to specifying codegen<br>
options already, and besides: the frontend needs to know the backend in<br>
order to conform to the ABI, set macros, emit calls to target-specific<br>
intrinsics, etc.<br></blockquote><div><br></div><div>Cleanest yes, most familiar yes, but doesn't fit the usecase of PNaCl/Emscripten/Renderscript/Halide/... as Eric was mentioning. These indeed need to figure out proper ABI, macros, intrinsics, but the existence of these is a pretty good proof that something can be done (I'm not saying it's clean or pretty!).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">>  That said I was actually envisioning something like:<br>
><br>
> clang -emit-llvm foo.c -o foo.bc<br>
> ...<br>
><br>
> clang -O3 -flto all.bc -arch x86_64h -o haswell_slice<br>
> clang -O3 -flto all.bc -arch x86_64 -o x86_64_slice<br>
><br>
> for the same set of bitcode files. But given the front end language restrictions on doing anything actually interesting there it's not too much of a constraint.<br>
<br>
</span>Many of the differences between architectures CPUs affect preprocesser<br>
definitions, right?  Link-time is too late for the frontend to emit<br>
Haswell-specific intrinsics, for example.<br>
<br>
That said, it would be cool if this worked.<br></blockquote><div><br></div><div>Agreed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> Another usage is the (admittedly one I don't think we want to support) halide one that I discovered this week:<br>
><br>
> clang foo.c -emit-llvm foo.bc<br>
> clang -target aarch64-linux-gnu foo.bc -O3 -o foo.aarch64<br>
> clang -target x86_64-linux-gnu foo.bc -O3 -o foo.x86_64<br>
> ...<br>
<br>
</span>Whereas this is just insane :0.<br></blockquote><div><br></div><div>Disagreed: different usecase from above :-)</div><div><br></div><div>Whoever maintains "portable" things has to figure out how this works, and I think right now it's still the wild west (hence insane may not be too far of a qualification), but I don't think it's an invalid usecase. </div></div></div></div>