pkgsrc-Bugs archive

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

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



>Number:         53170
>Category:       pkg
>Synopsis:       get_compiler fails to detect clang if it's not named "gcc" in $PATH
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 08 17:25:00 +0000 2018
>Originator:     keivan motavalli
>Release:        trunk/06-apr-2018
>Organization:
>Environment:
OpenBSD 6.3 GENERIC#100 amd64
>Description:
pkgsrc fails to bootstrap on recent OpenBSD releases because of a circular dependency on gcc3-c when compiling cwrappers as part of the procedure.

further fixes already discussed on pkgsrc-users are then needed to compile pkgtools/libarchive against LibreSSL >= 2.7, included in OpenBSD 6.3.

a known workaround for the circular dependency problem is to run the bootstrap script with --compiler clang, default C compiler since OpenBSD 6.2

modifying the bootstrap script to set check_compiler=yes when running in OpenBSD fails to detect clang and sets pkgsrc to use gcc.

this is because the system comes with both gcc (/usr/bin/gcc) and clang (/usr/bin/cc, /usr/bin/clang) installed, while the get_compiler() function first checks if a gcc executable exists in $PATH, then tests if it identifies as clang, so it tests the real gcc compiler reporting that clang is not present on the system.

the attached patch avoids searching for gcc and tests the default cc to identify it as either gcc or clang.

it doesn't explicitly search for gcc in $PATH anymore, but that search could be restored after the check on 'cc' if required.
 
>How-To-Repeat:
set check_compiler=yes when running on OpenBSD 6.2+ and run the bootstrap script
>Fix:
--- 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__))indeed
+#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