tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] /usr/include/syslog.h:68: error: invalid type #24


From: Steffen Nurpmeso
Subject: Re: [Tinycc-devel] /usr/include/syslog.h:68: error: invalid type #24
Date: Wed, 15 Apr 2020 17:09:09 +0200
User-agent: s-nail v14.9.17-63-g444b76e3

Hello prologic, Michael,

Michael Matz wrote in
<address@hidden>:
 |On Wed, 15 Apr 2020, James Mills wrote:
 |> I am trying to understand this "invalid type" I keep getting when \
 |> trying to
 |> compile software that wants to pull in syslog.h -- e.g: libressl and most
 |> recently I also tried util-linux.
 |> 
 |> You can see the full issue/details
 |> here: https://github.com/prologic/ulinux/issues/24
 |
 |Well, what declaration or type is on syslog.h:68 ?  (Possibly look at 
 |preprocessed output (-E) in case some macro substitution is going on).
 ...
 |> I would appreciate some help understanding this syslog.h "invalid type"
 |> problem. I don't quite get it :) FWIW that line references va_list which
 |
 |... ah, oh, see?  :)  Hmm, so is TCC's stdarg.h really being included, or 
 |is it picking up some other stdarg.h?

On AlpineLinux with musl, at [096c93c], if i add the diff

  diff --git a/lib/Makefile b/lib/Makefile
  index 9d74dc3..cb67731 100644
  --- a/lib/Makefile
  +++ b/lib/Makefile
  @@ -11,7 +11,7 @@ X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
   XTCC ?= $(TOP)/$(X)tcc$(EXESUF)
   XCC = $(XTCC)
   XAR = $(XTCC) -ar
  -XFLAGS-unx = -B$(TOPSRC)
  +XFLAGS-unx = -B$(TOPSRC) -B$(TOPSRC)/include -I$(TOPSRC)/include
   XFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include
   XFLAGS = $(XFLAGS$(XCFG)) -I$(TOP)
   XCFG = $(or $(findstring -win,$T),-unx)
  diff --git a/lib/bt-log.c b/lib/bt-log.c
  index 73e0067..d767f08 100644
  --- a/lib/bt-log.c
  +++ b/lib/bt-log.c
  @@ -1,6 +1,7 @@
   /* ------------------------------------------------------------- */
   /* function to get a stack backtrace on demand with a message */
   
  +#include <stdarg.h>
   #include <stdio.h>
   #include <string.h>

then i get to it, if i also include my patches from 2017

  diff --git a/libtcc.c b/libtcc.c
  index fdbe2e7..73b0b05 100644
  --- a/libtcc.c
  +++ b/libtcc.c
  @@ -922,6 +922,7 @@ LIBTCCAPI TCCState *tcc_new(void)
   # if defined(TCC_MUSL)
       tcc_define_symbol(s, "__DEFINED_va_list", "");
       tcc_define_symbol(s, "__DEFINED___isoc_va_list", "");
  +    tcc_define_symbol(s, "__builtin_va_list", "va_list");
       tcc_define_symbol(s, "__isoc_va_list", "void *");
   # endif /* TCC_MUSL */
       /* Some GCC builtins that are simple to express as macros.  */
  @@ -940,6 +941,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
       dynarray_reset(&s1->crt_paths, &s1->nb_crt_paths);
   
       /* free include paths */
  +    dynarray_reset(&s1->tccinclude_paths, &s1->nb_tccinclude_paths);
       dynarray_reset(&s1->include_paths, &s1->nb_include_paths);
       dynarray_reset(&s1->sysinclude_paths, &s1->nb_sysinclude_paths);
   
  @@ -983,6 +985,7 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int 
output_type)
       if (!s->nostdinc) {
           /* default include paths */
           /* -isystem paths have already been handled */
  +        tcc_add_tccinclude_path(s, CONFIG_TCC_TCCINCLUDEPATHS);
           tcc_add_sysinclude_path(s, CONFIG_TCC_SYSINCLUDEPATHS);
       }
   
  @@ -1020,6 +1023,12 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int 
output_type)
       return 0;
   }
   
  +LIBTCCAPI int tcc_add_tccinclude_path(TCCState *s, const char *pathname)
  +{
  +    tcc_split_path(s, &s->tccinclude_paths, &s->nb_tccinclude_paths, 
pathname);
  +    return 0;
  +}
  +
   LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname)
   {
       tcc_split_path(s, &s->include_paths, &s->nb_include_paths, pathname);
  diff --git a/libtcc.h b/libtcc.h
  index e164f5c..60c87a3 100644
  --- a/libtcc.h
  +++ b/libtcc.h
  @@ -39,6 +39,9 @@ LIBTCCAPI void tcc_set_options(TCCState *s, const char 
*str);
   /*****************************/
   /* preprocessor */
   
  +/* add in tcc include path, searched before anything else */
  +LIBTCCAPI int tcc_add_tccinclude_path(TCCState *s, const char *pathname);
  +
   /* add include path */
   LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
   
  diff --git a/tcc.c b/tcc.c
  index 34bfa00..fed6dc2 100644
  --- a/tcc.c
  +++ b/tcc.c
  @@ -183,6 +183,7 @@ static void print_search_dirs(TCCState *s)
   {
       printf("install: %s\n", s->tcc_lib_path);
       /* print_dirs("programs", NULL, 0); */
  +    print_dirs("tcc-include", s->tccinclude_paths, s->nb_tccinclude_paths);
       print_dirs("include", s->sysinclude_paths, s->nb_sysinclude_paths);
       print_dirs("libraries", s->library_paths, s->nb_library_paths);
   #ifdef TCC_TARGET_PE
  diff --git a/tcc.h b/tcc.h
  index a4506f4..1329ffe 100644
  --- a/tcc.h
  +++ b/tcc.h
  @@ -214,13 +214,20 @@ extern long double strtold (const char *__nptr, char 
**__endptr);
   /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
   
   /* system include paths */
  +#ifndef CONFIG_TCC_TCCINCLUDEPATHS
  +# ifdef TCC_TARGET_PE
  +#  define CONFIG_TCC_TCCINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"
  +# else
  +#  define CONFIG_TCC_TCCINCLUDEPATHS "{B}/include"
  +# endif
  +#endif
  +
   #ifndef CONFIG_TCC_SYSINCLUDEPATHS
   # ifdef TCC_TARGET_PE
  -#  define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"
  +#  define CONFIG_TCC_SYSINCLUDEPATHS ""
   # else
   #  define CONFIG_TCC_SYSINCLUDEPATHS \
  -        "{B}/include" \
  -    ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
  +    ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
       ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
   # endif
   #endif
  @@ -753,7 +760,10 @@ struct TCCState {
       DLLReference **loaded_dlls;
       int nb_loaded_dlls;
   
  -    /* include paths */
  +    /* include paths, search order */
  +    char **tccinclude_paths;
  +    int nb_tccinclude_paths;
  +
       char **include_paths;
       int nb_include_paths;
   
  diff --git a/tccpp.c b/tccpp.c
  index 2802d8e..52d46d9 100644
  --- a/tccpp.c
  +++ b/tccpp.c
  @@ -1809,7 +1809,8 @@ ST_FUNC void preprocess(int is_bof)
           /* push current file on stack */
           *s1->include_stack_ptr++ = file;
           i = tok == TOK_INCLUDE_NEXT ? file->include_next_index: 0;
  -        n = 2 + s1->nb_include_paths + s1->nb_sysinclude_paths;
  +        n = 2 + s1->nb_tccinclude_paths + s1->nb_include_paths +
  +            s1->nb_sysinclude_paths;
           for (; i < n; ++i) {
               char buf1[sizeof file->filename];
               CachedInclude *e;
  @@ -1831,8 +1832,14 @@ ST_FUNC void preprocess(int is_bof)
   
               } else {
                   /* search in all the include paths */
  -                int j = i - 2, k = j - s1->nb_include_paths;
  -                path = k < 0 ? s1->include_paths[j] : 
s1->sysinclude_paths[k];
  +                int k, j = i - 2;
  +
  +                if (j < (k = s1->nb_tccinclude_paths))
  +                    path = s1->tccinclude_paths[j];
  +                else if ((j -= k) < s1->nb_include_paths)
  +                    path = s1->include_paths[j];
  +                else if ((j -= s1->nb_include_paths) < 
s1->nb_sysinclude_paths)
  +                    path = s1->sysinclude_paths[j];
                   pstrcpy(buf1, sizeof(buf1), path);
                   pstrcat(buf1, sizeof(buf1), "/");
               }

which is ugly since there is no equivalent to the -B option which
can drive this, but it then works.
However, it seems you need more for libressl, so i added for
tinycc a new internal header in include/, syslog.h:

  #ifndef _TINY_SYSLOG_H
  #define _TINY_SYSLOG_H

  #include <stdarg.h>
  #include <syslog.h>

  #endif /* _TINY_SYSLOG_H */

because musl plays around with va_list in syslog.h.

 |> I've been able to get other software built that wants to use valist
 |> successfully be ensuring -I/usr/lib/tcc/include comes first by adding \
 |> this
 |> to an export CFLAGS=... in /etc/pkg.conf (pkg is what builds ports from
 |> Pkgfile(s))

Ah ja, that and syslog.h wrapper could get you going, until you
fail with

    CCLD     libcompat.la
  ar: `u' modifier ignored since `D' is the default (see `U')
    CCLD     libcrypto.la
  tcc: error: invalid option -- '--whole-archive'
  make[2]: *** [Makefile:3904: libcrypto.la] Error 1
  make[2]: Leaving directory '/tmp/x/libressl-3.1.0/crypto'
  make[1]: *** [Makefile:2165: all] Error 2
  make[1]: Leaving directory '/tmp/x/libressl-3.1.0/crypto'
  make: *** [Makefile:453: all-recursive] Error 1

Ciao, out for cycling now :)

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]