Re: [Tinycc-devel] tinycc manpage

2020-12-27 Thread Anton Shepelev
Sudipto Mallick:

> I am new here, I do not know whose approval I need
> to push the changes. Whom to ask for approval?

Not being a contributor to TCC, I  can't  tell  you.
Since  nobody has answered, chances are no one among
the readers of this mailing list  is  interested  in
tranditional  hand-crafted  man-pages  for  TCC  and
libtcc, but I think many users ourside may like  the
idea... Good luck.


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] What is your general workflow in answering to mailing list thread?

2020-12-26 Thread Anton Shepelev
Kyryl Melekhin:

> I started to like using mailx for emails recently.
> It seems to be the most minimal email client  that
> is  easy to hack on in C. The learning curve might
> be too steep for an average but in the end it  al-
> ways  ends  up  paying off in the long term.  Mutt
> probably will take a 2nd place in terms  of  mini-
> malism.

In  that  case,  you  might  be  interested to check
aerc -- a   moderntext-modee-mailclient:
https://aerc-mail.org/ .


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tinycc manpage

2020-12-26 Thread Anton Shepelev
Sudipto Mallick to Michael Matz:

> As  I am reformatting it, I do not find it hard to
> write. It must have been  writable  enough  to  be
> used in writing almost all manual pages in OpenBSD
> etc.  Also current setup depends on perl to be in-
> stalled,  which  is  not  a  hard requirement, but
> still ...

I agree that *roff syntax is simultaneosly  concise,
writable,  and  readable,  whereas texinfo is a huge
package with a verbose syntax  and  dependencies  on
LaTeX  and  other third-party formatters. That said,
*roff would be the natural choice for TCC because of
its similar minimalist ideology, but since the offi-
cial documentaion tool for TCC is  Texinfo,  I  fear
your good effort will not appreciated...

> There's  also texi2mdoc which is written in C, but
> I haven't tried that.

That means using the makrup language  from  a  large
system,  but  converting into the language of a sim-
pler system by means of a C program. Everybody  will
not  like it...  I think that using Texinfo directly
is better.


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] What is your general workflow in answering to mailing list thread?

2020-12-25 Thread Anton Shepelev
Vaidas BoQsc:

> What is the proper way to quote and reply in a Mailing
> List?

See Netiquette for the basic guidelines:

   https://tools.ietf.org/html/rfc1855

> As an average, I use in-browser Google Mail.

That is not a decent e-mail client, it is terrible.

> Do I need a Mail Client to have a better experience with
> Mailing Lists?

I should say yes. A decent, well-configured mail client is a
game changer. For basic requirements for a mail client, see:

   https://jdebp.eu/Proposals/gnksoa-mua.html

> Do you happen to do any manual message formatting work
> while replying?

I format all my message with the GNU Troff text-proessing
facility, but a good e-mail client will do it for you, so do
not worry :-)


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tinycc manpage

2020-12-25 Thread Anton Shepelev
Sudipto Mallick:

> When I compiled a recent version of tinycc from mob, I
> looked at the source of the manpage. I don't like it.

What did not you like?

> I learnt about the mdoc(7) format for writing man pages
> and thought to use that format for the tcc man page. The
> rewrite is attached.

The processed result is attached. While processing, GNU
Troff reported the following warnings:

   mdoc warning: A .Bl directive has no matching .El (#287)
   mdoc warning: Empty input line #376
   mdoc warning: Empty input line #387
   mdoc warning: Empty input line #392
   mdoc warning: Empty input line #394
   mdoc warning: Empty input line #409

> What do you think about this mdoc formatted manual page?

I disike lines longer than 78 characters and lack of
vertical spacing between logical sections. You can do them
like this:

   end of previous secgtion
   .
   .Sh SYNOPSIS
   .
   text text text.

> Please give suggestion to complete it.

I personally prefer the original -man package to -mdoc...
TCC(1)BSD General Commands Manual   TCC(1)

NAME
 tcc -- Tiny C Compiler

SYNOPSIS
 tcc [options] [infile1 infile2 ...] [-run infile args ...]

DESCRIPTION
 Tiny C Compiler is a lightweight and fast C compiler.  Unlike other C
 compilers, it can run programs directly from memory without generating
 executable files, almost like scripting languages!  tcc runs on Linux,
 Windows, macOS, FreeBSD, NetBSD and OpenBSD operating systems.  tcc can
 compile C code for i386, x86_64, arm, arm64 and riscv64 architectures.

OPTIONS
   General options
 -c  Generate an object file.

 -o outfile
 Put object file, executable, or dll into output file outfile.

 -run source [args ...]
 Compile file source and run it with the command line arguments
 args.  In order to be able to give more than one argument to a
 script, several tcc options can be given after the -run option,
 separated by spaces:
   tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
 In a script, it gives the following header:
   #!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11

 -v  Display TCC version.

 -vv Show included files. As sole argument, print search dirs.  -vvv
 shows too.

 -bench  Display compilation statistics.

   Preprocessor options
 -Idir   Specify an additional include path. Include paths are searched in
 the order they are specified.

 System include paths are always searched after. The default sys-
 tem include paths are: /usr/local/include, /usr/include and
 PREFIX/lib/tcc/include.  (PREFIX is usually /usr or /usr/local).

 -Dsym[=val]
 Define preprocessor symbol `sym' to `val'.  If `val' is not pre-
 sent, its value is `1'.  Function-like macros can also be
 defined: `-DF(a)=a+1'

 -Usym   Undefine preprocessor symbol `sym'.

 -E  Preprocess only, to stdout or file (with -o).

   Compilation flags
 Note: each of the following options has a negative form beginning with
 -fno-.

 -funsigned-char
 Let the char type be unsigned.

 -fsigned-char
 Let the char type be signed.

 -fno-common
 Do not generate common symbols for uninitialized data.

 -fleading-underscore
 Add a leading underscore at the beginning of each C symbol.

 -fms-extensions
 Allow a MS C compiler extensions to the language. Currently this
 assumes a nested named structure declaration without an identi-
 fier behaves like an unnamed one.

 -fdollars-in-identifiers
 Allow dollar signs in identifiers.

   Warning options
 -w  Disable all warnings.
 Note: each of the following warning options has a negative form beginning
 with -Wno-.

 -Wimplicit-function-declaration
 Warn about implicit function declaration.

 -Wunsupported
 Warn about unsupported GCC features that are ignored by TCC.

 -Wwrite-strings
 Make string constants be of type const char * instead of char *.

 -Werror
 Abort compilation if warnings are issued.

 -Wall   Activate all warnings, except -Werror, -Wunusupported and
 -Wwrite-strings.

   Linker options
 -Ldir   Specify an additional static library path for the -l option.  The
 default library paths are /usr/local/lib, /usr/lib and /lib.

 -lname  Link your program with dynamic library libname.so or static
 library libname.a.  The library is searched in the paths speci-
 fied by the -L option and LIBRARY_PATH variable.

 -Bdir   Set the path where the tcc internal libraries (and include files)
 can be found (default is PREFIX/lib/tcc).

 -shared
 Generate a shared 

Re: [Tinycc-devel] A possible bug in TCC

2020-12-20 Thread Anton Shepelev
Christian Jullien:

> I just recompiled you test program with mob. On Windows,
> cl, clang, gcc and ... tcc all produce the same output
> result.  Sorry, I can't reproduce.

I thank everybody for their help and answers and give up on
this one.  I will write it off as a hallucicatio of my PC.


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] A possible bug in TCC

2020-12-13 Thread Anton Shepelev
Vincent Lefevre:

> No issue with tcc 0.9.27+git20200814.62c30a4a-1 provided
> by Debian.

The bug on my side is reproduced with this version just five
days old:

   
https://repo.or.cz/tinycc.git/snapshot/8ff705554de47f16726ec5f1a6c49a162b926732.zip

I had to compile it myself on Windows, using
win32\build-tcc.bat . Is there a pre-compiled win32 build
available?

I have also tried the same on a Linux. Since I had not
enough permissions to install TCC, I only built it and tried
the following from the root of the source directory:

   ./tcc -Iinclude -L. ld.c

tcc failed with error:

   file '/usr/local/lib/tcc/libtcc1.a' not found

The file libtcc1.a is right there in the working directory.
Why did it ignore -L. ?


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] A possible bug in TCC

2020-12-13 Thread Anton Shepelev
Hello, all

During the recent exercise in comp.lang.c in writing a C
program to strip comments from a C source, I have
encountered what seems to be a bug in TCC.  It is manifest
when compiling looser drug's entry with TCC and feeding it
the following test input (between --- markers):

---
a/\
\
\
\
/b
---

which causes the program to hang infinitely. When complied
with other compilers (e.g. GCC), however, it processes the
file correctly and terminates.  The source follows:

#define DEBUG(...)

#include 
#include 
#include 
#include 

typedef union uobject *object;
typedef object list;
typedef enum tag { INVALID, INTEGER, LIST } tag;

union uobject { tag t;
   struct { tag t; int i, continues; } Int;
   struct { tag t; object a, b; } List;
};

typedef struct record {
  int mark;
  struct record *prev;
  union uobject o;
} record;


list cons( object a, object b );
list skip_quote( object q, list o );
list nested_comment( list o );
void print( list o );


record *allocation_list;
object global_roots;
object add_global_root( object o ){
  global_roots = cons( o, global_roots ); return  o;
}
record *alloc(){
  return  calloc( 1, sizeof(record) );
}
void mark( object ob ){
  if(  !ob  ) return;
  record *r = ((void*)( (char*)ob - offsetof( record, o ) ) );
  if(  r->mark  ) return;
  r->mark = 1;
  switch(  ob  ? ob->t  : 0  ){
case LIST: mark( ob->List.a ); mark( ob->List.b ); break;
  }
}
int sweep( record **ptr ){
  int count = 0;
  while(  *ptr  ){
if(  (*ptr)->mark  ){
  (*ptr)->mark = 0;
  ptr = &(*ptr)->prev;
} else {
  record *z = *ptr;
  *ptr = (*ptr)->prev;
  free( z );
  ++count;
}
  }
  return  count;
}
int collect( object local_roots ){
  mark( local_roots );
  mark( global_roots );
  return  sweep( _list );
}

#define OBJECT(...) new_( (union uobject[]){{ __VA_ARGS__ }} )
object new_( object a ){
  record *r = alloc();
  object p = NULL;
  if(  r  ){
r->prev = allocation_list;
allocation_list = r;
p = (void*)( ((char*)r) + offsetof( record, o ) );
*p = *a;
  }
  return  p;
}

object Int( int i ){ return  OBJECT( .Int = { INTEGER, i } ); }
list cons( object a, object b ){ return  OBJECT( .List = { LIST, a, b } ); }
list one( object a ){ return  cons( a, NULL ); }

object car( list o ){
  return  o  && o->t == LIST  ? o->List.a  : NULL;
}
object cdr( list o ){
  return  o  && o->t == LIST  ? o->List.b  : NULL;
}

int eq( object a, object b ){
  return  !a && !b? 1  :
  !a || !b? 0  :
  a->t != b->t? 0  :
  a->t == INTEGER  ? a->Int.i == b->Int.i
   : !memcmp( a, b, sizeof *a );
}

int eqint( object a, int i ){
  union uobject b = { .Int = { INTEGER, i } };
  return  eq( a,  );
}

int match( object pat, object it, object *matched, object *tail ){
  if(  !pat  ){
return  *tail = it,  1;
  }
  if(  pat->t != (it  ? it->t  : 0)  ) return  0;
  switch(  pat->t  ){
case LIST:
  {
object sink;
if(  match( car( pat ), car( it ), & sink, tail )  ){
  return  *matched = it,  match( cdr( pat ), cdr( it ), & sink, tail );
}
  } break;
case INTEGER:
  if(  eq( pat, it )  ){
return  *matched = it,  1;
  }
  }
  return  0;
}

list chars_from_file( FILE *f ){
  int c = fgetc( f );
  return  c != EOF  ? cons( Int( c ), chars_from_file( f ) )  : one( Int( c ) );
}

list logical_lines( list o ){
  static list pat;
  if(  !pat  ) pat = add_global_root( cons( Int( '\\' ), one( Int( '\n' ) ) ) );

  object matched, tail;
  DEBUG( if( car(o)->Int.i!=EOF )
 fprintf( stderr, "[%c%c]", car(o)->Int.i, car(cdr(o))->Int.i ); )
  if(  match( pat, o, ,  )  ){
DEBUG( fprintf( stderr, "@" ); )
car( tail )->Int.continues = car( o )->Int.continues + 1;
return  logical_lines( tail );
  } else {
object a = car( o );
return  eqint( a, EOF )  ? o  : cons( a, logical_lines( cdr( o ) ) );
  }
}

list restore_continues( list o ){
  if(  !o  ) return  NULL;
  object a = car( o );
  if(  eqint( a, EOF )  ) return  o;
  object z = cdr( o );
  object r = cons( a, restore_continues( z ) );
  while(  a->Int.continues  ){
r = cons( Int( '\\' ), cons( Int( '\n' ), r ) );
--a->Int.continues;
  }
  return  r;
}

list strip_comments( list o ){
  static list single, multi;
  if(  !single  ) single = add_global_root( cons( Int('/'), one(Int('/')) ) );
  if(  !multi   ) multi = add_global_root( cons( Int('/'), one(Int('*')) ) );

  object matched, tail;
  DEBUG( if(car(o)->Int.i!=EOF)
  fprintf(stderr,"<%c%c>", car(o)->Int.i, car(cdr(o))->Int.i); )
  if(  match( single, o, ,  )  ){
DEBUG( fprintf( stderr, "@" ); )
do {
  tail = cdr( tail );
  matched = car( tail );
} while(  !eqint( matched, '\n' )  );
return  strip_comments( tail );
  } else if(  match( multi, o, ,  )  ){
DEBUG( fprintf( stderr, "@" ); )
return  cons( Int( ' ' ),
 

Re: [Tinycc-devel] Tinycc Amalgamation file

2018-11-23 Thread Anton Shepelev
Mike Parsons:

>Hi all ... I am trying to create a WebAssembly version of
>tinycc using the emscripten tool chain and was wondering if
>there exists a single amalgamated source file for tinycc?
>For example, like that which is offered by sqlite.org
>https://sqlite.org/howtocompile.html.

This is a reply from Bart at comp.lang.c (where I fixed two
important typos):

I don't remember seeing an amalgamated version. Perhaps
there's some confusion because if the ONE_SOURCE macro is
defined, then when you compile tcc.c, it will also compile
all source code of tcc as a single translation unit.
(Otherwise it will be built as two lots, .exe and .dll.)

If an actual single file is required, that looks easy, but
my investigations reveal this include structure (standard
headers and many duplicate tcc.h not shown):

100 tcc.c
201 tcc.h
301 config.h
302 libtcc.h
303 elf.h
304 stab.h
401 stab.def
305 tcctok.h
501 i386-tok.h  WIN32
202 libtcc.c
600 (tcc.h)
601 tccpp.c
602 tccgen.c
603 tccelf.c
604 tccrun.c
605 i386-gen.c  WIN32
606 i386-lib.c  WIN32
607 i386-asm.c  WIN32
203 tcctools.c
700 (tcc.h)
701 process.h   WIN32 (./win32/include)
801 _mingw.hWIN32 (./win32/include)

When I tried to create such a file manually, then I got
compile errors.

If someone really wants a single C source for Tiny C, for a
fixed configuration and with no need to maintain the result,
then then using simple pre-processing /might/ work:

  C:cc7inycc-mob>bcc -e tcc.c
  Compiling tcc.c to tcc.i

  C:cc7inycc-mob>bcc tcc.i
  Compiling tcc.i to tcc.exe

  C:cc7inycc-mob>tcc -v
  tcc version 0.9.27 (x86_64 Windows)

However, there were problems trying to do the same with gcc
-E (I could build tcc.exe from the preprocessed file, but
couldn't run it - incompatible exe format or something). So
perhaps try a different compiler, although the result may be
specific to that compiler.

(To build tcc.c here for Windows 64, I defined these macros
at the start:

  #define TCC_TARGET_PE
  #define TCC_TARGET_X86_64
  #define ONE_SOURCE 1

while config.h contained:
  #define TCC_VERSION "0.9.27"

)

Perhaps I should add that this 'one-source' version is for
the main tcc executable. However, building a working Tiny C
installation also involves using that tcc.exe to build its
libraries: compiling a further bunch of .c and .S files into
.o then combining into .a.

There is also a specific directory structure needed to
properly run that version of tcc.

I couldn't find trace of an amalgamated version online, so
it sounds like this project is not so suitable for that, not
if one tcc.c file is expected to take care of everything
necessary.

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] TCC ignores a syntax error

2018-11-18 Thread Anton Shepelev
Hello, all

TCC compiles the following program:

int main( int argc, char** argv )
{  int   i, *iP;
   void* vP;
   i  = 55;
   iP = 
   vP = &(void*)iP; /* syntax error */
   return 0;
}

whereas it should fail with a syntax error, because
the & operator requires an lvalue.

P.S.: Sorry for sending this to the owner the first
  time.

-- 
()  ascii ribbon campaign -- against html e-mail
/\  http://preview.tinyurl.com/qcy6mjc [archived]

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Include paths

2014-05-28 Thread Anton Shepelev
grischka to Anton Shepelev:

  There must be something wrong with the  environ-
  ment on one of the machines, but I have no  idea
  how to locate it...

 tcc  -vvv  file.c shows where tcc is looking for
 files.

Thanks.  I had missed your  reply.   Here's  what  I
have:

,[tcc -vvv file.c:]
| tcc version 0.9.25
| - test.c
| nf d:/include/stdio.h
| nf d:/include/winapi/stdio.h
`-

-- 
()  ascii ribbon campaign - against html e-mail
/\  http://preview.tinyurl.com/qcy6mjc [archived]

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Include paths

2013-08-24 Thread Anton Shepelev
David Mertens:

 I  haven't dug into the source code for this, but I too
 have noticed that (1) I can move around a Windows  com-
 pilation  of tcc that was built using the build-tcc.bat
 file, but (2) I cannot move around a compilation  built
 using ./configure. This has ramifications for the build
 recipe for Alien::TinyCC, which is why I know and care.
 :-)
 [...]
 I  would  hypothesize  that  tcc  you built at work was
 built with the unixish approach? ./cofigure, make, make
 install?

The  funny  thing is that on both machines (where the in-
clude paths are visible and where they are not) I am  us-
ing the same pre-build version 0.9.26 downloaded from the
home page.  There must be something wrong with the  envi-
ronment on one of the machines, but I have no idea how to
locate it...

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Include paths

2013-08-22 Thread Anton Shepelev
Thomas Preud'homme:

  The manual says:
 
The default system include paths are: '/usr/
local/include', '/usr/include' and  'PREFIX/
lib/  tcc/include'.   ('PREFIX'  is  usually
'/usr' or '/usr/local').
 
  But [what] is  PREFIX?   Is  it  an  environment
  variable  or  some internal constant? How to de-
  termine it if I'm on Windows?

 It's the path passed to configure via  the -- pre-
 fix  switch.  By default it's C:/Program Files/tcc
 on Windows and /usr/local for other systems.

Thank you very much.  I copied the include directory
to that path so that I now have:

  C:\Program Files\tcc\include and
  C:\Program Files\tcc\lib

yet  tcc still can't compile the program without the
-I and -L options.

What's more interesting, at my home PC tcc finds its
include and lib directories irregardless of where it
is located, as if it were looking them up relatively
to  the  location  of  the executable: I renamed its
parent directory (say, to TCC-2), and called it from
the root of the drive -- and it worked again.  I al-
so made sure that  it  was  the  local  (sibling  to
tcc.exe) include directory that was used by renaming
it.

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel