Thread (42 messages) 42 messages, 6 authors, 2018-04-14

Re: [PATCH] Makefile: detect compiler and enable more warnings in DEVELOPER=1

From: Eric Sunshine <hidden>
Date: 2018-03-18 09:06:19
Subsystem: the rest · Maintainer: Linus Torvalds

On Sun, Mar 18, 2018 at 09:18:34AM +0100, Nguyễn Thái Ngọc Duy wrote:
quoted hunk ↗ jump to hunk
The set of extra warnings we enable when DEVELOPER has to be
conservative because we can't assume any compiler version the
developer may use. Detect the compiler version so we know when it's
safe to enable -Wextra and maybe more.

Helped-by: Jeff King [off-list ref]
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
diff --git a/detect-compiler b/detect-compiler
--- /dev/null
+++ b/detect-compiler
@@ -0,0 +1,50 @@
+get_version_line() {
+	"$CC" -v 2>&1 | grep ' version '
+}
On MacOS, "cc -v" output is:
--- >8 ---
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: ...
--- >8 ---
+get_family() {
+	get_version_line | sed 's/^\(.*\) version [0-9][^ ]* .*/\1/'
+}
So, this returns "Apple LLVM".
+case "$(get_family)" in
+gcc)
+	print_flags gcc
+	;;
+*clang)
+	print_flags clang
+	;;
+"FreeBSD clang")
+	print_flags clang
+	;;
+*)
+	: unknown compiler family
+	;;
+esac
Which means you probably want to squash in:
--- >8 ---
diff --git a/detect-compiler b/detect-compiler
index bc2ea39ef5..3140416b40 100755
--- a/detect-compiler
+++ b/detect-compiler
@@ -41,6 +41,9 @@ gcc)
 *clang)
 	print_flags clang
 	;;
+"Apple LLVM")
+	print_flags clang
+	;;
 "FreeBSD clang")
 	print_flags clang
 	;;
--- >8 ---
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help