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

Update ndk to r22 #6174

Closed
wants to merge 10 commits into from
Closed

Update ndk to r22 #6174

wants to merge 10 commits into from

Conversation

Grimler91
Copy link
Member

@Grimler91 Grimler91 commented Dec 24, 2020

Issues:

Trying to build any go package gives:

# runtime/cgo
ld: error: duplicate symbol: x_cgo_inittls
>>> defined at gcc_android.c
>>>            $WORK/b064/_x003.o:(x_cgo_inittls)
>>> defined at gcc_linux_arm64.c
>>>            $WORK/b064/_x006.o:(.bss+0x8)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Which is reported here in the golang repo: golang/go#42655

@Grimler91 Grimler91 added the WIP Work in progress, do not close the issue (PR) label Dec 24, 2020
@Grimler91 Grimler91 marked this pull request as draft December 24, 2020 09:28
@Grimler91
Copy link
Member Author

Grimler91 commented Dec 24, 2020

bitcoin, dash, ed (and probably a few others) fails with:

In file included from compat/stdin.cpp:15:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/termios.h:154:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/android/legacy_termios_inlines.h:43:
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/bits/termios_inlines.h:120:10: error: duplicate case value '0'
    case TCSAFLUSH: cmd = TCSETSF; break;
         ^
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/asm-generic/termbits.h:194:19: note: expanded from macro 'TCSAFLUSH'
#define TCSAFLUSH 0
                  ^
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/bits/termios_inlines.h:118:10: note: previous case defined here
    case TCSANOW: cmd = TCSETS; break;
         ^
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/asm-generic/termbits.h:191:17: note: expanded from macro 'TCSANOW'
#define TCSANOW 0
                ^
1 error generated.
make[2]: *** [Makefile:9837: compat/libbitcoin_cli_a-stdin.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:17262: all-recursive] Error 1
make: *** [Makefile:780: all-recursive] Error 1

Deleting the asm-generic-termbits.h.patch makes the builds work. We added that patch to solve this issue: #1359.

@Grimler91
Copy link
Member Author

Grimler91 commented Dec 24, 2020

dns2tcp, heyu and sharutils fails with this type of error

ld: error: duplicate symbol: debug
>>> defined at rr.c
>>>            rr.o:(debug)
>>> defined at main.c
>>>            main.o:(.bss+0x0)

@Grimler91
Copy link
Member Author

libtirpc needs autoreconf -vfi, and after adding that it fails with

/storage/termux-build/libtirpc/src/src/clnt_bcast.c:72:10: warning: 'POLLRDNORM' macro redefined [-Wmacro-redefined]
# define POLLRDNORM     0x040           /* Normal data may be read.  */
         ^
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/asm-generic/poll.h:27:9: note: previous definition is here
#define POLLRDNORM 0x0040
        ^
/storage/termux-build/libtirpc/src/src/clnt_bcast.c:73:10: warning: 'POLLRDBAND' macro redefined [-Wmacro-redefined]
# define POLLRDBAND     0x080           /* Priority data may be read.  */
         ^
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/asm-generic/poll.h:28:9: note: previous definition is here
#define POLLRDBAND 0x0080
        ^
2 warnings generated.
/storage/termux-build/libtirpc/src/src/svc.c:634:12: error: conflicting types for 'ffsl'
static int ffsl(int i)
           ^
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/strings.h:92:29: note: previous definition is here
__BIONIC_STRINGS_INLINE int ffsl(long __n) {
                            ^
1 error generated.
make[2]: *** [Makefile:889: libtirpc_la-svc.lo] Error 1

@ghost
Copy link

ghost commented Dec 24, 2020

error: conflicting types for 'ffsl'

Probably ffsl-func.patch is not needed anymore.

@Grimler91
Copy link
Member Author

@xeffyr yes, removing that patch makes the build succeed.

Libwren fails with:

Linking wren_shared
ld: error: --fix-cortex-a53-843419 is only supported on AArch64 targets
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [wren_shared.make:122: ../../lib/libwren.so] Error 1
make: *** [Makefile:60: wren_shared] Error 2

@tmm1
Copy link

tmm1 commented Dec 25, 2020

golang packages fails with error: duplicate symbol: x_cgo_inittls
dns2tcp fails with: duplicate symbol: debug
similar error for heyu: duplicate symbol: newsb

I wonder if this is worth reporting up to https://github.com/android/ndk

@Grimler91
Copy link
Member Author

Grimler91 commented Dec 25, 2020

@tmm1 thanks, you might want to include more information in that bug report, see the bug report template: https://github.com/android/ndk/blob/master/.github/ISSUE_TEMPLATE/bug-report.md. Specifically a small test case for reproducing the problem is useful

@Grimler91
Copy link
Member Author

Libdispatch fails with

In file included from /storage/termux-build/libdispatch/src/src/block.cpp:31:
In file included from /storage/termux-build/libdispatch/src/src/internal.h:666:
In file included from /storage/termux-build/libdispatch/src/src/shims.h:220:
In file included from /storage/termux-build/libdispatch/src/src/shims/atomic.h:38:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/lib64/clang/11.0.5/include/stdatomic.h:45:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/atomic:550:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/__threading_support:14:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/chrono:829:
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/ratio:97:1: error: templates must have C++ linkage
template <intmax_t _Xp, intmax_t _Yp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/storage/termux-build/libdispatch/src/src/internal.h:323:1: note: extern "C" language linkage specification begins here
__BEGIN_DECLS
^
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/sys/cdefs.h:46:23: note: expanded from macro '__BEGIN_DECLS'
#define __BEGIN_DECLS extern "C" {
                      ^
In file included from /storage/termux-build/libdispatch/src/src/block.cpp:31:
In file included from /storage/termux-build/libdispatch/src/src/internal.h:666:
In file included from /storage/termux-build/libdispatch/src/src/shims.h:220:
In file included from /storage/termux-build/libdispatch/src/src/shims/atomic.h:38:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/lib64/clang/11.0.5/include/stdatomic.h:45:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/atomic:550:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/__threading_support:14:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/chrono:829:
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/ratio:104:8: error: no template named '__static_gcd'; did you mean '__static_max'?
struct __static_gcd<_Xp, 0>
       ^
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/type_traits:2090:8: note: '__static_max' declared here
struct __static_max;
       ^
In file included from /storage/termux-build/libdispatch/src/src/block.cpp:31:
In file included from /storage/termux-build/libdispatch/src/src/internal.h:666:
In file included from /storage/termux-build/libdispatch/src/src/shims.h:220:
In file included from /storage/termux-build/libdispatch/src/src/shims/atomic.h:38:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/lib64/clang/11.0.5/include/stdatomic.h:45:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/atomic:550:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/__threading_support:14:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/chrono:829:
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/ratio:110:8: error: no template named '__static_gcd'; did you mean '__static_max'?
struct __static_gcd<0, 0>
       ^
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/type_traits:2090:8: note: '__static_max' declared here
struct __static_max;
       ^
In file included from /storage/termux-build/libdispatch/src/src/block.cpp:31:
In file included from /storage/termux-build/libdispatch/src/src/internal.h:666:
In file included from /storage/termux-build/libdispatch/src/src/shims.h:220:
In file included from /storage/termux-build/libdispatch/src/src/shims/atomic.h:38:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/lib64/clang/11.0.5/include/stdatomic.h:45:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/atomic:550:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/__threading_support:14:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/chrono:829:
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/c++/v1/ratio:117:1: error: templates must have C++ linkage
template <intmax_t _Xp, intmax_t _Yp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/storage/termux-build/libdispatch/src/src/internal.h:323:1: note: extern "C" language linkage specification begins here
__BEGIN_DECLS
^
/storage/termux-build/_cache/android-r22-api-24-v3/sysroot/usr/include/sys/cdefs.h:46:23: note: expanded from macro '__BEGIN_DECLS'
#define __BEGIN_DECLS extern "C" {
                      ^

@Grimler91
Copy link
Member Author

libvpx fails with

[AR] libvpx_g.a
ld: error: relocation R_AARCH64_ADR_PREL_PG_HI21 cannot be used against symbol vpx_codec_vp8_cx_algo; recompile with -fPIC
>>> defined in vp8/vp8_cx_iface.c.o
>>> referenced by vp8_cx_iface.c
>>>               vp8/vp8_cx_iface.c.o:(vpx_codec_vp8_cx)

@finagolfin
Copy link
Member

I'll look into the libdispatch issue, that src/internal.h header clang complains about hasn't been updated since last year so likely an NDK regression.

@Grimler91
Copy link
Member Author

man fails with:

In file included from mdoc_html.c
In file included from eqn_html.c:23:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/ctype.h:39:
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/bits/ctype_inlines.h:81:27: error: static declaration of 'isblank' follows non-static declaration
:23:
In file included from /storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/ctype.h:39:
/storage/termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/bits/ctype_inlines.h:81:27: error: static declaration of 'isblank' follows non-static declaration
__BIONIC_CTYPE_INLINE int isblank(int __ch) {
__BIONIC_CTYPE_INLINE int isblank(int __ch) {
                          ^
In file included from man_html.c                          ^
./config.h:65./config.h::1465:: 14: note: noteprevious declaration is here:
previous declaration is here
extern  int       isblank(int);
extern  int       isblank(int);
                  ^

@Grimler91
Copy link
Member Author

That was all types of failures related to the ndk update encountered during a ./build-all.sh. The duplicate symbol type of error should be fixed somehow before we upgrade to ndk r22 as around 80 packages cannot be built due to it

@landfillbaby
Copy link
Member

landfillbaby commented Dec 28, 2020

the golang issue was fixed just now by @xeffyr so you can check that off the list :)

@finagolfin
Copy link
Member

As noted on the NDK issue, the clang default was changed to -fno-common, so we'll have to change it back manually by adding the -fcommon flag in our NDK build scripts or fix the 80 packages.

@ghost
Copy link

ghost commented Dec 30, 2020

As noted on the NDK issue, the clang default was changed to -fno-common

Should we revert this for clang supplied as Termux package?

@finagolfin
Copy link
Member

I lean towards fixing the packages instead, even though it's more work. Both gcc and clang have switched that flag off by default now, so most packages will have to patch those over time anyway.

@Grimler91
Copy link
Member Author

the golang issue was fixed just now by @xeffyr so you can check that off the list :)

Yeah, it works when building locally on termux now. We also have to patch the downloaded host golang package, or wait for the next release

@finagolfin
Copy link
Member

They recently bumped the LTS NDK to 21e, we should use that for now. I asked and NDK 22 is a rolling release, so maybe we just put this pull off till the next LTS release?

Fixes error
```
In file included from man_html.c:23:
In file included from /home/builder/.termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/ctype.h:39:
/home/builder/.termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/bits/ctype_inlines.h:81:27: error: static declaration of 'isblank' follows non-static declaration
In file included from mdoc_html.c:23:
In file included from /home/builder/.termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/ctype.h:39:
/home/builder/.termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/bits/ctype_inlines.h:81:27: error: __BIONIC_CTYPE_INLINE int isblank(int __ch) {static declaration of 'isblank' follows non-static declaration
```
Fixes error

```
util.c:47:1: error: redefinition of 'swab'
swab (const void *bfrom, void *bto, ssize_t n)
^
/home/builder/.termux-build/_cache/android-r22-api-24-v3/bin/../sysroot/usr/include/bits/swab.h:41:27: note: previous definition is here
__BIONIC_SWAB_INLINE void swab(const void* __void_src, void* __void_dst, ssize_t __byte_count) {
                          ^
1 error generated.
make[3]: *** [/home/builder/.termux-build/netpbm/src/common.mk:272: util.o] Error 1
make[3]: *** Waiting for unfinished jobs....

```
Patch from @buttaface. This commit is responsible:
aosp-mirror/platform_bionic@76e2b15
@@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="System header and library files from the Android NDK nee
TERMUX_PKG_LICENSE="NCSA"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=$TERMUX_NDK_VERSION
TERMUX_PKG_REVISIOM=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typo...here...

@creepy-pasta101
Copy link
Contributor

@Grimler91 I don't know why... but I ran the docker image and running ./scripts/setup-android-sdk.sh gives this error...

Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli

@ghost
Copy link

ghost commented Jun 26, 2021

@suhan-paradkar You can run setup-android-sdk.sh only when Docker image is building. Once image build is about to finish, the cleanup steps are being executed which remove unnecessary components from SDK bundle to shrink the resulting image size.

sdkmanager is no longer functional after that and this is expected behavior. Run rm -rf ~/lib to be able reconfigure Android SDK and NDK installation.

@creepy-pasta101
Copy link
Contributor

Thanks..👍

@finagolfin
Copy link
Member

Heh, Termux will run on the next version of Windows, Windows 11. 😃

@tomty89
Copy link
Contributor

tomty89 commented Jun 28, 2021

@Buttface I hope it won't stop be able to run in Android first, heh, with all the security whatsoever back-and-forth changes that has come / will come...

@creepy-pasta101
Copy link
Contributor

dns2tcp, heyu and sharutils fails with this type of error

ld: error: duplicate symbol: debug
>>> defined at rr.c
>>>            rr.o:(debug)
>>> defined at main.c
>>>            main.o:(.bss+0x0)

This one(if I am not wrong) is again due to -fno-common ...
Removing the line with #include <debug.h> removes the error....
This mostly happens for example.. in this situation...
Lets say there is a file.. a.h , having

#include <c.h>

and a file b.h , having

#include <a.h>
#include <c.h>

This scenario causes the error (correct me if I am wrong)...
Removing the line containing #include <c.h> from the file b.h seems to fix it... or in this case, #include <debug.h> from some of the files

@finagolfin
Copy link
Member

A new LTS NDK was released a couple days ago, NDK 23, we should switch to that.

@Grimler91
Copy link
Member Author

I'll close this and start over from r23

@Grimler91 Grimler91 closed this Aug 16, 2021
@Grimler91 Grimler91 deleted the ndk-r22 branch October 22, 2021 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress, do not close the issue (PR)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants