Commit a0622550 authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Treehugger Robot
Browse files

ANDROID: tools/resolve_btfids: Pass CFLAGS to libsubcmd build via EXTRA_CFLAGS

When building using kleaf on an host distribution with glibc 2.38 or later,
there is a linkage failure when building resolve_btfids:

  ld.lld: error: undefined symbol: __isoc23_strtol
  >>> referenced by stdlib.h:483 (/usr/include/stdlib.h:483)
  >>>               libsubcmd-in.o:(pretty_print_string_list) in archive .../libsubcmd.a
  >>> referenced by stdlib.h:483 (/usr/include/stdlib.h:483)
  >>>               libsubcmd-in.o:(pretty_print_string_list) in archive .../libsubcmd.a
  >>> referenced by stdlib.h:483 (/usr/include/stdlib.h:483)
  >>>               libsubcmd-in.o:(pager_get_columns) in archive .../libsubcmd.a
  >>> referenced 2 more times

  ld.lld: error: undefined symbol: __isoc23_strtoul
  >>> referenced by parse-options.c:314 (.../tools/lib/subcmd/parse-options.c:314)
  >>>               libsubcmd-in.o:(get_value) in archive .../libsubcmd.a

  ld.lld: error: undefined symbol: __isoc23_strtoull
  >>> referenced by parse-options.c:332 (.../tools/lib/subcmd/parse-options.c:332)
  >>>               libsubcmd-in.o:(get_value) in archive .../libsubcmd.a
  clang-17: error: linker command failed with exit code 1 (use -v to see invocation)

These errors imply that the files were build against glibc 2.38 headers
but attempted to be linked with an older glibc version.

Building with '--debug_make_verbosity=D' reveals that the libsubcmd
object files are not built with the additional HOSTCFLAGS the Android
build system provides for a hermetic build (namely '-I' for .c files),
so they build against the system's headers but link against Android's
glibc 2.17, resulting in the error above.

This is not an issue upstream after
commit 13e07691 ("tools/resolve_btfids: Alter how HOSTCC is
forced"), as HOST_OVERRIDES (which contains HOSTCFLAGS via EXTRA_CFLAGS)
is passed along to libsubcmd. That change is quite invasive as a
backport for 5.15 and earlier. As a miminal fix, pass CFLAGS (which
contains HOSTCFLAGS via KBUILD_HOSTCFLAGS) to the libsubcmd build via
EXTRA_CFLAGS, which really should have been done upstream in
commit 0e3a1c90 ("tools/resolve_btfids: Build with host flags"),
which is present in this branch as commit 9e332a14 ("FROMGIT:
tools/resolve_btfids: Build with host flags").

Bug: 301145081
Change-Id: I91c1c9a8fb8f83118a6b8ec4da6cc33a773f2124
Fixes: 368cd631 ("FROMGIT: tools/resolve_btfids: Build with host flags")
Link: https://github.com/ClangBuiltLinux/linux/issues/1929


Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
parent 4aee33cb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment