[Top][All Lists]

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

[Tinycc-devel] RE :Re: [PATCH] Don't break compilation process with unkn

From: Christian JULLIEN
Subject: [Tinycc-devel] RE :Re: [PATCH] Don't break compilation process with unknow option
Date: Wed, 7 Jan 2015 08:56:39 +0100 (CET)

To support specific gcc options I sometimes have in configure.ac lines like:

    if `${CC} -v --help 2>&1 | grep finline-limit= > /dev/null`
      CFLAGS="$CFLAGS -finline-limit=4096"

It works for any CC. In case compiler is NOT gcc, -v --help may produce an error and grep will find nothing.

And alternate (and better) solution is to use AX_CHECK_COMPILE_FLAG which resides on ax_check_compile_flag.m4 you can add in a local m4 directory.

Then check is as easy as:

AX_CHECK_COMPILE_FLAG([-std=gnu99], [CFLAGS="$CFLAGS -std=gnu99"])

The 'little' inconvenient is that is requires additional steps by mean of autogen.sh which, in simple case can just be:

#! /bin/sh

fail() {
    echo "Error:" $@ 1>&2; exit 1

aclocal -I m4 --force || fail "aclocal"
autoconf -f || fail "autoconf"

This the what I recommend as we may add more m4 macro files in the future.
Also most open source projects use this mechanism these days.

Hope it helps.

----- message d'origine -----
De : "Michael Matz" <address@hidden>
date mer. 07/01/2015 07:09 (GMT +01:00)
À : "address@hidden" <address@hidden>
Objet : Re: [Tinycc-devel] [PATCH] Don't break compilation process with unknow option

Am 07.01.2015 um 04:14 schrieb Sergey Korshunoff:
> After applying a "disable DTEST" patch to allow "make test" to pass a
> broken tests...
> ./configure --cc=tcc; make; make install; make test
> tcc -o tcctest.cc tcctest.c -I.. -I.. -w -DTCC_TARGET_I386
> -std=gnu99 -O0 -fno-omit-frame-pointer
> tcc: error: invalid option -- '-std=gnu99'
> With a patch apllied a test can be performed with
> make CFLAGS=-Wunsuported test
> And your solution?

The makefile (and/or configure) needs to be fixed to not hardcode
potentially unknown compiler options.

> What you will add to CFLAGS?

Nothing. The only sensible thing that tcc can to with completely
unknown options is to error out on them. It can't simply ignore them,
not even with a warning as the unknown option in question might have
significant effects for code generation for a compiler understanding it
(-std=gnu99 is on the border of being such option) and the author might
_require_ that effect to happen for his compilations. Ignoring it would
either generate unnecessary followup errors or silently generate code
with the wrong semantics, which is worse.

There is a case to be made to only warn for unknown options that
influence diagnostics only. As it's unknown it's of course hard to know
when exactly that is the case. If it starts with -W that might be a
good enough heuristic in practice, so I'm with Thomas on this topic.

If you absolutely hate fixing makefiles/configures for trying out tcc,
instead of patching tcc to ignore all unkown options you could also
simply write a wrapper script that removes _known_ unknown options that
you happen to hit when you know they indeed aren't important.


Tinycc-devel mailing list

reply via email to

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