emcc and inline assembly issue
davebang opened this issue · comments
Trying to #include <choc/audio/choc_AudioFileFormat_FLAC.h>
and compile with emcc but it doesn't like this inline asm....
subprojects/choc/audio/choc_AudioFileFormat_FLAC.h:6702:46: error: invalid output constraint '=a' in asm
asm volatile (".byte 0x0f, 0x01, 0xd0" : "=a"(lo), "=d"(hi) : "c" (0));
^
1 error generated.
Have worked around it by undefining the __GNUC__
macro that encapsulates this code temporarily. Was hoping to define FLAC__NO_ASM
as a fix but that doesn't seem to cover it. Not sure if there's something I'm missing here but it seems like there maybe should be provision for emcc to avoid this line and fallthrough to the return 0 in the #else
case below?
Hmm, thanks for the heads-up, I've not been testing emcc as a target, though it'd certainly be good to support it. I'm sure I can fudge some macros to avoid it hitting that codepath...
..does it work for you if you just bang a check for CHOC_EMSCRIPTEN at the end of line 173?
#if ! (defined (__ARM_ARCH) || defined (__arm__) || defined (__arm64__) || defined(__aarch64__) || defined(_M_ARM64) || CHOC_EMSCRIPTEN)
Thanks! Yes, I need to add -DCHOC_EMSCRIPTEN to emcc too but then it works
CHOC_EMSCRIPTEN isn't supposed to be added to a build, it's automatically detected in choc_Platform.h
Maybe we need to make sure choc_Platform.h is included at the top of that file?
..or simpler, just use this:
#if ! (defined (__ARM_ARCH) || defined (__arm__) || defined (__arm64__) || defined(__aarch64__) || defined(_M_ARM64) || defined (__EMSCRIPTEN__))
Brilliant - yes, that's got it. I was getting "Unknown platform" when including the platform header.
But adding defined (__EMSCRIPTEN__)
alone works great.
Cool, I'll push that change. Is that the only problem you've hit with emcc?
So far yes but it's the first time I've built a class that includes choc with emcc. I'm going to be doing more, so will let you know if I run in to anything else.
@julianstorer quick follow up, whilst i managed to resolve the emcc compiler issues, I never actually managed to access/playback the audio. It was a little while ago now but IIRC, it was some problem at AudioFileReader readEntireStream(). Perhaps the buffer was empty or some runtime issue, I can't remember exactly. We switched to the WAV reader for the short-term and all is fine.
I investigated a little but other tasks took priority so I never got to the bottom of it. I'll follow up again if/when I revisit it.