Thanks Aram and Michael, that helps a lot.  

I've studied https://github.com/golang/go/tree/master/src/crypto/sha1 which 
looks like a good example of having a pure-go fallback with 
architecture-specific assembly.  

My next question is which tool is responsible for selecting the correct 
sha1block_GOARCH.s? Is the the compiler, linker, or where?

On Tuesday, September 13, 2016 at 9:32:25 AM UTC-6, Aram Hăvărneanu wrote:
>
> On Tue, Sep 13, 2016 at 6:19 AM,  <pcj...@gmail.com <javascript:>> wrote: 
> > My interpretation of golang's assembly is that it represents an 
> intermediate 
> > pseudo-language that is transformed via "instruction selection" to a 
> > concrete form. 
>
> Correct, but this pseudo-language is not portable between architectures. 
>
> > Therefore, is it possible to re-write the above to a cross-compilable 
> form? 
>
> The assembly in the Go distribution is already cross-compilable, but 
> looking at your example you are not concerned whether the assembly is 
> cross-compilable or not (that depends on the toolchain, and not on the 
> assembly code), but you want the assembly to be portable between 
> architectures. 
>
> Apart from the most trivial of cases, this is not possible. Different 
> targets use different instructions and different registers. 
>
> The Go assembler uses the same *syntax* on every architecture, so it 
> can be parsed and processed by a single program, however the assembly 
> code required for each target is very different. 
>
> -- 
> Aram Hăvărneanu 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to