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

[Bug]: Several configure&make packages give binaries with cannot locate symbol "__extendsftf2" #8029

Closed
Grimler91 opened this issue Nov 21, 2021 · 25 comments
Labels

Comments

@Grimler91
Copy link
Member

Problem description

After the ndk-r23 update several configure&make packages seem to give binaries that can have issues like

CANNOT LINK EXECUTABLE "gvpack": cannot locate symbol "__extendsftf2" referenced by "/data/data/com.termux/files/usr/lib/graphviz/libgvplugin_neato_layout.so"...

We saw it first for tesseract, where the workaround was to switch to building with cmake instead of configure and make. Updating graphviz gives a package with the same issue in some of the binaries.

Same workaround might work for graphviz as well, there is an CMakeLists.txt available, but since multiple packages have this problem there are probably other packages where this is not an option.

A minimal code example using static_cast<long double>() (which clang turns into exteddftf2) does not have any issues when (cross-)compiled. I can try see if a minimal example with a configure script and Makefile gives the issue.

What steps will reproduce the bug?

Build and install graphviz 2.49.3 and try to run for example gvpack on device.

What is the expected behavior?

gvpack, and other programs, should execute without an undefined symbol error.

System information

Just tested on aarch64 so far:

termux-info:

Application version:
0.117
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://grimler.se/termux-packages-24 stable main
# game-repo (sources.list.d/game.list)
deb https://grimler.se/game-packages-24 games stable
# root-repo (sources.list.d/root.list)
deb https://grimler.se/termux-root-packages-24 root stable
# science-repo (sources.list.d/science.list)
deb https://grimler.se/science-packages-24 science stable
# x11-repo (sources.list.d/x11.list)
deb https://grimler.se/x11-packages x11 main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/24 termux extras
Updatable packages:
All packages up to date
Android version:
11
Kernel build information:
Linux localhost 4.4.111-gd5fc07ee4d01 #6 SMP PREEMPT Sun Oct 31 19:57:10 CET 2021 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-G955F
@Grimler91 Grimler91 added the bug report Something is not working properly label Nov 21, 2021
@Grimler91
Copy link
Member Author

I see now that th e symbol is slightly different, extenddftf2 vs extendsftf2.

On arm we do not seem to have this problem, compiling graphviz 2.49.3 for arm gives a fully working package

@thunder-coding
Copy link
Member

I guess this issue is also reproducible on x86_64, did you try in emulator?

From NDK changelog

Issue 1230: LLVM's libunwind is now used instead of libgcc for all architectures rather than just 32-bit Arm.
Issue 1231: LLVM's libclang_rt.builtins is now used instead of libgcc.

The symbols which you refrenced, I could find in libgcc's source code and also in libcompiler-rt's, So I guess this is an upstream issue and will be likely fixed in future NDK versions

Further investigation,

$ nm $PREFIX/lib/libcompiler_rt-extras.a | grep __extend
$

Whereas,

$
nm $PREFIX/lib/clang/13.0.0/lib/android/libclang_rt.builtins-aarch64-android.a | grep __extend
0000000000000000 T __extenddftf2
0000000000000000 T __extendhftf2
0000000000000000 T __extendsftf2
0000000000000000 T __extendsfdf2
0000000000000000 T __extendhfsf2
$

Our libcompiler-rt has the symbols but NDK's doesn't, so probably we need to report this upstream. Also, I wonder why build with Cmake succeeds while with autotools, it gives this error. This is worth investigating.

@xtkoba
Copy link
Contributor

xtkoba commented Nov 22, 2021

Official NDK bindist also has those symbols:

$ nm /usr/local/opt/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8/lib/linux/libclang_rt.builtins-aarch64-android.a | grep __extend
0000000000000000 T __extenddftf2
0000000000000000 T __extendhftf2
0000000000000000 T __extendsftf2
0000000000000000 T __extendsfdf2
0000000000000000 T __extendhfsf2

@xtkoba
Copy link
Contributor

xtkoba commented Nov 22, 2021

One possibility is that some shared library that is used when lding accidentally defines the symbol as not HIDDEN, resolving the reference without the definition from static compiler-rt builtin library. If the shared library of the same name that is used when executing does not have that symbol (or has it as HIDDEN), then the reference cannot be resolved.

@Grimler91
Copy link
Member Author

One possibility is that some shared library that is used when lding accidentally defines the symbol as not HIDDEN

Do you know of a way to check the status of the symbol? On aarch64 we have

$ nm -D $PREFIX/lib/graphviz/libgvplugin_neato_layout.so | grep __extend
                 U __extendsftf2

but on arm extendsftf2 isn't used at all (it isn't referenced in either $PREFIX/lib/graphviz/libgvplugin_neato_layout.so or $PREFIX/lib/clang/13.0.0/lib/android/libclang_rt.builtins-aarch64-android.a).

I tried adding -u__extendsftf2 to LDFLAGS (that helped when arm had issues with atomic symbols), but that does not make a difference in this case

@Grimler91
Copy link
Member Author

@thunder-coding

So I guess this is an upstream issue and will be likely fixed in future NDK versions

If we or someone else report the issue, then probably yes :)

Our libcompiler-rt has the symbols but NDK's doesn't, so probably we need to report this upstream

Would be nice to have a smaller code example that reproduces the issue when reporting in any case

Also, I wonder why build with Cmake succeeds while with autotools, it gives this error. This is worth investigating

It is pretty exciting :)

@xtkoba
Copy link
Contributor

xtkoba commented Nov 22, 2021

One possibility is that some shared library that is used when lding accidentally defines the symbol as not HIDDEN

The NDK toolchain by default makes links against libdl.so and libc.so for C, and additionally against libc++_shared.so and libm.so for C++. I meant that those libraries that are used by ld might define __extendsftf2 with non-HIDDEN visibility.

Do you know of a way to check the status of the symbol? On aarch64 we have

$ nm -D $PREFIX/lib/graphviz/libgvplugin_neato_layout.so | grep __extend
                 U __extendsftf2

I use readelf:

$ readelf -Wa $_LIBCLANG_RT_DIR/libclang_rt.builtins-aarch64-android.a | grep " FUNC .* __extend"
     7: 0000000000000000   172 FUNC    GLOBAL HIDDEN     4 __extenddftf2
     7: 0000000000000000   180 FUNC    GLOBAL HIDDEN     4 __extendhftf2
     7: 0000000000000000   184 FUNC    GLOBAL HIDDEN     4 __extendsftf2
     7: 0000000000000000   168 FUNC    GLOBAL HIDDEN     4 __extendsfdf2
     9: 0000000000000000   136 FUNC    GLOBAL HIDDEN     4 __extendhfsf2

As for a resulted executable or shared library, when compiler-rt is correctly used, we will see:

$ readelf -Wa a.out | grep " FUNC .* __extend"
    30: 000000000000165c   184 FUNC    LOCAL  HIDDEN    12 __extendsftf2

whereas for a case something is wrong, we will see UND in the index column:

$ readelf -Wa a.out | grep " FUNC .* __extend"
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __extendsftf2
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __extendsftf2

Symbols that are UNDefined must be resolved at runtime by other shared libraries. Execution (or dlopen) fails if it cannot.

but on arm extendsftf2 isn't used at all (it isn't referenced in either $PREFIX/lib/graphviz/libgvplugin_neato_layout.so or $PREFIX/lib/clang/13.0.0/lib/android/libclang_rt.builtins-aarch64-android.a).

These builtins are arch-specific. It is just that __extendsftf2 is used in aarch64 and x86_64 and not in arm or i686.

I tried adding -u__extendsftf2 to LDFLAGS (that helped when arm had issues with atomic symbols), but that does not make a difference in this case

A possible workaround would be to include $PREFIX/lib/clang/13.0.0/lib/android/libclang_rt.builtins-aarch64-android.a in LDFLAGS. Note that the position matters. I recommend prepending it.

@finagolfin
Copy link
Member

One possibility is that some shared library that is used when lding accidentally defines the symbol as not HIDDEN, resolving the reference without the definition from static compiler-rt builtin library. If the shared library of the same name that is used when executing does not have that symbol (or has it as HIDDEN), then the reference cannot be resolved.

Yep, that could be it.

Another possibility is that in switching to the completely binutils-free toolchain in NDK 23, configure no longer picks up a needed library like libm or libcompiler-rt properly.

A good way to debug would be to check out the last commit of this repo before the NDK 23 pull was merged and build a now-broken package like graphviz with NDK 21d instead, extracting the working linker command it puts out for gvpack. Then, compare that command to the broken one now and see what the difference is.

@Grimler91
Copy link
Member Author

Grimler91 commented Nov 23, 2021

Building with ndk r21 gvpack works, we have

~ $ nm -D $PREFIX/lib/graphviz/libgvplugin_neato_layout.so | grep __extend
0000000000062ff4 T __extendsftf2

I guess it is the link command for libgvplugin_neato_layout.so that is interesting, since the missing symbol is there. Stuff below is with CC="<..>-clang --verbose" CXX="<..>-clang++ --verbose", maybe I need to add --verbose to LD as well (testing now)

Diff between r21 and r23 is:

$ diff -u graphviz_ndk-r21.link graphviz_ndk-r23.link 
--- graphviz_ndk-r21.link	2021-11-23 12:09:16.950560583 +0100
+++ graphviz_ndk-r23.link	2021-11-23 12:09:13.713886886 +0100
@@ -4,7 +4,7 @@
 -DPIC \
 -shared \
 -nostdlib \
-/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_so.o \
+/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_so.o \
 .libs/gvplugin_neato_layout.o \
 .libs/gvlayout_neato_layout.o \
 -Wl,--whole-archive \
@@ -28,19 +28,17 @@
 ../../lib/cgraph/.libs/libcgraph.so \
 ../../lib/cdt/.libs/libcdt.so \
 ../../lib/pathplan/.libs/libpathplan.so \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/lib64/clang/9.0.8/lib/linux/aarch64 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib/../lib64 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/lib64/clang/12.0.8/lib/linux/aarch64 \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../lib/gcc/aarch64-linux-android/4.9.x \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib \
 -lc++ \
 -lm \
 -lc \
--lgcc \
+-l:libunwind.a \
 -ldl \
-/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtend_so.o \
+/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtend_so.o \
 -fstack-protector-strong \
 -Oz \
 -Wl,-rpath=/data/data/com.termux/files/usr/lib \
Full command with r23
aarch64-linux-android-clang++ \
--verbose \
-fPIC \
-DPIC \
-shared \
-nostdlib \
/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_so.o \
.libs/gvplugin_neato_layout.o \
.libs/gvlayout_neato_layout.o \
-Wl,--whole-archive \
../../lib/neatogen/.libs/libneatogen_C.a \
../../lib/twopigen/.libs/libtwopigen_C.a \
../../lib/patchwork/.libs/libpatchwork_C.a \
../../lib/osage/.libs/libosage_C.a \
../../lib/fdpgen/.libs/libfdpgen_C.a \
../../lib/sparse/.libs/libsparse_C.a \
../../lib/rbtree/.libs/librbtree_C.a \
../../lib/circogen/.libs/libcircogen_C.a \
../../lib/sfdpgen/.libs/libsfdpgen_C.a \
../../lib/vpsc/.libs/libvpsc_C.a \
-Wl,--no-whole-archive \
-L/home/builder/.termux-build/graphviz/src/lib/gvc/.libs \
-L/home/builder/.termux-build/graphviz/src/lib/cgraph/.libs \
-L/home/builder/.termux-build/graphviz/src/lib/cdt/.libs \
-L/home/builder/.termux-build/graphviz/src/lib/pathplan/.libs \
-L/data/data/com.termux/files/usr/lib \
../../lib/gvc/.libs/libgvc.so \
../../lib/cgraph/.libs/libcgraph.so \
../../lib/cdt/.libs/libcdt.so \
../../lib/pathplan/.libs/libpathplan.so \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/lib64/clang/12.0.8/lib/linux/aarch64 \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../lib/gcc/aarch64-linux-android/4.9.x \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib \
-lc++ \
-lm \
-lc \
-l:libunwind.a \
-ldl \
/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtend_so.o \
-fstack-protector-strong \
-Oz \
-Wl,-rpath=/data/data/com.termux/files/usr/lib \
-fopenmp \
-static-openmp \
-Wl,--enable-new-dtags \
-Wl,--as-needed \
-Wl,-z \
-Wl,relro \
-Wl,-z \
-Wl,now \
-fopenmp \
-Wl,-soname \
-Wl,libgvplugin_neato_layout.so \
-o \
.libs/libgvplugin_neato_layout.so

Full config.log and build logs for r21 and r23 are attached:
graphviz_ndk-r21_verbose.log
graphviz_ndk-r21_verbose_config.log
graphviz_ndk-r23_verbose.log
graphviz_ndk-r23_verbose_config.log

@Grimler91
Copy link
Member Author

Grimler91 commented Nov 23, 2021

Discard previous comment, here is the full link command:

Diff:

--- neato_layout_verbose_r21.log	2021-11-23 13:40:37.521566069 +0100
+++ neato_layout_verbose_r23.log	2021-11-23 13:41:09.604802803 +0100
@@ -1,4 +1,4 @@
-"/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld" \
+"/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/ld" \
 -z \
 noexecstack \
 -EL \
@@ -11,29 +11,28 @@
 -z \
 max-page-size=4096 \
 --hash-style=gnu \
---hash-style=both \
 --enable-new-dtags \
 --eh-frame-hdr \
 -m \
 aarch64linux \
 -shared \
 -o .libs/libgvplugin_neato_layout.so \
+-L/home/builder/.termux-build/graphviz/src/lib/gvc/.libs \
+-L/home/builder/.termux-build/graphviz/src/lib/cgraph/.libs \
+-L/home/builder/.termux-build/graphviz/src/lib/cdt/.libs \
+-L/home/builder/.termux-build/graphviz/src/lib/pathplan/.libs \
 -L/data/data/com.termux/files/usr/lib \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/lib64/clang/9.0.8/lib/linux/aarch64 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib/../lib64 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/lib64/clang/9.0.8/lib/linux/aarch64 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib/../lib64 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/lib \
--L/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib \
-/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_so.o \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/lib64/clang/12.0.8/lib/linux/aarch64 \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../lib/gcc/aarch64-linux-android/4.9.x \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/lib64/clang/12.0.8/lib/linux/aarch64 \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../lib/gcc/aarch64-linux-android/4.9.x \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android \
+-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib \
+/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_so.o \
 .libs/gvplugin_neato_layout.o \
 .libs/gvlayout_neato_layout.o \
 --whole-archive \
@@ -48,16 +47,16 @@
 ../../lib/sfdpgen/.libs/libsfdpgen_C.a \
 ../../lib/vpsc/.libs/libvpsc_C.a \
 --no-whole-archive \
--lgvc \
--lcgraph \
--lcdt \
--lpathplan \
+../../lib/gvc/.libs/libgvc.so \
+../../lib/cgraph/.libs/libcgraph.so \
+../../lib/cdt/.libs/libcdt.so \
+../../lib/pathplan/.libs/libpathplan.so \
 -lc++ \
 -lm \
 -lc \
--lgcc \
+-l:libunwind.a \
 -ldl \
-/home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtend_so.o \
+/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtend_so.o \
 -rpath=/data/data/com.termux/files/usr/lib \
 --enable-new-dtags \
 --as-needed \

Most suspicious is probably the missing --hash-style=both \ for ndk r23.

Full command with r23
"/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/ld" \
-z \
noexecstack \
-EL \
--fix-cortex-a53-843419 \
--warn-shared-textrel \
-z \
now \
-z \
relro \
-z \
max-page-size=4096 \
--hash-style=gnu \
--enable-new-dtags \
--eh-frame-hdr \
-m \
aarch64linux \
-shared \
-o .libs/libgvplugin_neato_layout.so \
-L/home/builder/.termux-build/graphviz/src/lib/gvc/.libs \
-L/home/builder/.termux-build/graphviz/src/lib/cgraph/.libs \
-L/home/builder/.termux-build/graphviz/src/lib/cdt/.libs \
-L/home/builder/.termux-build/graphviz/src/lib/pathplan/.libs \
-L/data/data/com.termux/files/usr/lib \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/lib64/clang/12.0.8/lib/linux/aarch64 \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../lib/gcc/aarch64-linux-android/4.9.x \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/lib64/clang/12.0.8/lib/linux/aarch64 \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../lib/gcc/aarch64-linux-android/4.9.x \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android \
-L/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib \
/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_so.o \
.libs/gvplugin_neato_layout.o \
.libs/gvlayout_neato_layout.o \
--whole-archive \
../../lib/neatogen/.libs/libneatogen_C.a \
../../lib/twopigen/.libs/libtwopigen_C.a \
../../lib/patchwork/.libs/libpatchwork_C.a \
../../lib/osage/.libs/libosage_C.a \
../../lib/fdpgen/.libs/libfdpgen_C.a \
../../lib/sparse/.libs/libsparse_C.a \
../../lib/rbtree/.libs/librbtree_C.a \
../../lib/circogen/.libs/libcircogen_C.a \
../../lib/sfdpgen/.libs/libsfdpgen_C.a \
../../lib/vpsc/.libs/libvpsc_C.a \
--no-whole-archive \
../../lib/gvc/.libs/libgvc.so \
../../lib/cgraph/.libs/libcgraph.so \
../../lib/cdt/.libs/libcdt.so \
../../lib/pathplan/.libs/libpathplan.so \
-lc++ \
-lm \
-lc \
-l:libunwind.a \
-ldl \
/home/builder/.termux-build/_cache/android-r23b-api-24-v2/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtend_so.o \
-rpath=/data/data/com.termux/files/usr/lib \
--enable-new-dtags \
--as-needed \
-z \
relro \
-z \
now \
-soname \
libgvplugin_neato_layout.so

Full build log and config.log:
grapviz_ndk-r21_config.log
grapviz_ndk-r23_build.log
grapviz_ndk-r23_config.log
grapviz_ndk-r21_build.log

@xtkoba
Copy link
Contributor

xtkoba commented Nov 23, 2021

-lgcc is specified in NDK r21d, whereas in r23b it is not, and compiler-rt builtins library (libclang_rt.builtins-${target}.a) is not linked against either.

I guess builtins library is not linked against because -nostdlib is specified.

@xtkoba
Copy link
Contributor

xtkoba commented Nov 23, 2021

Seems to be more than 20-year-old bug(?) in libtool: https://gcc.gnu.org/legacy-ml/gcc/2001-09/msg00262.html

@finagolfin
Copy link
Member

finagolfin commented Nov 23, 2021

Yeah, that's the problem: libtool supplying all the link flags to the compiler and overriding the runtime library the compiler chooses with -nostdlib. Maybe it needs to be patched to add compiler-rt instead of libgcc, but in the meantime, perhaps we could override it by passing in the -rtlib=compiler-rt flag for those packages, as I did with the Swift CMake config.

@xtkoba
Copy link
Contributor

xtkoba commented Nov 23, 2021

This may work:

termux_step_pre_configure() {
	LDFLAGS+=" $($CC -print-libgcc-file-name)"
}

@Grimler91
Copy link
Member Author

@buttaface @xtkoba thanks, LDFLAGS+=" $($CC -print-libgcc-file-name)" works, but adding -rtlib=compiler-rt to LDFLAGS doesn't seem to have an effect. It is included in the link command, and there is no warning about unknown argument or similar. Passing -Wl,-rtlib=compiler-rt instead makes the configure c compiler test fail with ld: error: unknown argument '-rtlib=compiler-rt'.

In any case, I'll create a minimal example and open an issue with the ndk to see what the best solution would be, and for what arches we might need it.

@xtkoba xtkoba removed the not stale label Dec 24, 2022
@alensiljak
Copy link

Getting the same error when cargo install-ing a package that contains libsqlite3-sys (I suspect. sqlite3.o:(sqlite3_str_vappendf)).

@xtkoba
Copy link
Contributor

xtkoba commented Jan 2, 2023

@alensiljak Similar but different: build failure (the Rust/Cargo case) vs. runtime error (discussed here; which is nastier).

FWIW, we already have a workaround for the Rust/Cargo case:

RUSTFLAGS+=" -C link-arg=$($CC -print-libgcc-file-name)"

@krmanik
Copy link

krmanik commented Jan 20, 2023

Tried to build Anki for Termux on android using recently added packages pyqt5 and pyqtwebwngine.
https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583

Getting following errors

ImportError: dlopen failed: cannot locate symbol "__extenddftf2" referenced by "/data/data/com.termux/files/home/anki/out/rust/debug/librsbridge.so"...
~/anki $ ./run
Finished dev [unoptimized + debuginfo] target(s) in 2.36s
[26/26; 1 active; 115.654s] qt/aqt:data/web/js
Build succeeded.
Traceback (most recent call last):
File "/data/data/com.termux/files/home/anki/tools/run.py", line 9, in <module>
import aqt
File "/data/data/com.termux/files/home/anki/qt/aqt/__init__.py", line 40, in <module>
import anki.lang
File "/data/data/com.termux/files/home/anki/pylib/anki/lang.py", line 12, in <module>
import anki._backend
File "/data/data/com.termux/files/home/anki/pylib/anki/_backend.py", line 14, in <module>
from anki import _rsbridge, backend_pb2, i18n_pb2
ImportError: dlopen failed: cannot locate symbol "__extenddftf2" referenced by "/data/data/com.termux/files/home/anki/out/rust/debug/librsbridge.so"...

@xtkoba
Copy link
Contributor

xtkoba commented Jan 20, 2023

@krmanik Please migrate to #14576.

@silent-rain
Copy link

RUSTFLAGS+= " -C link-arg= $( $CC -print-libgcc-file-name ) " 这个参数相当有用,添加后可以通过编译

@stale stale bot removed the inactive No activity in a certain period of time label Apr 13, 2023
@2096779623

This comment was marked as off-topic.

@stale stale bot added the inactive No activity in a certain period of time label Jun 27, 2023
@xtkoba xtkoba added tracker and removed bug report Something is not working properly inactive No activity in a certain period of time labels Jun 27, 2023
@xtkoba
Copy link
Contributor

xtkoba commented Jun 27, 2023

Converted to tracker. Keeping open until at least well documented in other places. Only for libtool + C++ + shared lib. Workaround already provided.

@twaik
Copy link
Member

twaik commented Oct 19, 2024

Should we keep this issue opened or we should close it in prior to #21130?

@twaik
Copy link
Member

twaik commented Oct 22, 2024

Since there is no activity I am closing this.
Superseded by #21130.

@Biswa96
Copy link
Member

Biswa96 commented Nov 10, 2024

This may work:

termux_step_pre_configure() {
	LDFLAGS+=" $($CC -print-libgcc-file-name)"
}

The above workaround produces warning with libtool/autotools. Please try to use the workaround from this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants