emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 662 forks source link

Latest (3.x) emscripten vs 2.x, broken build scripts/libs/headers? #1331

Open spider853 opened 6 months ago

spider853 commented 6 months ago

Hi,

I've tried to compile ffmpeg with emscripten using this guide: https://dev.to/alfg/ffmpeg-webassembly-2cbl using MSYS2

I've used the latest version of both. It took a few hours of patches to go through compilation of it with emscripten 3.x, starting from missing -nologo in clang and ending with multiple missing functions, links and other stuff during compilation like gethrtime and so on...

with emscripten 2.0.16 it didn't had many issues except one hand patch for missing shutil.which('mingw32-make') (it was using tools.building.which)

Is there a reason so many issues are in the current version, will they get fixed or it's because backwards compatibility was lost? Couldn't find no information on things like missing nologo (is it a Microsoft only thing?), had to edit the py file to strip the argument

Thanks

sbc100 commented 6 months ago

We try not to break existing code unless there is good reason. Perhaps you could file individual issues with details of the specific problems you ran into and we can try to address them individually.

For the nologo issue specifically, IIRC emsripten has never supported the /nologo command line flag. IIUC that is cl.exe specific flag that is not supported by gcc or clang (or emscripten).

sbc100 commented 6 months ago

For the gethrtime issue, I don't think emscripten ever supported that either. I cannot find any reference to it anywhere in the git history. Maybe something odd is going on with the build setup that is causing the project to think its building on some other platform that does support that library call (e.g. solaris?)

spider853 commented 6 months ago

I think that might be the difference in 2.x and 3.x it detects the platform differently maybe? Like I mentioned above a good testbed is to just try to compile ffmpeg with that guide, and see the differences, 2.x no issues, 3.x (latest) a ton of issues 🤷‍♂️

spider853 commented 6 months ago

also forgot to mention I tried to build on the latest Ubuntu too, same issue

sbc100 commented 6 months ago

Between 2.0.16 and 3.0.0 there were over 1000 changes so its hard to say what might be causing your issues. Perhaps we can address them specifically one by one.

In order to reproduce do we just follow the instructions at https://dev.to/alfg/ffmpeg-webassembly-2cbl?

spider853 commented 6 months ago

yes, the only difference is you need to give the dirs to nm and ranlib (if not part of environment, which they're not by default)

-ranlib="$EMSDK/upstream/bin/llvm-ranlib" --nm="$EMSDK/upstream/bin/llvm-nm -g"