I've been thinking about writing some x86/64 assembly code in an open source project, for optimizing performance, however I can see compatibility issues if I want wide support:
- different calling conventions across platforms
- different syntax across compilers (MSVC (MASM) vs GCC/Clang (GAS))
- haven't really looked into it, but would supporting PIC vs non-PIC be an issue?
- 32/64-bit differences
What options are available if I don't want to write multiple copies of everything to target all combinations of the above? I figure that I may have to write separate 32/64-bit routines, which I can accept, but I'd like to avoid the others.
From what I've seen, there's no universal or widely accepted solution to this issue. Approaches I've seen:
- some projects just seem to go the multiple copy route
- OpenSSL has some Perl script which I guess transpiles the assembly to handle the differences
- I've seen some projects which require the end user (the one building the source) have a separate assembler, like NASM installed, and then they use macros to deal with the calling convention differences
To make building easy, I'd prefer not require the end user have to install a separate assembler. A transpiling script/application sounds nice, but is there one which is not specific to a project (like OpenSSL), that is perhaps "widely used"?
I've been thinking about another option: go the macro route above, but assemble object files for the various combinations, and distribute that.
Or are there any other options?