Hi!

I'm trying to make a custom build for my router and I've got into some
weird thing which I don't understand how it can be working at all.

iproute2 depends on elfutils. elfutils provides several library
packages and one of them is libdwfl. When this libdwfl is compiled
I've got an error in file find-debuginfo.c

The error is regarding the usage of function basename(). Clearly
elfutils expects glibc where this function is declared in <string.h>
and expects const char* as its argument. While musl provides another
weird implementation of basename() declared in <libgen.h> which
expects char* as its argument. So, even adding a patch that adds
#include <libgen.h> doesn't help because the compiler asserts that
const type qualifier is being discarded.

I've looked for the patches in the OpenWRT tree but found nothing on
this topic. What am I missing? How can it be compiled at all with
musl?

This error if compiling as is:

find-debuginfo.c: In function 'find_debuginfo_in_path':
find-debuginfo.c:168:58: error: implicit declaration of function
'basename'; did you mean 'ptsname'?
[-Werror=implicit-function-declaration]
  const char *file_basename = file_name == NULL ? NULL : basename (file_name);
                                                         ^~~~~~~~
                                                         ptsname
find-debuginfo.c:168:56: error: pointer/integer type mismatch in
conditional expression [-Werror]
  const char *file_basename = file_name == NULL ? NULL : basename (file_name);

This error if I add patch to include <libgen.h>

find-debuginfo.c:169:68: error: passing argument 1 of 'basename'
discards 'const' qualifier from pointer target type
[-Werror=discarded-qualifiers]
  const char *file_basename = file_name == NULL ? NULL : basename (file_name);
                                                                   ^~~~~~~~~
In file included from find-debuginfo.c:36:
/src/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-8.3.0_musl/include/libgen.h:9:7:
note: expected 'char *' but argument is of type 'const char *'
char *basename(char *);
      ^~~~~~~~


-- 
With best regards
  Maksim Dmitrichenko

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to