From patchwork Wed Nov 1 00:56:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 10035801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D17F603B5 for ; Wed, 1 Nov 2017 00:56:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02FDE28ADD for ; Wed, 1 Nov 2017 00:56:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9AA228AEB; Wed, 1 Nov 2017 00:56:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AD1328ADD for ; Wed, 1 Nov 2017 00:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751931AbdKAA4t (ORCPT ); Tue, 31 Oct 2017 20:56:49 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:49770 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbdKAA4s (ORCPT ); Tue, 31 Oct 2017 20:56:48 -0400 Received: by mail-yw0-f196.google.com with SMTP id z195so639066ywz.6 for ; Tue, 31 Oct 2017 17:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=lCp3K35TlFT8gAm4/l3sce2kgKqBxxfLAGKZS14TK6k=; b=MzKUUCi361fzfUuXxiRlSh/qRNjP9f8o/tnGrhsgSbMbUYcfSyI0cUgJOP0hkvZCWc V8v+Ei30UA0UpsxufmmB2M1EVKsakDMXnEkufNNLJ1cjYgAWgJsLUVnV7OBC3XBFI5gj N7tcue0oKnYEH4Trwf1ZuCnXxiVkGFYgbPI56eAtsa8W1d7FmVHfwTNTBfn6Az5i/tQL 63owN8Kwvn7eyqjp2r1eZyTRy4WBSY5O784HGP/sQvNyXKAyuG1T1Oi5Zu6gsMlYKu7Z YyOjsBQAZcoifQDJoJihDr3dwX+HHDLRfIyBELoPHLJa51tXYPYjMH09mnODbGXAvuzP JSuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=lCp3K35TlFT8gAm4/l3sce2kgKqBxxfLAGKZS14TK6k=; b=Tyok6NLxu7ee4PWNRYlHMF51FT3+U5M6UN2QahAIkWB5pQTRAZrOluekF/tJX1a6c8 afG5QUH3dZS1W/J+TLL6Q2QsVi56kofzi0fOWlBgkwt6ymQiHuzD+bdvfd998LiGCyGz kBiJB7OjppFKIXrpfQbNKks1dXfDGGmEnM3PBzdxQ/toLaS/Dx0R7R1LPGS2TG+DU71h gqhVhpb6rA1KR2ymIlPdb4//WFVKiTp7+awymFILOY+49VyFwM21CFBz6HNj/Ffm/DiA 2VcMuzQMbMXgLuXKvm+27m6s0QR8yKqzbyrQPSEt0HWFrnrGhpjdDxzhxAtgkyJJyQJ3 /38Q== X-Gm-Message-State: AMCzsaUXRDKA14YBA7eo5GaSfwMXrN//KLuh5NK3LcwCM1/9atbIRevd 2NbB+X/I0asIlhxWJa3VnKUs4JgDGrNIHA+IhPSH X-Google-Smtp-Source: ABhQp+TG6+OVxK+OsqmGT91jxMIfeEk3PIWEd6VxcAci2AyfcJDXiZIdzURLO3ZG3pUkMVtKEMenkKlLNaPSBJHl92o= X-Received: by 10.13.229.131 with SMTP id o125mr2362748ywe.377.1509497808124; Tue, 31 Oct 2017 17:56:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.103.133 with HTTP; Tue, 31 Oct 2017 17:56:47 -0700 (PDT) In-Reply-To: <1509476260.4553.45.camel@kernel.org> References: <20171025100222.5983-1-jlayton@kernel.org> <20171025142009.foxh2rblmfpxvm7d@ltop.local> <1509019885.29077.6.camel@kernel.org> <1509476260.4553.45.camel@kernel.org> From: Christopher Li Date: Tue, 31 Oct 2017 20:56:47 -0400 X-Google-Sender-Auth: lSCawNBCsV9gu2OQemilWplahKw Message-ID: Subject: Re: [PATCH] build: clean up $CFLAGS handling in the makefile To: Jeff Layton Cc: Luc Van Oostenryck , Linux-Sparse Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Oct 31, 2017 at 2:57 PM, Jeff Layton wrote: > As Luc and Josh pointed out, I think we want $(CFLAGS) last here. That > allows you to pass in options that can supersede what the makefile puts > in there. > ...other than that, I'm fine with this. Assuming you fix that, you can > add: I update the patch here and git url: https://git.kernel.org/pub/scm/devel/sparse/chrisl/sparse.git/log/?h=cflags-v2 Chris From 55496234238e127c05807550fb432e1125a85710 Mon Sep 17 00:00:00 2001 From: Christopher Li Date: Sun, 29 Oct 2017 19:16:44 +0800 Subject: [PATCH] Makefile: provide CFLAGS for command line override. Avoid assign to CFLAGS in Makefile. Rename BASIC_CFLAGS to COMMON_CFLAGS. Use PKG_CFLAGS to store external package related cflags. Signed-off-by: Christopher Li Acked-by: Jeff Layton --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) $(LLVM_VERSION) installed.) diff --git a/Makefile b/Makefile index d0341764..66cb1ae1 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,8 @@ OS = linux CC = gcc -CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g -CFLAGS += -Wall -Wwrite-strings +COMMON_CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g +COMMON_CFLAGS += -Wall -Wwrite-strings LDFLAGS += -g LD = gcc AR = ar @@ -21,7 +21,7 @@ PKG_CONFIG = pkg-config CHECKER = ./cgcc -no-compile CHECKER_FLAGS = -ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) +ALL_CFLAGS = $(COMMON_CFLAGS) $(PKG_CFLAGS) $(CFLAGS) # # For debugging, put this in local.mk: # @@ -44,13 +44,13 @@ LLVM_CONFIG:=llvm-config HAVE_LLVM:=$(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo 'yes') GCC_BASE := $(shell $(CC) --print-file-name=) -BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\" +COMMON_CFLAGS += -DGCC_BASE=\"$(GCC_BASE)\" MULTIARCH_TRIPLET := $(shell $(CC) -print-multiarch 2>/dev/null) -BASIC_CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\" +COMMON_CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\" ifeq ($(HAVE_GCC_DEP),yes) -BASIC_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d +COMMON_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d endif DESTDIR= @@ -83,7 +83,7 @@ PROGRAMS += test-inspect INST_PROGRAMS += test-inspect test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o test-inspect_OBJS := test-inspect.o $(test-inspect_EXTRA_DEPS) -$(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc): CFLAGS += $(GTK_CFLAGS) +$(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc): PKG_CFLAGS += $(GTK_CFLAGS) test-inspect_EXTRA_OBJS := $(GTK_LIBS) else $(warning Your system does not have gtk3/gtk2, disabling test-inspect) @@ -101,7 +101,7 @@ LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs) LLVM_LIBS += $(shell $(LLVM_CONFIG) --system-libs 2>/dev/null) PROGRAMS += $(LLVM_PROGS) INST_PROGRAMS += sparse-llvm sparsec -sparse-llvm.o: BASIC_CFLAGS += $(LLVM_CFLAGS) +sparse-llvm.o: PKG_CFLAGS += $(LLVM_CFLAGS) sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS) else $(warning LLVM 3.0 or later required. Your system has version