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 <tinycc-devel@nongnu.org> 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 <mailto:Tinycc-devel@nongnu.org> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org <mailto: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