vcpkg icon indicating copy to clipboard operation
vcpkg copied to clipboard

[ffmpeg] [Build error] [configure] [test_ld failed]

Open Tangle-1990 opened this issue 2 years ago • 10 comments

Host Environment

  • OS: Windows-10
  • Compiler: MSVC-19.0.24215.1
  • vcpkg-tool version: 2022-05-05-67e17c1782801cf481be9ac0b3765dff3e4bdeb8
  • vcpkg-scripts version: 162a88fa4 2022-07-28
  • ffmpeg verson: 4.4.1#14

To Reproduce Steps to reproduce the behavior: ./vcpkg install ffmpeg:x86-windows-static

Failure logs

  • Console
    CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:96 (message):
        Command failed: D:/App/vcpkg/downloads/tools/msys2/79d5b6b790550399/usr/bin/bash.exe ./build.sh
        Working Directory: D:/App/vcpkg/buildtrees/ffmpeg/x64-windows-static-rel
        Error code: 1
        See logs for more information:
        D:\App\vcpkg\buildtrees\ffmpeg\build-x64-windows-static-rel-out.log
    
    Call Stack (most recent call first):
    ports/ffmpeg/portfile.cmake:548 (vcpkg_execute_required_process)
    scripts/ports.cmake:147 (include)
    
  • build-x64-windows-static-rel-out.log
    === CONFIGURING ===
    cl.exe 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
    [email protected] 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.
    
  • config.log
    test_ld cc
    test_cc
    BEGIN /c/Users/XXXX/AppData/Local/Temp/ffconf.xmA29ylu/test.c
        1	int main(void){ return 0; }
    END /c/Users//AppData/Local/Temp/ffconf.xmA29ylu/test.c
    cl.exe @D:/App/vcpkg/buildtrees/ffmpeg/x64-windows-static-rel/cflags.rsp -nologo -DHAVE_UNISTD_H=0 -c -Fo/c/Users/XXXX/AppData/Local/Temp/ffconf.xmA29ylu/test.o /c/Users/XXXX/AppData/Local/Temp/ffconf.xmA29ylu/test.c
    test.c
    C:\Users\XXXX\AppData\Local\Temp\ffconf.xmA29ylu\test.c : fatal error C1083: Cannot open compiler generated file: 'D:\c\Users\XXXX\AppData\Local\Temp\ffconf.xmA29ylu\test.o': No such file or directory
    C compiler test failed.
    

Additional context

The issue is clear that test_ld uses a wrong path[D:\c\Users\XXXX\AppData\Local\Temp\ffconf.xmA29ylu\test.o], which actully is path[C:\Users\XXXX\AppData\Local\Temp\ffconf.xmA29ylu\test.o]

Tangle-1990 avatar Jul 29 '22 08:07 Tangle-1990

D:\c\Users\XXXX\AppData\Local\Temp\ffconf.xmA29ylu\test.o this path is incorrect.

JackBoosY avatar Aug 01 '22 06:08 JackBoosY

Can you please provide full log config.log?

Thanks.

JackBoosY avatar Aug 01 '22 06:08 JackBoosY

Can you please provide full log config.log?

Thanks.

config.log

Tangle-1990 avatar Aug 01 '22 08:08 Tangle-1990

cl.exe @D:/App/vcpkg/buildtrees/ffmpeg/x64-windows-static-rel/cflags.rsp -nologo -DHAVE_UNISTD_H=0 -c -Fo/c/Users/RHTX/AppData/Local/Temp/ffconf.xmA29ylu/test.o /c/Users/RHTX/AppData/Local/Temp/ffconf.xmA29ylu/test.c
C:\Users\RHTX\AppData\Local\Temp\ffconf.xmA29ylu\test.c : fatal error C1083: Cannot open compiler generated file: 'D:\c\Users\RHTX\AppData\Local\Temp\ffconf.xmA29ylu\test.o': No such file or directory

source code: in configure:

test_cc(){
    log test_cc "$@"
    cat > $TMPC
    log_file $TMPC
    test_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
}

The test tmp file path should be relative, not absoult.

Edit: Should related to:

test_exec <<EOF
int main(void){ return 0; }
EOF
if test "$?" != 0; then
    echo "$cc is unable to create an executable file."
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
        echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
        echo "Only do this if you know what cross compiling means."
    fi
    die "C compiler test failed."
fi

JackBoosY avatar Aug 04 '22 06:08 JackBoosY

cc @dg0yt Any ideas for this cross check?

JackBoosY avatar Aug 04 '22 07:08 JackBoosY

Just tried ffmpeg:arm64-linux: The portfile's prefix detection is wrong and passes --cross-prefix=/<path>/aarch64-linux-gnu- when it should pass aarch64-linux-gnu-.

https://github.com/microsoft/vcpkg/blob/e6a000679745f8ea3f98067e5f3753d3cbecb948/ports/ffmpeg/portfile.cmake#L463-L466

Here, the regex should be: "([^\/]*-)gcc$". I just added related code in the x264 PR.

dg0yt avatar Aug 04 '22 07:08 dg0yt

@Tangle-1990 Could you please test the modification of dg0yt locally? Thank you!

Cheney-W avatar Aug 04 '22 09:08 Cheney-W

@Tangle-1990 Could you please test the modification of dg0yt locally? Thank you! Well, the solution is not work. I checked the configure file, it seems that cl.exe not support unix-like absolute path[like "/c/Users/RHTX/AppData/Local/Temp/ffconf.xmA29ylu/test.o"] and in the msys2 envirenment cl.exe dosen't transfer the unix-like path to window-like path but regards the unix-like path as a relative path.

Tangle-1990 avatar Aug 05 '22 08:08 Tangle-1990

@Cheney-W My comment only deals with cross_prefix, https://github.com/microsoft/vcpkg/issues/26048#issuecomment-1204849497. Windows triplets is a different story.

-Fo/c/Users/XXXX/AppData/Local/Temp/ffconf.xmA29ylu/test.o seems to target C:\Users\XXXX\AppData\Local\Temp\ffconf.xmA29ylu\test.o, but the error message reports D:\c\Users\XXXX\AppData\Local\Temp\ffconf.xmA29ylu\test.o. At some point, there is a conversion missing between Windows paths (C:) and MSYS Unix paths (/c). Maybe a missing compiler wrapper?

dg0yt avatar Aug 05 '22 09:08 dg0yt

Hi, I checked the configure file, there is a option "--toolchain" could impact the tmpdir path, but the configure executes with this parameter not setted. And there is code chunk in portfile.cmake which would set --toolchain

if(VCPKG_DETECTED_MSVC)
    set(OPTIONS "--toolchain=msvc ${OPTIONS}")
    # This is required because ffmpeg depends upon optimizations to link correctly
    string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -O2")
    string(REGEX REPLACE "(^| )-RTC1( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
    string(REGEX REPLACE "(^| )-Od( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
    string(REGEX REPLACE "(^| )-Ob0( |$)" " " VCPKG_COMBINED_C_FLAGS_DEBUG "${VCPKG_COMBINED_C_FLAGS_DEBUG}")
endif()

it seems that vcpkg not detects msvc.

Tangle-1990 avatar Aug 08 '22 06:08 Tangle-1990

add --toolchain msvc for MSVC in portfile.cmake

wsw0108 avatar Aug 12 '22 03:08 wsw0108

@Tangle-1990 Can you please add set(OPTIONS "${OPTIONS} --toolchain=msvc") to ports/ffmpeg/portfile.cmake line 519 then try again?

if(CC_path)
    vcpkg_add_to_path(PREPEND "${CC_path}")
endif()
set(OPTIONS "${OPTIONS} --toolchain=msvc")
message(STATUS "Building Options: ${OPTIONS}")

Thanks.

JackBoosY avatar Aug 12 '22 08:08 JackBoosY

add --toolchain msvc for MSVC in portfile.cmake

I have tried add this, and build success with msvc.

Sorry, I miss this comment https://github.com/microsoft/vcpkg/issues/26048#issuecomment-1207719518 before my last comment.

wsw0108 avatar Aug 12 '22 11:08 wsw0108

@Tangle-1990 Can you please add set(OPTIONS "${OPTIONS} --toolchain=msvc") to ports/ffmpeg/portfile.cmake line 519 then try again?

if(CC_path)
    vcpkg_add_to_path(PREPEND "${CC_path}")
endif()
set(OPTIONS "${OPTIONS} --toolchain=msvc")
message(STATUS "Building Options: ${OPTIONS}")

Thanks.

Hi, guys. Sorry for reply to you so late. Well, I add --toolchain=msvc at portfile.cmake:101

elseif(VCPKG_TARGET_IS_WINDOWS)
    string(APPEND OPTIONS " --target-os=win32")
    string(APPEND OPTIONS " --toolchain=msvc")
elseif(VCPKG_TARGET_IS_OSX)

where I think it wouldn't break down it's portablity, and now I build ffmpeg succeed. But I think the best fixed is to find out why VCPKG_DETECTED_MSVC not setted.

Tangle-1990 avatar Aug 18 '22 07:08 Tangle-1990