Re: [Tinycc-devel] Implementation of '--' argument

2023-04-18 Thread certanan via Tinycc-devel
I'm not sure if I understood your question correctly, but compiling a version 
of tcc that hasn't replaced '--' with '-run' seems to be a bit of a nuisance - 
it does not support the x86_64 architecture.
I don't think that there are very many people stuck on i386 nowadays, plus I 
can't see how a considerable amount of people hacking their own tcc 
installations to support their x86_64 would be more viable than simply 
upgrading it to more recent versions. It's more likely that there are few 
scripts relying on '--' out there and that they aren't used.

I'm not sure if altering these scripts to a conformant form wouldn't be more 
ideal than modifying tcc itself, in the end. As I am neither a seasoned tcc 
user nor a hardened industry software developer, I will leave this up to the 
more experience ones of you to decide.
One way or another, implementing an error message pointing users in the right 
direction instead of the generic "invalid option" error would do no harm, or 
would it?

- certanan


--- Original Message ---
On Tuesday, April 18th, 2023 at 8:37 AM, grischka  wrote:


> On 18.04.2023 07:41, certanan via Tinycc-devel wrote:
> 
> > I couldn't find any specific reasons as to why '--' was replaced by '-run' 
> > (other than '-run' being implicitly more coherent than '--'). Since there 
> > is a possibility that older scripts still depend on '--', would it be a bad 
> > idea to re-implement it for the sake of backward compatibility, and state 
> > its deprecated status in documentation?
> 
> 
> What about the possibility that the "older" script that you found
> 
> https://github.com/qemacs/qemacs/blob/master/qe.tcc
> 
> still exists there unchanged because nobody did even try it with
> a more recent version of tcc since then?
> 
> Did you check how well it would work at all?
> 
> -- gr
> 
> > - certanan
> > 
> > --- Original Message ---
> > On Monday, April 17th, 2023 at 8:18 AM, grischka gris...@gmx.de wrote:
> > 
> > > On 17.04.2023 07:59, avih via Tinycc-devel wrote:
> > > 
> > > > What some random script tries or doesn't try to do is irrelevant.
> > > 
> > > In a case however where the script and the tcc to be used with it
> > > were written by the same author at the same time, we probably better
> > > assume that it actually did work.
> > > 
> > > As it seems the purpose was different though, i.e. the '--' once
> > > was used with instant execution to separate tcc args from the
> > > program's args.
> > > 
> > > See commit here (from almost exactly 20 years ago) where "--" then
> > > was replaced by "-run" as it still exists.
> > > 
> > > https://repo.or.cz/tinycc.git/commitdiff/40987541dc683a13cef764aa33f5da21b2660817
> > > 
> > > > tcc should follow the spec and common practices.
> > > 
> > > ... provided that these do make sense in tcc's own context. In cases
> > > it better shouldn't.
> > > 
> > > For example, not to support compilation of files such as -c.c is
> > > not a problem as long as we assume that such files do not exist.
> > > 
> > > Other than that tcc currently does support these forms with -run:
> > > tcc options [files less one] -run last_file arguments
> > > and also
> > > tcc "-run options" file arguments (for usage with "#!", see ex4.c)
> > > and also
> > > tcc options files -run @ arguments
> > > 
> > > I'd consider the latter form still rather "unofficial" so we could
> > > still replace it by
> > > 
> > > tcc options files -run -- arguments
> > > 
> > > which might (or might not) look better, in some sense.
> > > 
> > > What do people think?
> > > 
> > > -- grischka
> > > 
> > > ___
> > > Tinycc-devel mailing list
> > > Tinycc-devel@nongnu.org
> > > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> > 
> > ___
> > Tinycc-devel mailing list
> > Tinycc-devel@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> 
> 
> 
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-18 Thread grischka

On 18.04.2023 07:41, certanan via Tinycc-devel wrote:

I couldn't find any specific reasons as to why '--' was replaced by '-run' 
(other than '-run' being implicitly more coherent than '--'). Since there is a 
possibility that older scripts still depend on '--', would it be a bad idea to 
re-implement it for the sake of backward compatibility, and state its 
deprecated status in documentation?


What about the possibility that the "older" script that you found

   https://github.com/qemacs/qemacs/blob/master/qe.tcc

still exists there unchanged because nobody did even try it with
a more recent version of tcc since then?

Did you check how well it would work at all?

-- gr


- certanan

--- Original Message ---
On Monday, April 17th, 2023 at 8:18 AM, grischka  wrote:



On 17.04.2023 07:59, avih via Tinycc-devel wrote:


What some random script tries or doesn't try to do is irrelevant.



In a case however where the script and the tcc to be used with it
were written by the same author at the same time, we probably better
assume that it actually did work.

As it seems the purpose was different though, i.e. the '--' once
was used with instant execution to separate tcc args from the
program's args.

See commit here (from almost exactly 20 years ago) where "--" then
was replaced by "-run" as it still exists.

https://repo.or.cz/tinycc.git/commitdiff/40987541dc683a13cef764aa33f5da21b2660817


tcc should follow the spec and common practices.



... provided that these do make sense in tcc's own context. In cases
it better shouldn't.

For example, not to support compilation of files such as -c.c is
not a problem as long as we assume that such files do not exist.

Other than that tcc currently does support these forms with -run:
tcc options [files less one] -run last_file arguments
and also
tcc "-run options" file arguments (for usage with "#!", see ex4.c)
and also
tcc options files -run @ arguments

I'd consider the latter form still rather "unofficial" so we could
still replace it by

tcc options files -run -- arguments

which might (or might not) look better, in some sense.

What do people think?

-- grischka


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


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




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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-17 Thread certanan via Tinycc-devel
I couldn't find any specific reasons as to why '--' was replaced by '-run' 
(other than '-run' being implicitly more coherent than '--'). Since there is a 
possibility that older scripts still depend on '--', would it be a bad idea to 
re-implement it for the sake of backward compatibility, and state its 
deprecated status in documentation?

- certanan

--- Original Message ---
On Monday, April 17th, 2023 at 8:18 AM, grischka  wrote:


> On 17.04.2023 07:59, avih via Tinycc-devel wrote:
> 
> > What some random script tries or doesn't try to do is irrelevant.
> 
> 
> In a case however where the script and the tcc to be used with it
> were written by the same author at the same time, we probably better
> assume that it actually did work.
> 
> As it seems the purpose was different though, i.e. the '--' once
> was used with instant execution to separate tcc args from the
> program's args.
> 
> See commit here (from almost exactly 20 years ago) where "--" then
> was replaced by "-run" as it still exists.
> 
> https://repo.or.cz/tinycc.git/commitdiff/40987541dc683a13cef764aa33f5da21b2660817
> 
> > tcc should follow the spec and common practices.
> 
> 
> ... provided that these do make sense in tcc's own context. In cases
> it better shouldn't.
> 
> For example, not to support compilation of files such as -c.c is
> not a problem as long as we assume that such files do not exist.
> 
> Other than that tcc currently does support these forms with -run:
> tcc options [files less one] -run last_file arguments
> and also
> tcc "-run options" file arguments (for usage with "#!", see ex4.c)
> and also
> tcc options files -run @ arguments
> 
> I'd consider the latter form still rather "unofficial" so we could
> still replace it by
> 
> tcc options files -run -- arguments
> 
> which might (or might not) look better, in some sense.
> 
> What do people think?
> 
> -- grischka
> 
>  
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-17 Thread ian

Hi all.

Honestly ? When I read "-- option to tcc", I laughed at lot !

I consider this particularly irrelevant, and Grishka's comment is right
("For example, not to support compilation of files such as -c.c is not a 
problem as long as we assume that such files do not exist.")


Considering other cases, I just tried a very simple test case :
#!/usr/bin/env -S tcc inc.o -run
#include 
#include "inc.h"
int main(int argc, const char* argv[]) {
  for (int i=0;iFor example, not to support compilation of files such as -c.c is 

--
İȃɲ ƝᵋᵃʳᶩỾ
--*menea...@gmail.com*
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-17 Thread grischka

On 17.04.2023 07:59, avih via Tinycc-devel wrote:


What some random script tries or doesn't try to do is irrelevant.


In a case however where the script and the tcc to be used with it
were written by the same author at the same time, we probably better
assume that it actually did work.

As it seems the purpose was different though, i.e. the '--' once
was used with instant execution to separate tcc args from the
program's args.

See commit here (from almost exactly 20 years ago) where "--" then
was replaced by "-run" as it still exists.

https://repo.or.cz/tinycc.git/commitdiff/40987541dc683a13cef764aa33f5da21b2660817


tcc should follow the spec and common practices.


... provided that these do make sense in tcc's own context.  In cases
it better shouldn't.

For example, not to support compilation of files such as -c.c is
not a problem as long as we assume that such files do not exist.

Other than that tcc currently does support these forms with -run:
   tcc options [files less one] -run last_file arguments
and also
   tcc "-run options" file arguments (for usage with "#!", see ex4.c)
and also
   tcc options files -run @ arguments

I'd consider the latter form still rather "unofficial" so we could
still replace it by

   tcc options files -run -- arguments

which might (or might not) look better, in some sense.

What do people think?

-- grischka


Generally speaking, applications which respect the POSIX syntax
guidelines should treat non-option-argument "--" as an indication
that all further arguments are operands:
- https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html

It's important to note that according to these guidelines, the
options always come before the operands. I.e. mixing of options and
operands (like GNU getopt does with permutations) is not allowed.

Therefore, the use of "--" is to indicate where the options end and
the operands start, especially for the case where the first operand
begins with "-".

"grep" should indeed respect these guidelines, and "--":
- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html

However, there are exceptions, for instance "echo" should not
respect these guidelines and instead treat all arguments as operands:
- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

(the fact that some implementations of "echo" deviate from the spec
and allow options such as "-e" or "-n" is the reason for echo being
considered non portable, and why "printf" is recommended instead)

The "c99" utility, which should probably be considered the spec for
tcc, has some exceptions with regards to the syntax guidelines:
- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html

While it does not specifically mention "--", it does say that
options and operands can be mixed, and some options should appear
after [c-files] operands, such as the "-l" and "-L" options
(check the synopsis).

For that reason, allowing "--" to be used before c-filenames
is a footgun, because then it's not possible to add "-l" or "-L"
options as needed by the spec.

The fact that gcc also doesn't recognize "--" is existing common
practice as well.

However, clang does recognize "--", and indeed, it rejects "-l"
or "-L" if they appear after "--" and some c-filenames.

As far as I can tell that's inconsistent with the "c99" POSIX spec.

So there you go. The main point of this is that it's not obvious
that tcc should respect "--" the same as some other utilities.

- avih

On Sunday, April 16, 2023, 11:44:24 PM GMT+3, certanan via Tinycc-devel 
 wrote:


I understand. But then what role does the flag fulfil in this script?
https://github.com/qemacs/qemacs/blob/master/qe.tcc

- certanan

 > I tried: gcc -- a.c
 > and got:
 > gcc: error: unrecognized command-line option '--'
 >
 > This is with prerelease of gcc 13.
 > So gcc does not support this. Why would this be needed for tcc?
 >
 > Herman
 >
 > ___
 > Tinycc-devel mailing list
 > Tinycc-devel@nongnu.org 
 > https://lists.nongnu.org/mailman/listinfo/tinycc-devel


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


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




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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-17 Thread avih via Tinycc-devel
 What some random script tries or doesn't try to do is irrelevant.

tcc should follow the spec and common practices.

Generally speaking, applications which respect the POSIX syntax
guidelines should treat non-option-argument "--" as an indication
that all further arguments are operands:
- https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html

It's important to note that according to these guidelines, the
options always come before the operands. I.e. mixing of options and
operands (like GNU getopt does with permutations) is not allowed.

Therefore, the use of "--" is to indicate where the options end and
the operands start, especially for the case where the first operand
begins with "-".

"grep" should indeed respect these guidelines, and "--":
- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html

However, there are exceptions, for instance "echo" should not
respect these guidelines and instead treat all arguments as operands:
- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

(the fact that some implementations of "echo" deviate from the spec
 and allow options such as "-e" or "-n" is the reason for echo being
 considered non portable, and why "printf" is recommended instead)

The "c99" utility, which should probably be considered the spec for
tcc, has some exceptions with regards to the syntax guidelines:
- https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html

While it does not specifically mention "--", it does say that
options and operands can be mixed, and some options should appear
after [c-files] operands, such as the "-l" and "-L" options
(check the synopsis).

For that reason, allowing "--" to be used before c-filenames
is a footgun, because then it's not possible to add "-l" or "-L"
options as needed by the spec.

The fact that gcc also doesn't recognize "--" is existing common
practice as well.

However, clang does recognize "--", and indeed, it rejects "-l"
or "-L" if they appear after "--" and some c-filenames.

As far as I can tell that's inconsistent with the "c99" POSIX spec.

So there you go. The main point of this is that it's not obvious
that tcc should respect "--" the same as some other utilities.

- avih

 On Sunday, April 16, 2023, 11:44:24 PM GMT+3, certanan via Tinycc-devel 
 wrote:  
 
 I understand. But then what role does the flag fulfil in this script?
https://github.com/qemacs/qemacs/blob/master/qe.tcc

- certanan

> I tried: gcc -- a.c
> and got:
> gcc: error: unrecognized command-line option '--'
> 
> This is with prerelease of gcc 13.
> So gcc does not support this. Why would this be needed for tcc?
> 
> Herman
> 
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-16 Thread certanan via Tinycc-devel
I understand. But then what role does the flag fulfil in this script?
https://github.com/qemacs/qemacs/blob/master/qe.tcc

- certanan

> I tried: gcc -- a.c
> and got:
> gcc: error: unrecognized command-line option '--'
> 
> This is with prerelease of gcc 13.
> So gcc does not support this. Why would this be needed for tcc?
> 
> Herman
> 
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-16 Thread Herman ten Brugge via Tinycc-devel

On 4/16/23 20:10, certanan wrote:

>From experience, when a program invoked by a shell sees the '--' flag, it 
stops looking for options.

$ grep -V// print grep version
grep (GNU grep) 3.8
...

$ grep -- -V // match for '-V'
[waiting for stdin where matching for '-V' will occur]

If I'm not mistaken, tcc expects only file-names and options as arguments (if 
no file-names are provided, it reads code from stdin). Hence after '--' it 
would treat all arguments as file-names or resort to reading code from stdin if 
none are provided.

- certanan

--- Original Message ---
On Sunday, April 16th, 2023 at 5:46 PM, grischka  wrote:



On 15.04.2023 22:38, certanan via Tinycc-devel wrote:


 From what it seems to me, even Bellard's QEmacs seems to be relying on this, 
rather, standard feature since at least 19 years ago, as referenced in its 
official GitHub repository.
Am I missing something cardinal, or is there, indeed, no valid reason for this 
seemingly not being implemented in tcc? Should the former be the case, I would 
appreciate if someone informed me of it. Otherwise, I have a patch on standby, 
ready to push the feature to mob.


Sorry, what this "the feature"? Mind do add a little more information
what you're talking about, how it's supposed to be used, examples... ?

I tried: gcc -- a.c
and got:
gcc: error: unrecognized command-line option '--'

This is with prerelease of gcc 13.
So gcc does not support this. Why would this be needed for tcc?

    Herman

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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-16 Thread certanan via Tinycc-devel
From experience, when a program invoked by a shell sees the '--' flag, it stops 
looking for options.

$ grep -V// print grep version
grep (GNU grep) 3.8
...

$ grep -- -V // match for '-V'
[waiting for stdin where matching for '-V' will occur]

If I'm not mistaken, tcc expects only file-names and options as arguments (if 
no file-names are provided, it reads code from stdin). Hence after '--' it 
would treat all arguments as file-names or resort to reading code from stdin if 
none are provided.

- certanan

--- Original Message ---
On Sunday, April 16th, 2023 at 5:46 PM, grischka  wrote:


> On 15.04.2023 22:38, certanan via Tinycc-devel wrote:
> 
> > From what it seems to me, even Bellard's QEmacs seems to be relying on 
> > this, rather, standard feature since at least 19 years ago, as referenced 
> > in its official GitHub repository.
> > Am I missing something cardinal, or is there, indeed, no valid reason for 
> > this seemingly not being implemented in tcc? Should the former be the case, 
> > I would appreciate if someone informed me of it. Otherwise, I have a patch 
> > on standby, ready to push the feature to mob.
> 
> 
> Sorry, what this "the feature"? Mind do add a little more information
> what you're talking about, how it's supposed to be used, examples... ?
> 
> -- gr
> 

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


Re: [Tinycc-devel] Implementation of '--' argument

2023-04-16 Thread grischka

On 15.04.2023 22:38, certanan via Tinycc-devel wrote:

 From what it seems to me, even Bellard's QEmacs seems to be relying on this, 
rather, standard feature since at least 19 years ago, as referenced in its 
official GitHub repository.
Am I missing something cardinal, or is there, indeed, no valid reason for this 
seemingly not being implemented in tcc? Should the former be the case, I would 
appreciate if someone informed me of it. Otherwise, I have a patch on standby, 
ready to push the feature to mob.


Sorry, what this "the feature"?  Mind do add a little more information
what you're talking about, how it's supposed to be used, examples... ?

-- gr


Thanks.
- certanan

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




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


[Tinycc-devel] Implementation of '--' argument

2023-04-15 Thread certanan via Tinycc-devel
From what it seems to me, even Bellard's QEmacs seems to be relying on this, 
rather, standard feature since at least 19 years ago, as referenced in its 
official GitHub repository.
Am I missing something cardinal, or is there, indeed, no valid reason for this 
seemingly not being implemented in tcc? Should the former be the case, I would 
appreciate if someone informed me of it. Otherwise, I have a patch on standby, 
ready to push the feature to mob.

Thanks.
- certanan

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