Opened 4 months ago

Closed 4 months ago

#7785 closed defect (invalid)

[Android] Configure script: Wrong HAVE_ macros are created due to "-f may not be used without -shared" error

Reported by: ESt Owned by:
Priority: normal Component: build system
Version: git-master Keywords: android
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
While building for Android the configuration script seems to create some wrong HAVE_ macros, e. g. #define HAVE_ATANF 0, HAVE_CBRT 0, HAVE_LOCALTIME_R 0, etc. Which later on causes issues with the build itself, e.g.:

./libavutil/libm.h:61:31: error: static declaration of 'cbrtf' follows non-static declaration
static av_always_inline float cbrtf(float x) 

The source of the problem seems to be that the 'test_ld' function throws the following error for those functions "-f may not be used without -shared". I've added $(if [ shared="yes" ] ; then echo "-shared" ; fi) to the last line of test_ld, and it seemed to fix the problem for that build:
(I'm not submitting a patch since I'm not sure this is the way the problem should be solved and I'm afraid it might cause errors with other builds)

test_ld(){
    log test_ld "$@"
    type=$1
    shift 1
    flags=$(filter_out '-l*|*.so' $@)
    libs=$(filter '-l*|*.so' $@)
    test_$type $($cflags_filter $flags) || return
    flags=$($ldflags_filter $flags)
    libs=$($ldflags_filter $libs)
    test_cmd $ld $LDFLAGS $LDEXEFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs $(if [ shared="yes" ] ; then echo "-shared" ; fi)
}


How to reproduce:

The configure command I ran was:
./configure --prefix=android/arm64-v8a --disable-asm --enable-cross-compile --disable-static --disable-programs --disable-doc --enable-shared --enable-protocol=file --enable-pic --enable-small --disable-pthreads --ar=/home/es/Android/Sdk/ndk-bundle//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar --strip=/home/es/Android/Sdk/ndk-bundle//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip --ld=/home/es/Android/Sdk/ndk-bundle//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld --cc=/home/es/Android/Sdk/ndk-bundle//toolchains/llvm/prebuilt/linux-x86_64/bin/clang --cxx=/home/es/Android/Sdk/ndk-bundle//toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --as=/home/es/Android/Sdk/ndk-bundle//toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target-os=android --extra-cflags='-target aarch64-none-linux-android -mfpu=neon -mfloat-abi=soft -I/home/es/Android/Sdk/ndk-bundle//sysroot/usr/include/aarch64-linux-android -O3 -fPIC' --extra-ldflags='-L/home/es/Android/Sdk/ndk-bundle//toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x -L/home/es/Android/Sdk/ndk-bundle//platforms/android-21/arch-arm64/usr/lib -lc' --sysroot=/home/es/Android/Sdk/ndk-bundle//sysroot --extra-libs=-lgcc
Then I ran 'make' and got the make error above (or you can see the ld error in the config log or the macros in config.h)

My NDK version is r19b and my OS is Arch-Linux
I'll attach the config.log in the files of this ticket

Attachments (1)

config.log (589.2 KB) - added by ESt 4 months ago.
Config log

Download all attachments as: .zip

Change History (3)

Changed 4 months ago by ESt

Config log

comment:1 Changed 4 months ago by cehoyos

  • Keywords android added; Android shared configure ld HAVE removed

Building for arm64-android works fine here with NDK r19b. Could you please retest with a simplified configure line without any extra-flags? It appears to me that --sysroot is not necessary anymore with NDK r19.
Why did you specify --disable-asm and --disable-pthreads?

$ ./configure --cross-prefix=../android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android- --cc=../android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang --arch=arm64 --target-os=android

comment:2 Changed 4 months ago by ESt

  • Resolution set to invalid
  • Status changed from new to closed

Ok, it seems to work with the command that you provided, sorry for not doing enough homework before reporting.

Note: See TracTickets for help on using tickets.