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]: Failed to build package 'coreutils' #21113

Closed
gouravkhunger opened this issue Aug 13, 2024 · 11 comments · Fixed by #21120
Closed

[Bug]: Failed to build package 'coreutils' #21113

gouravkhunger opened this issue Aug 13, 2024 · 11 comments · Fixed by #21120
Labels
bug report Something is not working properly

Comments

@gouravkhunger
Copy link
Contributor

gouravkhunger commented Aug 13, 2024

Problem description

Since the NDK was bumped to version 27, compiling coreutils gives this error

...
  CC       lib/libcoreutils_a-nstrftime.o
  CC       lib/libcoreutils_a-obstack.o
  CC       lib/libcoreutils_a-openat-die.o
  CC       lib/libcoreutils_a-openat-safer.o
In file included from /home/builder/.termux-build/coreutils/src/lib/nstrftime.c:19:
/home/builder/.termux-build/coreutils/src/lib/strftime.c:1725:17: error: call to undeclared function 'mktime_z'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 1725 |             t = mktime_z (tz, &ltm);
      |                 ^
/home/builder/.termux-build/coreutils/src/lib/strftime.c:1725:17: note: did you mean 'mktime'?
/home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/include/time.h:159:8: note: 'mktime' declared here
  159 | time_t mktime(struct tm* _Nonnull __tm);
      |        ^
1 error generated.
make[2]: *** [Makefile:16274: lib/libcoreutils_a-nstrftime.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make[1]: *** [Makefile:22447: all-recursive] Error 1
make[1]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make: *** [Makefile:8865: all] Error 2
Failed to build package 'coreutils' for arch 'aarch64'
[*] Building 'coreutils' exited with exit code 2
Error: Process completed with exit code 2.

What steps will reproduce the bug?

coreutils should be in PACKAGES in build-bootstraps.sh:

./scripts/run-docker.sh ./clean.sh
./scripts/run-docker.sh ./scripts/build-bootstraps.sh --android10

What is the expected behavior?

No response

System information

N/A
@gouravkhunger gouravkhunger added bug report Something is not working properly untriaged labels Aug 13, 2024
@Biswa96 Biswa96 removed the untriaged label Aug 13, 2024
@Biswa96
Copy link
Member

Biswa96 commented Aug 13, 2024

For testing purposes, the compiler error could be workaround with adding -Wno-implicit-function-declaration in compiler flags. I would discourage to add this workaround within actual package.

@TomJo2000
Copy link
Member

We might need another tracker like #20966, for NDK 27.

@truboxl would you be available to run another set of build tests, or could you elaborate on how you did the tests for the NDK 26b build problem tracker?

@licy183
Copy link
Member

licy183 commented Aug 14, 2024

timezone_t is declared in time.h since NDK 27, but mktime_z is introduced in Android API 35. coreutils checks timezone_t and assumes mktime_z exists. Setting ac_cv_type_timezone_t=no in EXTRA_CONFIGURE_ARGS should resolve this issue.

Emmm... I'll investigate it.

@gouravkhunger
Copy link
Contributor Author

gouravkhunger commented Aug 14, 2024

@Biswa96 Using -Wno-implicit-function-declaration:

  CC       src/libsinglebin_cut_a-cut.o
  CC       src/libsinglebin_date_a-date.o
  CC       src/libsinglebin_dd_a-dd.o
  CC       src/libsinglebin_dir_a-coreutils-dir.o
/home/builder/.termux-build/coreutils/src/src/date.c:578:14: error: incompatible integer to pointer conversion initializing 'timezone_t' (aka 'struct __timezone_t *') with an expression of type 'int' [-Wint-conversion]
  578 |   timezo  CC       src/libsinglebin_ls_a-ls.o
ne_t tz = tzalloc (tzstring);
      |              ^    ~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [Makefile:20152: src/libsinglebin_date_a-date.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/builder/.termux-build/coreutils/src/src/ls.c:1727:11: error: incompatible integer to pointer conversion assigning to 'timezone_t' (aka 'struct __timezone_t *') from 'int' [-Wint-conversion]
 1727 |   localtz = tzalloc (getenv ("TZ"));
      |           ^ ~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [Makefile:20698: src/libsinglebin_ls_a-ls.o] Error 1
make[2]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make[1]: *** [Makefile:22447: all-recursive] Error 1
make[1]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make: *** [Makefile:8865: all] Error 2
Failed to build package 'coreutils' for arch 'arm'
[*] Building 'coreutils' exited with exit code 2
Error: Process completed with exit code 2.

And -Wno-int-conversion:

  AR       src/libsinglebin_b2sum.a
  AR       src/libsinglebin_chgrp.a
  AR       src/libsinglebin_dir.a
  CCLD     src/coreutils
ld.lld: error: undefined symbol: localtime_rz
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced 7 more times
>>> did you mean: localtime_r
>>> defined in: /home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/lib/arm-linux-androideabi/24/libc.so

ld.lld: error: undefined symbol: tzfree
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime) in archive lib/libcoreutils.a

ld.lld: error: undefined symbol: tzalloc
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime) in archive lib/libcoreutils.a
>>> referenced 5 more times

ld.lld: error: undefined symbol: mktime_z
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced by parse-datetime.c
>>>               libcoreutils_a-parse-datetime.o:(parse_datetime_body) in archive lib/libcoreutils.a
>>> referenced 3 more times
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Makefile:11116: src/coreutils] Error 1
make[2]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make[1]: *** [Makefile:22447: all-recursive] Error 1
make[1]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make: *** [Makefile:8865: all] Error 2
Failed to build package 'coreutils' for arch 'arm'
[*] Building 'coreutils' exited with exit code 2
Error: Process completed with exit code 2.

@TheNewHEROBRINEX
Copy link

The tar package seems to be affected by the same problem.

@gouravkhunger
Copy link
Contributor Author

@licy183 If it is any helpful, this is the output when setting ac_cv_type_timezone_t=no:

  CC       lib/libcoreutils_a-long-options.o
  CC       lib/libcoreutils_a-malloca.o
  CC       lib/libcoreutils_a-math.o
  CC       lib/libcoreutils_a-mbrlen.o
In file included from /home/builder/.termux-build/coreutils/src/lib/malloca.cIn file included from /home/builder/.termux-build/coreutils/src/lib/long-options.c:27:
In file included from ./lib/stdio.h:95:
In file included from ./lib/sys/stat.h:51:
./lib/time.h:998:25: error: typedef redefinition with different types ('struct tm_zone *' vs 'struct __timezone_t *')
  998 | typedef struct tm_zone *timezone_t;
      |                         ^
/home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/include/time.h:52:30: note: previous definition is here
   52 | typedef struct __timezone_t* timezone_t;
      |                              ^
:22:
In file included from /home/builder/.termux-build/coreutils/src/lib/malloca.h:29:
In file included from ./lib/stdlib.h:36:
In file included from /home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/include/stdlib.h:34:
In file included from /home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/include/malloc.h:30:
In file included from ./lib/stdio.h:95:
In file included from ./lib/sys/stat.h:51:
./lib/time.h:998:25: error: typedef redefinition with different types ('struct tm_zone *' vs 'struct __timezone_t *')
  998 | typedef struct tm_zone *timezone_t;
      |                         ^
/home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/include/time.h:52:30: note: previous definition is here
   52 | typedef struct __time1 error generated.
zone_t* timezone_t;
      |                              ^
make[2]: *** [Makefile:15616: lib/libcoreutils_a-long-options.o] Error 1
make[2]: *** Waiting for unfinished jobs....
1 error generated.
In file included from /home/builder/.termux-build/coreutils/src/lib/mbrlen.c:21:
In file included from ./lib/wchar.h:80:
In file included from /home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/include/wchar.h:33:
In file included from ./lib/stdio.h:95:
In file included from ./lib/sys/stat.h:51:
./lib/time.h:998:25: error: typedef redefinition with different types ('struct tm_zone *' vs 'struct __timezone_t *')
  998 | typedef struct tm_zone *timezone_t;
      |                         ^
/home/builder/.termux-build/_cache/android-r27-api-24-v0/bin/../sysroot/usr/include/time.h:52:30: note: previous definition is here
   52 | typedef struct __timezone_t* timezone_t;
      |                              ^
make[2]: *** [Makefile:15658: lib/libcoreutils_a-malloca.o] Error 1
1 error generated.
make[2]: *** [Makefile:15686: lib/libcoreutils_a-mbrlen.o] Error 1
make[3]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make[2]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make[1]: *** [Makefile:22447: all-recursive] Error 1
make[1]: Leaving directory '/home/builder/.termux-build/coreutils/build'
make: *** [Makefile:8865: all] Error 2
Failed to build package 'coreutils' for arch 'aarch64'
[*] Building 'coreutils' exited with exit code 2
Error: Process completed with exit code 2.

@Biswa96
Copy link
Member

Biswa96 commented Aug 14, 2024

The tar package seems to be affected by the same problem.

The similar issue probably affects any program that uses gnulib. I have applied a workaround in gnulib's time.in.h as following.

@@ -997,6 +916,9 @@
    (timezone_t) NULL stands for UTC.  */
 typedef struct tm_zone *timezone_t;
 
+#endif
+
+#if __ANDROID_API__ < 35
 /* tzalloc (name)
    Returns a time zone object for the given time zone NAME.  This object
    represents the time zone that other functions would use it the TZ

But that workaround need to be done in every package. Also, it needs changes in autotools file to compile the actual function definition in time_rz.c. Another workaround would be to implement the time functions in NDK. The required functions are - tzalloc, tzfree, localtime_rz, mktime_z.

@truboxl
Copy link
Contributor

truboxl commented Aug 14, 2024

@TomJo2000 I use GitHub Actions to bulk test building packages

@licy183
Copy link
Member

licy183 commented Aug 14, 2024

Maybe we should patching sysroot and drop the declaration of timezone_t.

@Grimler91
Copy link
Member

The similar issue probably affects any program that uses gnulib. I have applied a workaround in gnulib's time.in.h as following.

Does gnulib's time.in.h need to be patched also after proposed toolchain patch in #21120?

@Biswa96
Copy link
Member

Biswa96 commented Aug 14, 2024

Does gnulib's time.in.h need to be patched also after proposed toolchain patch in #21120?

No. That toolchain patch already hides timezone_t. So, gnulib will use its own stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants