You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Igor Galić <i....@brainsware.org> on 2013/04/30 08:22:42 UTC

Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters


----- Original Message -----
> Updated Branches:
>   refs/heads/master 54b532b64 -> d8c526233
> 
> 
> TS-1864 Rearrange some of the autoconf code, order matters
> 
[snip]
> Branch: refs/heads/master
> Commit: d8c5262331e0654097640982100f43731e7e8f6d
> Parents: 54b532b
> Author: Leif Hedstrom <zw...@apache.org>
> Authored: Mon Apr 29 17:00:51 2013 -0600
> Committer: Leif Hedstrom <zw...@apache.org>
> Committed: Mon Apr 29 22:07:27 2013 -0600

> --- a/configure.ac
> +++ b/configure.ac
> @@ -674,10 +720,10 @@ AM_CONDITIONAL([BUILD_HAVE_LIBCXX], [ false ])
>  
>  base_cc=`basename $CC`
>  # These are shortcuts used in combination for the compiler options
>  below


I hope we can all agree that using the compilers name on the
filesystem is a BAD way determine which compiler we're dealing with.

> -case $host_os in
> -  linux*)
> +case $host_os_def in
> +  linux)
>      case $base_cc in
> -    icc)
> +    *icc*)
>        # -Wall goes crazy, so turned these specific checks off for
>        now:
>        #
>        #  111 is "statement is unrecahable"
> @@ -700,7 +746,7 @@ case $host_os in
>        release_opt="-g $common_opt $optimization_flags -axsse4.2
>        -fno-strict-aliasing"
>        cxx_opt="-Wno-invalid-offsetof"
>        ;;
> -    clang)
> +    *clang*)
>        debug_opt="-ggdb3 $common_opt -Werror -Qunused-arguments"
>        release_opt="-g $common_opt $optimizing_flags
>        -fno-strict-aliasing -Werror -Qunused-arguments"
>        cxx_opt="-Wno-invalid-offsetof -Werror -Qunused-arguments"
> @@ -717,10 +763,10 @@ case $host_os in
>        flex_cflags="-Wno-unused-parameter"
>        ;;
>      esac
> -    ;; # linux*)
> -  darwin*)
> +    ;; # linux)
> +  darwin)
>      case $base_cc in
> -    clang)
> +    *clang*)
>        common_opt="-pipe -Wall -Werror -Wno-deprecated-declarations"
>        debug_opt="$common_opt"
>        release_opt="-g $common_opt $optimizing_flags
>        -fno-strict-aliasing"
> @@ -738,10 +784,10 @@ case $host_os in
>      # ToDo: This seems semi-kludgy, but useful for MacPort's I
>      think.
>      TS_ADDTO(CPPFLAGS, [-I/opt/local/include])
>      TS_ADDTO(LDFLAGS, [-L/opt/local/lib])
> -    ;; # darwin*)
> -  freebsd*|kfreebsd*)
> +    ;; # darwin)
> +  freebsd|kfreebsd)
>      case $base_cc in
> -    clang)
> +    *clang*)
>        common_opt="-pipe -Wall -Werror -Qunused-arguments"
>        debug_opt="-ggdb3 $common_opt"
>        release_opt="-g $common_opt $optimizing_flags
>        -feliminate-unused-debug-symbols -fno-strict-aliasing"
> @@ -755,10 +801,11 @@ case $host_os in
>        ;;
>      esac
>      TS_ADDTO(LDFLAGS, [-L/usr/local/lib])
> -    ;;
> -  solaris*)
> +    ;; # freebsd|kfreebsd)
> +  solaris)
>      if test "x${base_cc}" = "xcc"; then
> -      common_opt="-mt -m64 -D__WORDSIZE=64" # FIXME: arch should be
> detected
> +      # TODO: If we no longer support SunStudio, should this code go
> away?
> +      common_opt="-mt -D__WORDSIZE=64" # FIXME: arch should be
> detected
>        debug_opt="-g $common_opt"
>        release_opt="-g $common_opt $optimizing_flags"
>        cxx_opt="-library=stlport4"
> @@ -771,11 +818,11 @@ case $host_os in
>          postdeps_CXX="-library=Crun"
>        fi
>      else # gcc
> -      common_opt="-pipe -Wall -Werror -m64"
> +      common_opt="-pipe -Wall -Werror"
>        debug_opt="-ggdb3 $common_opt"
>        release_opt="-g $common_opt $optimizing_flags
>        -feliminate-unused-debug-symbols -fno-strict-aliasing"
>        cxx_opt="-Wno-invalid-offsetof"
> -    fi
> +    fi # solaris)
>      ;;
>    *)
>      common_opt="-pipe -Wall -Werror"
> @@ -802,26 +849,27 @@ SHARED_LDFLAGS=-shared

-- i
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE


Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by Igor Galić <i....@brainsware.org>.
Well, this is now done!

TS-1872 / https://git-wip-us.apache.org/repos/asf?p=trafficserver.git;a=commit;h=c400c884

----- Original Message -----
> On May 1, 2013, at 8:39 AM, Leif Hedstrom <zw...@apache.org> wrote:
> 
> > On 5/1/13 6:58 AM, James Peach wrote:
> >> On May 1, 2013, at 12:48 AM, Igor Galić <i....@brainsware.org>
> >> wrote:
> >> 
> >>> Following this basic idea here
> >>> 
> >>>  http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
> >>> 
> >>> I'd like to add a build/base_compiler.m4 - that runs this
> >>> program:
> >>> 
> >>>    # include <stdio.h>
> >>>    int main (void) {
> >>>      printf (
> >>>    #if defined(__clang__)
> >>>      "clang"
> >>>    #elif defined (__GNUC__) || defined (__GNUG__)
> >>>      "gcc"
> >>>    #elif defined (__SUNPRO_C) || defined (__SUNPRO_CC)
> >>>      "sunproc"
> >>>    #elif defined (__ICC) || defined(__INTEL_COMPILER)
> >>>      "icc"
> >>>    #endif
> >>>      );
> >>>      return 0;
> >>>    }
> > 
> > 
> > In addition to what James said, I think order could matter here.
> > Like, I suspect that ICC might define some of the gcc flags in its
> > "compatibility" mode. As such, I'd imagine you ought to test for
> > most specific first (e.g. icc then sunpro then clang and last gcc)
> > ?
> 
> Yeh, the order matters ... clang masquerades as GCC pretty thoroughly
> 
> J

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE

Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by James Peach <jp...@apache.org>.
On May 1, 2013, at 8:39 AM, Leif Hedstrom <zw...@apache.org> wrote:

> On 5/1/13 6:58 AM, James Peach wrote:
>> On May 1, 2013, at 12:48 AM, Igor Galić <i....@brainsware.org> wrote:
>> 
>>> Following this basic idea here
>>> 
>>>  http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
>>> 
>>> I'd like to add a build/base_compiler.m4 - that runs this program:
>>> 
>>>    # include <stdio.h>
>>>    int main (void) {
>>>      printf (
>>>    #if defined(__clang__)
>>>      "clang"
>>>    #elif defined (__GNUC__) || defined (__GNUG__)
>>>      "gcc"
>>>    #elif defined (__SUNPRO_C) || defined (__SUNPRO_CC)
>>>      "sunproc"
>>>    #elif defined (__ICC) || defined(__INTEL_COMPILER)
>>>      "icc"
>>>    #endif
>>>      );
>>>      return 0;
>>>    }
> 
> 
> In addition to what James said, I think order could matter here. Like, I suspect that ICC might define some of the gcc flags in its "compatibility" mode. As such, I'd imagine you ought to test for most specific first (e.g. icc then sunpro then clang and last gcc) ?

Yeh, the order matters ... clang masquerades as GCC pretty thoroughly

J

Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by Leif Hedstrom <zw...@apache.org>.
On 5/1/13 6:58 AM, James Peach wrote:
> On May 1, 2013, at 12:48 AM, Igor Galić <i....@brainsware.org> wrote:
>
>> Following this basic idea here
>>
>>   http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
>>
>> I'd like to add a build/base_compiler.m4 - that runs this program:
>>
>>     # include <stdio.h>
>>     int main (void) {
>>       printf (
>>     #if defined(__clang__)
>>       "clang"
>>     #elif defined (__GNUC__) || defined (__GNUG__)
>>       "gcc"
>>     #elif defined (__SUNPRO_C) || defined (__SUNPRO_CC)
>>       "sunproc"
>>     #elif defined (__ICC) || defined(__INTEL_COMPILER)
>>       "icc"
>>     #endif
>>       );
>>       return 0;
>>     }


In addition to what James said, I think order could matter here. Like, I 
suspect that ICC might define some of the gcc flags in its 
"compatibility" mode. As such, I'd imagine you ought to test for most 
specific first (e.g. icc then sunpro then clang and last gcc) ?

But +1 from me.

-- Leif


Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by James Peach <jp...@apache.org>.
On May 1, 2013, at 10:18 AM, Igor Galić <i....@brainsware.org> wrote:

> 
> 
> ----- Original Message -----
>> Wednesday, May 1, 2013, 8:58:50 AM, you wrote:
>> 
>>> On May 1, 2013, at 12:48 AM, Igor Galić <i....@brainsware.org>
>>> wrote:
>> 
>> 
>>>> Following this basic idea here
>> 
>>>> http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
>> 
>> 
>>> This is a great idea. You should be able to implement it with only
>>> compilation; running a program makes life harder for cross
>>> compiling ...
>> 
>> By wrapping broken code with the appropriate #define and checking for
>> compilation success?
> 
> m4_define([_TS_C_COMPILE_INTEL_testbody], [
> int main (void) {
> # if !defined(__icc) || !defined()
>  This should fail if it's the compiler isn't Intel C/C++ Compiler
> # endif
> }
> ])
> 
> Like so?

Exactly!


Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by Igor Galić <i....@brainsware.org>.

----- Original Message -----
> Wednesday, May 1, 2013, 8:58:50 AM, you wrote:
> 
> > On May 1, 2013, at 12:48 AM, Igor Galić <i....@brainsware.org>
> > wrote:
> 
> 
> >> Following this basic idea here
> 
> >>  http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
> 
> 
> > This is a great idea. You should be able to implement it with only
> > compilation; running a program makes life harder for cross
> > compiling ...
> 
> By wrapping broken code with the appropriate #define and checking for
> compilation success?

m4_define([_TS_C_COMPILE_INTEL_testbody], [
int main (void) {
# if !defined(__icc) || !defined()
  This should fail if it's the compiler isn't Intel C/C++ Compiler
# endif
}
])

Like so?

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE


Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by "Alan M. Carroll" <am...@network-geographics.com>.
Wednesday, May 1, 2013, 8:58:50 AM, you wrote:

> On May 1, 2013, at 12:48 AM, Igor Galić <i....@brainsware.org> wrote:


>> Following this basic idea here

>>  http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros


> This is a great idea. You should be able to implement it with only compilation; running a program makes life harder for cross compiling ...

By wrapping broken code with the appropriate #define and checking for compilation success?


Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by James Peach <ja...@me.com>.
On May 1, 2013, at 12:48 AM, Igor Galić <i....@brainsware.org> wrote:

> 
> Following this basic idea here
> 
>  http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
> 
> I'd like to add a build/base_compiler.m4 - that runs this program:
> 
>    # include <stdio.h>
>    int main (void) {
>      printf (
>    #if defined(__clang__)
>      "clang"
>    #elif defined (__GNUC__) || defined (__GNUG__)
>      "gcc"
>    #elif defined (__SUNPRO_C) || defined (__SUNPRO_CC)
>      "sunproc"
>    #elif defined (__ICC) || defined(__INTEL_COMPILER)
>      "icc"
>    #endif
>      );
>      return 0;
>    }
> 
> To normalize our base_cc which we then can use as before:
> 
>    igalic@tynix /tmp % gcc comp.cc
>    igalic@tynix /tmp % ./a.out
>    gcc%
>    igalic@tynix /tmp % clang comp.cc
>    igalic@tynix /tmp % ./a.out
>    clang%
>    igalic@tynix /tmp %
> 
> 
> Objections?

This is a great idea. You should be able to implement it with only compilation; running a program makes life harder for cross compiling ...


> 
> ----- Original Message -----
>> On Apr 29, 2013, at 11:22 PM, Igor Galić <i....@brainsware.org>
>> wrote:
>> 
>>> 
>>> 
>>> ----- Original Message -----
>>>> Updated Branches:
>>>> refs/heads/master 54b532b64 -> d8c526233
>>>> 
>>>> 
>>>> TS-1864 Rearrange some of the autoconf code, order matters
>>> [snip]
>>>> Branch: refs/heads/master
>>>> Commit: d8c5262331e0654097640982100f43731e7e8f6d
>>>> Parents: 54b532b
>>>> Author: Leif Hedstrom <zw...@apache.org>
>>>> Authored: Mon Apr 29 17:00:51 2013 -0600
>>>> Committer: Leif Hedstrom <zw...@apache.org>
>>>> Committed: Mon Apr 29 22:07:27 2013 -0600
>>> 
>>>> --- a/configure.ac
>>>> +++ b/configure.ac
>>>> @@ -674,10 +720,10 @@ AM_CONDITIONAL([BUILD_HAVE_LIBCXX], [ false
>>>> ])
>>>> 
>>>> base_cc=`basename $CC`
>>>> # These are shortcuts used in combination for the compiler options
>>>> below
>>> 
>>> 
>>> I hope we can all agree that using the compilers name on the
>>> filesystem is a BAD way determine which compiler we're dealing
>>> with.
>> 
>> Yep. Amongst other things, this behaves really badly with clang's
>> scan-build. We have https://issues.apache.org/jira/browse/TS-1838
>> open to address this.
>> 
>> J
> 
> -- 
> Igor Galić
> 
> Tel: +43 (0) 664 886 22 883
> Mail: i.galic@brainsware.org
> URL: http://brainsware.org/
> GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE

Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by Igor Galić <i....@brainsware.org>.
Following this basic idea here

  http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros

I'd like to add a build/base_compiler.m4 - that runs this program:

    # include <stdio.h>
    int main (void) {
      printf (
    #if defined(__clang__)
      "clang"
    #elif defined (__GNUC__) || defined (__GNUG__)
      "gcc"
    #elif defined (__SUNPRO_C) || defined (__SUNPRO_CC)
      "sunproc"
    #elif defined (__ICC) || defined(__INTEL_COMPILER)
      "icc"
    #endif
      );
      return 0;
    }

To normalize our base_cc which we then can use as before:

    igalic@tynix /tmp % gcc comp.cc
    igalic@tynix /tmp % ./a.out
    gcc%
    igalic@tynix /tmp % clang comp.cc
    igalic@tynix /tmp % ./a.out
    clang%
    igalic@tynix /tmp %


Objections?

----- Original Message -----
> On Apr 29, 2013, at 11:22 PM, Igor Galić <i....@brainsware.org>
> wrote:
> 
> > 
> > 
> > ----- Original Message -----
> >> Updated Branches:
> >>  refs/heads/master 54b532b64 -> d8c526233
> >> 
> >> 
> >> TS-1864 Rearrange some of the autoconf code, order matters
> >> 
> > [snip]
> >> Branch: refs/heads/master
> >> Commit: d8c5262331e0654097640982100f43731e7e8f6d
> >> Parents: 54b532b
> >> Author: Leif Hedstrom <zw...@apache.org>
> >> Authored: Mon Apr 29 17:00:51 2013 -0600
> >> Committer: Leif Hedstrom <zw...@apache.org>
> >> Committed: Mon Apr 29 22:07:27 2013 -0600
> > 
> >> --- a/configure.ac
> >> +++ b/configure.ac
> >> @@ -674,10 +720,10 @@ AM_CONDITIONAL([BUILD_HAVE_LIBCXX], [ false
> >> ])
> >> 
> >> base_cc=`basename $CC`
> >> # These are shortcuts used in combination for the compiler options
> >> below
> > 
> > 
> > I hope we can all agree that using the compilers name on the
> > filesystem is a BAD way determine which compiler we're dealing
> > with.
> 
> Yep. Amongst other things, this behaves really badly with clang's
> scan-build. We have https://issues.apache.org/jira/browse/TS-1838
> open to address this.
> 
> J

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE

Re: git commit: TS-1864 Rearrange some of the autoconf code, order matters

Posted by James Peach <jp...@apache.org>.
On Apr 29, 2013, at 11:22 PM, Igor Galić <i....@brainsware.org> wrote:

> 
> 
> ----- Original Message -----
>> Updated Branches:
>>  refs/heads/master 54b532b64 -> d8c526233
>> 
>> 
>> TS-1864 Rearrange some of the autoconf code, order matters
>> 
> [snip]
>> Branch: refs/heads/master
>> Commit: d8c5262331e0654097640982100f43731e7e8f6d
>> Parents: 54b532b
>> Author: Leif Hedstrom <zw...@apache.org>
>> Authored: Mon Apr 29 17:00:51 2013 -0600
>> Committer: Leif Hedstrom <zw...@apache.org>
>> Committed: Mon Apr 29 22:07:27 2013 -0600
> 
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -674,10 +720,10 @@ AM_CONDITIONAL([BUILD_HAVE_LIBCXX], [ false ])
>> 
>> base_cc=`basename $CC`
>> # These are shortcuts used in combination for the compiler options
>> below
> 
> 
> I hope we can all agree that using the compilers name on the
> filesystem is a BAD way determine which compiler we're dealing with.

Yep. Amongst other things, this behaves really badly with clang's scan-build. We have https://issues.apache.org/jira/browse/TS-1838 open to address this.

J