Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x264 build fails with NDK r23 #144

Closed
juha-h opened this issue Sep 4, 2021 · 10 comments
Closed

x264 build fails with NDK r23 #144

juha-h opened this issue Sep 4, 2021 · 10 comments
Assignees
Labels
android Affect Android platform enhancement New feature or request fixed-in-v4.5 Fixed in release v4.5 incompatibility scripts Affect build scripts v4.4 Affects v4.4 release

Comments

@juha-h
Copy link

juha-h commented Sep 4, 2021

Description
I upgraded NDK from r21 (21.4.7075529) to r23 (23.0.7599858) and ffmpeg-kit (main branch) build failed for arm64-v8a architecture at x264 with error message

No working C compiler found.

Expected behavior
I would expect the build work as it did with NDK r21, but don't know if ffmpeg-kit main branch is supposed to work with NDK r23.

Current behavior
See the log below.

To Reproduce

ANDROID_NDK_ROOT=/opt/Android/ndk/23.0.7599858 \
./android.sh --enable-gpl --no-archive \
	--disable-arm-v7a --disable-arm-v7a-neon --disable-x86 \
	--disable-x86-64 \
	--enable-libvpx --enable-x264 --enable-x265 --enable-libaom \
	--enable-libpng --skip-ffmpeg-kit

Logs

INFO: Building x264 for aarch64-linux-android with the following environment variables

SHELL=/bin/bash
SESSION_MANAGER=local/lohi:@/tmp/.ICE-unix/130294,unix/lohi:/tmp/.ICE-unix/130294
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session2
XDG_MENU_PREFIX=xfce-
GTK_IM_MODULE=ibus
LANGUAGE=en_US:en
TERMINATOR_DBUS_PATH=/net/tenshu/Terminator2
MAKE_TERMOUT=/dev/pts/2
SSH_AUTH_SOCK=/tmp/ssh-kMm8DVpz5ENk/agent.130294
INSTALL_PKG_CONFIG_DIR=/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/pkgconfig
TERMINATOR_UUID=urn:uuid:03116634-54df-4769-adf6-b12fdc3d845f
XMODIFIERS=@im=ibus
DESKTOP_SESSION=xfce
SSH_AGENT_PID=130351
GPG_TTY=/dev/pts/2
EDITOR=emacs
XDG_SEAT=seat0
PWD=/usr/src/libbaresip-android/ffmpeg-kit
LOGNAME=jh
XDG_SESSION_DESKTOP=xfce
XDG_SESSION_TYPE=x11
PRINTER=Canon_MP250_series
CXX=aarch64-linux-android24-clang++
CXXFLAGS=-std=c++11 -fno-exceptions -fno-rtti -Os -ffunction-sections -fdata-sections
XAUTHORITY=/home/jh/.Xauthority
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/jh
GDM_LANG=en_US.utf8
TOOLCHAIN_ARCH=arm64
LDFLAGS=-march=armv8-a -Wl,--gc-sections -Os -ffunction-sections -fdata-sections -lc -lm -ldl -llog -L/opt/Android/ndk/23
.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/lib -L/opt/Android/ndk/23.0.7599858/toolchains/llv
m/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24 -L/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt
/linux-x86_64/lib -Wl,--hash-style=both -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a
HOME=/home/jh
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=XFCE
VTE_VERSION=6203
ZLIB_PACKAGE_CONFIG_PATH=/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/pkgconfig/zlib.pc
FFMPEG_KIT_BUILD_TYPE=android
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
API=24
LD=aarch64-linux-android-ld
TERMINATOR_DBUS_NAME=net.tenshu.Terminator21a9d5db22c73a993ff0b42f64b396873
ac_cv_c_bigendian=no
PKG_CONFIG_LIBDIR=/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/pkgconfig
CLUTTER_IM_MODULE=ibus
MFLAGS=
SCTP=1
SED_INLINE=sed -i
MAKEFLAGS=
XDG_SESSION_CLASS=user
IBUS_DISABLE_SNOOPER=1
TERM=xterm-256color
TOOLCHAIN=linux-x86_64
USER=jh
GIT_PAGER=less --tabs=4
MAKE_TERMERR=/dev/pts/2
LIB_INSTALL_BASE=/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64
AR=aarch64-linux-android-ar
AS=aarch64-linux-android24-clang
SANE_DEFAULT_DEVICE=pixma:04A9173A_CA3478
ORIGINAL_API=24
ARCH=arm64-v8a
DISPLAY=:0.0
SHLVL=3
NM=aarch64-linux-android-nm
MAKELEVEL=1
ANDROID_SDK_ROOT=/foo/bar
QT_IM_MODULE=ibus
XDG_VTNR=7
XDG_SESSION_ID=57
PAPERSIZE=a4
FFMPEG_KIT_TMPDIR=/usr/src/libbaresip-android/ffmpeg-kit/.tmp
PJSIP_BUILD_DIR=/usr/src
XDG_RUNTIME_DIR=/run/user/1000
BASEDIR=/usr/src/libbaresip-android/ffmpeg-kit
ANDROID_NDK_ROOT=/opt/Android/ndk/23.0.7599858
STRIP=aarch64-linux-android-strip
XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
PATH=/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin:/usr/bin:/bin:/opt/Android/ndk/23.0.7599858/
toolchains/llvm/prebuilt/linux-x86_64/bin
MPAGE=-1 -m60l50t50b -bA4 -o
CC=aarch64-linux-android24-clang
GDMSESSION=xfce
CFLAGS=-march=armv8-a -DFFMPEG_KIT_ARM64_V8A -std=c99 -Wno-unused-function -fno-integrated-as -fstrict-aliasing -DANDROID
_NDK -fPIC -DANDROID -D__ANDROID__ -D__ANDROID_API__=24 -Os -ffunction-sections -fdata-sections  
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
RANLIB=aarch64-linux-android-ranlib
OLDPWD=/usr/src/libbaresip-android
SKIP_ffmpeg_kit=1
_=/usr/bin/env
----------------------------------------------------------------

INFO: System information

INFO: Linux lohi 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux

----------------------------------------------------------------

No working C compiler found.

Other
Compiler aarch64-linux-android24-clang does exist in /opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin:

$ more /opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang
#!/bin/bash
if [ "$1" != "-cc1" ]; then
    `dirname $0`/clang --target=aarch64-linux-android24 "$@"
else
    # Target is already an argument.
    `dirname $0`/clang "$@"
fi
@juha-h
Copy link
Author

juha-h commented Sep 4, 2021

I also tried with development branch and then build of x264 succeeded, but ffmpeg failed:

./android.sh --enable-gpl --no-archive \
	--disable-arm-v7a --disable-arm-v7a-neon --disable-x86 \
	--disable-x86-64 \
	--enable-libvpx --enable-x264 --enable-x265 --enable-libaom \
	--enable-libpng --skip-ffmpeg-kit

Building ffmpeg-kit library for Android

Architectures: arm64-v8a
Libraries: android-zlib, libvpx, x264, x265, libaom

Downloading sources: ok

Building arm64-v8a platform on API level 24

x264: ok
x265: ok
libaom: ok
libpng: ok
cpu-features: ok
libvpx: ok

ffmpeg: failed

See build.log for details

make: *** [Makefile:302: ffmpeg] Error 1

and build.log has:

...
INFO: Building ffmpeg for  with the following environment variables

SHELL=/bin/bash
SESSION_MANAGER=local/lohi:@/tmp/.ICE-unix/130294,unix/lohi:/tmp/.ICE-unix/130294
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session2
XDG_MENU_PREFIX=xfce-
GTK_IM_MODULE=ibus
LANGUAGE=en_US:en
DETECTED_NDK_VERSION=23.0.7599858
TERMINATOR_DBUS_PATH=/net/tenshu/Terminator2
MAKE_TERMOUT=/dev/pts/3
SSH_AUTH_SOCK=/tmp/ssh-kMm8DVpz5ENk/agent.130294
DEPENDENCY_REBUILT_freetype=1
TERMINATOR_UUID=urn:uuid:56083a28-715a-42f8-8397-a4f50b750123
XMODIFIERS=@im=ibus
DESKTOP_SESSION=xfce
SSH_AGENT_PID=130351
GPG_TTY=/dev/pts/3
EDITOR=emacs
XDG_SEAT=seat0
PWD=/usr/src/libbaresip-android/ffmpeg-kit
LOGNAME=jh
XDG_SESSION_DESKTOP=xfce
XDG_SESSION_TYPE=x11
PRINTER=Canon_MP250_series
XAUTHORITY=/home/jh/.Xauthority
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/jh
GDM_LANG=en_US.utf8
TOOLCHAIN_ARCH=arm64
HOME=/home/jh
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=XFCE
VTE_VERSION=6203
DEPENDENCY_REBUILT_libass=1
FFMPEG_KIT_BUILD_TYPE=android
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
API=24
DEPENDENCY_REBUILT_openh264=1
TERMINATOR_DBUS_NAME=net.tenshu.Terminator21a9d5db22c73a993ff0b42f64b396873
CLUTTER_IM_MODULE=ibus
MFLAGS=
SCTP=1
MAKEFLAGS=
XDG_SESSION_CLASS=user
IBUS_DISABLE_SNOOPER=1
TERM=xterm-256color
TOOLCHAIN=linux-x86_64
USER=jh
GIT_PAGER=less --tabs=4
MAKE_TERMERR=/dev/pts/3
LIB_INSTALL_BASE=/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64
SANE_DEFAULT_DEVICE=pixma:04A9173A_CA3478
ORIGINAL_API=24
ARCH=arm64-v8a
DISPLAY=:0.0
SHLVL=3
MAKELEVEL=1
ANDROID_SDK_ROOT=/foo/bar
QT_IM_MODULE=ibus
XDG_VTNR=7
XDG_SESSION_ID=57
DEPENDENCY_REBUILT_libwebp=1
PAPERSIZE=a4
FFMPEG_KIT_TMPDIR=/usr/src/libbaresip-android/ffmpeg-kit/.tmp
PJSIP_BUILD_DIR=/usr/src
XDG_RUNTIME_DIR=/run/user/1000
BASEDIR=/usr/src/libbaresip-android/ffmpeg-kit
DEPENDENCY_REBUILT_leptonica=1
ANDROID_NDK_ROOT=/opt/Android/ndk/23.0.7599858
XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
DEPENDENCY_REBUILT_tesseract=1
PATH=/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin:/usr/bin:/bin
MPAGE=-1 -m60l50t50b -bA4 -o
GDMSESSION=xfce
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DEPENDENCY_REBUILT_libvpx=1
OLDPWD=/usr/src/libbaresip-android
SKIP_ffmpeg_kit=1
_=/usr/bin/env
----------------------------------------------------------------

INFO: System information

INFO: Linux lohi 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux

----------------------------------------------------------------

INFO: Enabling library libvpx

INFO: Enabling library x264

INFO: Enabling library x265

INFO: Enabling library libaom

INFO: Enabling library libpng

INFO: Enabling library cpu-features

INFO: Enabling library android-zlib

INFO: Cleaning workspace for ffmpeg

Updated 0 paths from the index
Updated 0 paths from the index
Updated 0 paths from the index
Updated 0 paths from the index

INFO: Enabled custom ffmpeg-kit protocols

aarch64-linux-android24-clang 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.

@tanersener
Copy link
Collaborator

main doesn't support r23 yet but development branch does. It is tested with the latest NDK version available.

If you encounter errors, I suggest following the error messages on the build output to understand what went wrong. Your output says to look inside the ffbuild/config.log file. So, please have a look at it.

@juha-h
Copy link
Author

juha-h commented Sep 4, 2021

Can't find ffbuild/config.log nor ffbuild dir not config.log inside ffmpeg-kit. Where should it be?

@juha-h
Copy link
Author

juha-h commented Sep 4, 2021

Error message ffmpeg: failed comes immediately after libvpx: ok so perhaps ffbuild dir has not been created yet.

@juha-h
Copy link
Author

juha-h commented Sep 5, 2021

How does the test that works for you differ in its ./android.sh arguments?

@tanersener
Copy link
Collaborator

Can't find ffbuild/config.log nor ffbuild dir not config.log inside ffmpeg-kit. Where should it be?

It is under the src/ffmpeg folder. See Logs wiki page.

How does the test that works for you differ in its ./android.sh arguments?

Different computers, different outcomes.

@juha-h
Copy link
Author

juha-h commented Sep 5, 2021

Ok, found config.log. Failing compiler test looks like this:

test_ld cc
test_cc
BEGIN /tmp/ffconf.1RTWRmfX/test.c
    1	int main(void){ return 0; }
END /tmp/ffconf.1RTWRmfX/test.c
aarch64-linux-android24-clang --sysroot=/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/sysroot -march=armv8-a -DFFMPEG_KIT_ARM64_V8A -Wno-unused-function -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD -fstrict-aliasing -DANDROID_NDK -fPIC -DANDROID -D__ANDROID__ -D__ANDROID_MIN_SDK_VERSION__=24 -flto -fuse-ld=gold -O2 -ffunction-sections -fdata-sections -I/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/libvpx/include -I/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/x264/include -I/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/x265/include -I/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/libaom/include -I/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/libpng/include/libpng16 -march=armv8-a -c -o /tmp/ffconf.1RTWRmfX/test.o /tmp/ffconf.1RTWRmfX/test.c
clang-12: warning: argument unused during compilation: '-fuse-ld=gold' [-Wunused-command-line-argument]
aarch64-linux-android24-clang -march=armv8-a -Wl,--gc-sections -flto -fuse-ld=gold -O2 -ffunction-sections -fdata-sections -finline-functions -lc -lm -ldl -llog -lcamera2ndk -lmediandk -L/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/lib -L/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24 -L/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/lib -Wl,--hash-style=both -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libunwind.a -L/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/libvpx/lib -lvpx -lm -L/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/cpu-features/lib -lndk_compat -L/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/x264/lib -lx264 -lm -ldl -L/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/x265/lib -lx265 -lm -ldl -llog -lm -lc++_shared -L/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/libaom/lib -laom -lm -L/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/libpng/lib -L/opt/Android/ndk/23.0.7599858/platforms/android-24/arch-arm64/usr/lib -lpng16 -lm -lz -L/opt/Android/ndk/23.0.7599858/platforms/android-24/arch-arm64/usr/lib -lz -L/opt/Android/ndk/23.0.7599858/platforms/android-24/arch-arm64/usr/lib --sysroot=/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/sysroot -march=armv8-a -o /tmp/ffconf.1RTWRmfX/test /tmp/ffconf.1RTWRmfX/test.o -L/usr/src/libbaresip-android/ffmpeg-kit/prebuilt/android-arm64/cpu-features/lib -lndk_compat
/usr/bin/ld.gold: fatal error: /opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/crtbegin_dynamic.o: unsupported ELF machine number 183
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
C compiler test failed.

Failing linker is /usr/bin/ld.gold and earlier there is warning

clang-12: warning: argument unused during compilation: '-fuse-ld=gold' [-Wunused-command-line-argument]

NDK toolchain does not have /usr/bin/ld.gold, but Debian does have it. When aarch64-linux-android24-clang is used to compile the the test program, shouldn't the linker too be from the toolchain and not from Debian? Mixing of the environments does not sound like a good idea.

@juha-h
Copy link
Author

juha-h commented Sep 5, 2021

NDK r21 does have gold linker:

/opt/Android/ndk/21.4.7075529$ fdfind ld.gold
toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld.gold
toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld.gold
toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold
toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.gold
toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld.gold
toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold
toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld.gold
toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.gold
toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android-ld.gold
toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-ld.gold
toolchains/llvm/prebuilt/linux-x86_64/i686-linux-android/bin/ld.gold
toolchains/llvm/prebuilt/linux-x86_64/x86_64-linux-android/bin/ld.gold
toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-ld.gold
toolchains/x86-4.9/prebuilt/linux-x86_64/i686-linux-android/bin/ld.gold
toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-ld.gold
toolchains/x86_64-4.9/prebuilt/linux-x86_64/x86_64-linux-android/bin/ld.gold

but r23 does not:

/opt/Android/ndk/23.0.7599858$ fdfind ld.gold
/opt/Android/ndk/23.0.7599858$ 

My understanding is that ffmpeg should use this linker:

/opt/Android/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/ld.lld

that exists both in r21 and r23.

@tanersener tanersener self-assigned this Sep 5, 2021
@tanersener tanersener added android Affect Android platform enhancement New feature or request incompatibility scripts Affect build scripts v4.4 Affects v4.4 release labels Sep 5, 2021
@tanersener
Copy link
Collaborator

Apparently, arm64-v8a wasn't tested enough on development. gold linker used by arm64-v8a is removed on NDK r23, that's why it fails. I fixed it by switching to lld. It should be working now.

@juha-h
Copy link
Author

juha-h commented Sep 5, 2021

Thanks for the fix. Now ffmpeg build worked fine for both arm64-v8a and arm-v7a architectures.

@juha-h juha-h closed this as completed Sep 5, 2021
@tanersener tanersener added the fixed-on-development Fixed on the development branch. Not released yet. label Sep 5, 2021
@tanersener tanersener added fixed-in-v4.5 Fixed in release v4.5 and removed fixed-on-development Fixed on the development branch. Not released yet. labels Sep 20, 2021
@janbolat janbolat mentioned this issue Sep 22, 2021
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Affect Android platform enhancement New feature or request fixed-in-v4.5 Fixed in release v4.5 incompatibility scripts Affect build scripts v4.4 Affects v4.4 release
Projects
None yet
Development

No branches or pull requests

2 participants