pkgsrc-Bugs archive

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

Re: pkg/53170: get_compiler fails to detect clang if it's not named "gcc" in $PATH



The following reply was made to PR pkg/53170; it has been noted by GNATS.

From: Keivan Motavalli <keivan%motavalli.me@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: pkg/53170: get_compiler fails to detect clang if it's not named "gcc" in $PATH
Date: Mon, 09 Apr 2018 11:10:32 +0200

 On Sunday, April 8, 2018 8:40:01 PM CEST you wrote:
 >  I also tested my patch as working on OpenBSD 6.2 and 6.3 and it doesn't
 >  break FreeBSD 11.1. I haven't tested for Darwin yet
 
 It doesn't work under Darwin (Mac OS 10.13): cc -E doesn't output anything to 
 stdout when running the preprocessor.
 
 furthermore, I had left a stray "indeed" in the original patch.
 
 --- a/bootstrap/bootstrap
 +++ b/bootstrap/bootstrap
 @@ -134,37 +134,21 @@ get_compiler()
  	# normally, we'd just use 'cc', but certain configure tools look
  	# for gcc specifically, so we have to see if that comes first
  	if [ -z "${testcc}" ]; then
 -		save_IFS="${IFS}"
 -		IFS=':'
 -		for dir in ${PATH}; do
 -			test -z "$dir" && dir=.
 -			if [ -x "$dir/gcc" ]; then
 -				testcc="$dir/gcc"
 -				break
 -			fi
 -		done
 -		IFS="${save_IFS}"
 -	fi
 -
  	# Clang compiler pretends to be GCC, so we have to check that
 -	cat >${wrkdir}/$$.c <<EOF
 -#ifdef __clang__
 -indeed
 -#endif
 -EOF
 -	compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c 
 indeed`
 -	rm -f ${wrkdir}/$$.c
 -
 -	cat >${wrkdir}/$$.c <<EOF
 -#ifdef __GNUC__
 -#ifndef __clang__
 -indeed
 +		cat >${wrkdir}/$$.c <<EOF
 +#define GCC_COMPILER (defined(__GNUC__) && !defined(__clang__))
 +#if GCC_COMPILER
 +gcc
  #endif
 +#ifdef __clang__
 +clang
  #endif
  EOF
 -	compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c 
 indeed`
 -	rm -f ${wrkdir}/$$.c
 -
 +		compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c 
 gcc`
 +		compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c 
 clang`
 +		rm -f ${wrkdir}/$$.c
 +	fi
 +	
  }
  get_abi()
  {
 @@ -776,6 +760,7 @@ OpenBSD)
  	need_awk=no
  	need_sed=no
  	set_opsys=no
 +	check_compiler=yes
  	machine_arch=`arch -s`
  	;;
  OSF1)
 
 
 


Home | Main Index | Thread Index | Old Index