emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.63k stars 3.28k forks source link

build FFmpeg got the ERROR:emcc is unable to create an executable file.C compiler test failed. #21070

Open stark-jarvis opened 8 months ago

stark-jarvis commented 8 months ago

Please include the following in your bug report:

Version of emscripten/emsdk: Please include the output emcc -v here emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.51 (c0c2ca1314672a25699846b4663701bcb6f69cca) clang version 18.0.0git (https://github.com/llvm/llvm-project f2464ca317bfeeedddb7cbdea3c2c8ec487890bb) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /data/download/emsdk-lib/emsdk/upstream/bin

Failing command line in full: If this is compile or link-time failure please include the full failing command along with its entire output.

configure: ./configure --cc=emcc --cxx=em++ --ar=emar --nm=emnm --ranlib=emranlib --prefix=/data/site/wasm/ffmpeg/ffmpeg-lib --enable-cross-compile --target-os=none --arch=x86_64 --cpu=generic --enable-gpl --enable-version3 --disable-sdl2 --disable-iconv --disable-runtime-cpudetect --disable-cuda-llvm --disable-programs --disable-doc --disable-avdevice --disable-swresample --disable-swscale --disable-postproc --disable-avformat --disable-avfilter --disable-everything --disable-debug --disable-asm --disable-fast-unaligned --disable-network --enable-parser=hevc --enable-decoder=hevc emcc is unable to create an executable file. C compiler test failed.

use emcc build my "C" demo, is OK....what`s wrong ???

FFmpeg was builded success. see the next info:

ffmpeg version N-113275-g1081bae94d Copyright (c) 2000-2024 the FFmpeg developers built with gcc 11 (GCC) configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree libavutil 58. 36.101 / 58. 36.101 libavcodec 60. 37.100 / 60. 37.100 libavformat 60. 20.100 / 60. 20.100 libavdevice 60. 4.100 / 60. 4.100 libavfilter 9. 17.100 / 9. 17.100 libswscale 7. 6.100 / 7. 6.100 libswresample 4. 13.100 / 4. 13.100 libpostproc 57. 4.100 / 57. 4.100

sbc100 commented 8 months ago

Often the ./configure script will write an error log somewhere when things go wrong. Can you find that log and perhaps attach it to this bug?

Have you tried running ./configure with emconfigure?

RightFS commented 7 months ago
emconfigure ./configure --cc="emcc" --cxx="em++" --ar="emar" --prefix=/usr/local/decoder_wasm/ffmpeg --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic \
    --enable-gpl --enable-version3 --disable-avdevice --enable-avformat --disable-swresample --disable-postproc --disable-avfilter \

    --disable-programs --disable-everything \
    --disable-ffplay --disable-ffprobe --disable-asm --disable-doc --disable-devices --disable-network \
    --disable-hwaccels --enable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs \     
    --enable-demuxers \
    --enable-decoder=hevc --enable-parser=hevc \
    --enable-decoder=h264  --enable-parser=h264
configure: ./configure --cc=emcc --cxx=em++ --ar=emar --prefix=/usr/local/decoder_wasm/ffmpeg --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic --enable-gpl --enable-version3 --disable-avdevice --enable-avformat --disable-swresample --disable-postproc --disable-avfilter --disable-programs --disable-everything --disable-ffplay --disable-ffprobe --disable-asm --disable-doc --disable-devices --disable-network --disable-hwaccels --enable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-demuxers --enable-decoder=hevc --enable-parser=hevc --enable-decoder=h264 --enable-parser=h264       
emcc is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
emconfigure: error: './configure --cc=emcc --cxx=em++ --ar=emar --prefix=/usr/local/decoder_wasm/ffmpeg --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic --enable-gpl --enable-version3 --disable-avdevice --enable-avformat --disable-swresample --disable-postproc --disable-avfilter --disable-programs --disable-everything --disable-ffplay --disable-ffprobe --disable-asm --disable-doc --disable-devices --disable-network --disable-hwaccels --enable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-demuxers --enable-decoder=hevc --enable-parser=hevc --enable-decoder=h264 --enable-parser=h264' failed (returned 1)

same error here emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.52 (fa478400df3351f7153c0279bc638784d3d90334) Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt) This is free and open source software under the MIT license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

RightFS commented 7 months ago

emcc -nologo -c -Fo/tmp/ffconf.UXpKlb94/test.o /tmp/ffconf.UXpKlb94/test.c clang: error: unknown argument: '-nologo'

sbc100 commented 7 months ago

You need to figure out why -nologo is being added. That is a windows-only flag and should not be passed to emcc.

chulsu72 commented 7 months ago

I removed all -nologo from ffmpeg's configure file and built it. wasm-ld: error: unknown file type: /tmp/ffconf.afyrIvzC/test.o

Ubuntu 20.04.6 LTS (WSL2) emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.52 ffmpeg 4.4 or 6.1

$ cat ffbuild/config.log ... BEGIN /tmp/ffconf.afyrIvzC/test.c 1 int main(void){ return 0; } END /tmp/ffconf.afyrIvzC/test.c emcc -c -Fo/tmp/ffconf.afyrIvzC/test.o /tmp/ffconf.afyrIvzC/test.c emcc -Fe/tmp/ffconf.afyrIvzC/test /tmp/ffconf.afyrIvzC/test.o wasm-ld: error: unknown file type: /tmp/ffconf.afyrIvzC/test.o ... C compiler test failed.

sbc100 commented 7 months ago

That seems very odd since it looks like /tmp/ffconf.afyrIvzC/test.o was just compiled with emcc. Normally wasm-ld: error: unknown file type means that file is some other kind of object file, normally one build for the host OS, e.g. an ELF file.

You can always run file /tmp/ffconf.afyrIvzC/test.o to find out what type of file it really is.

kashiken commented 7 months ago

Hello, Let me jump in this thread and share my idea.

I faced the same problem with the following environment:

When I ran the following command in the ffmpeg-4.3.2 directory, emconfigure ./configure (options) the script was aborted and the following message appeared, as others had mentioned, emcc is unable to create an executable file.

I checked ffbuild/config.log and investigate the problem:

  1. clang: error: unknown argument: '-nologo' -> This error comes because emcc doesn't have the option. Removing '-nologo' from configure resolves but another error occurs.
  2. wasm-ld: error: unknown file type: /tmp/ffconf.(random)/test.o -> I found that test.o in the directory has 0 byte, it means the compiler doesn't make object file correctly. I digged this and find that the configure script execute following command but emcc dosn't support the option '-Fo' . emcc -O3 -I/opt/ffmpeg/include -I/opt/ffmpeg/include/opus -c -Fo/tmp/ffconf.(random)/test.o /tmp/ffconf.(random)/test.c The correct option to specify output object for emcc is '-o'.

Both of the wrong options are for Microsoft MSVC, so I conclude the root cause of the problem is wrong compiler judgement written in probe_cc(). Actually I don't know what is the correct operation of compiler judgement but commenting out 'elif' section below this line helps to run configure to the end. elif $_cc -nologo- 2>&1 | grep -q Microsoft || { $_cc -v 2>&1 | grep -q clang && $_cc -? > /dev/null 2>&1; }; then

This is a problem with the configure script, not with emcc, so I believe this should be discussed in the ffmpeg repository.

chulsu72 commented 7 months ago

I did as kashiken said.

The build was successful by changing to the following environment:

Ubuntu 20.04.6 LTS (WSL2) emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.40 ffmpeg 4.4

I believe this should be discussed in the ffmpeg repository too.

Thank you very much.

jozefchutka commented 3 months ago

Please join our discussion related to ffmpeg build on the most recent emscripten on https://github.com/emscripten-core/emscripten/issues/22008