From patchwork Tue Feb 12 22:03:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 2132271 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 53AEEDFB7B for ; Tue, 12 Feb 2013 22:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754241Ab3BLWDt (ORCPT ); Tue, 12 Feb 2013 17:03:49 -0500 Received: from avon.wwwdotorg.org ([70.85.31.133]:34439 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752278Ab3BLWDt (ORCPT ); Tue, 12 Feb 2013 17:03:49 -0500 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 4B4AD6205; Tue, 12 Feb 2013 15:06:49 -0700 (MST) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 6B7C2E40F8; Tue, 12 Feb 2013 15:03:46 -0700 (MST) From: Stephen Warren To: Grant Likely , Rob Herring Cc: devicetree-discuss@lists.ozlabs.org, Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Warren Subject: [PATCH] kbuild: limit dtc+cpp include path Date: Tue, 12 Feb 2013 15:03:37 -0700 Message-Id: <1360706617-20276-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.7.10.4 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Stephen Warren Device tree source files may now include header files. The intent is that those header files define/name constants used as part of the DT bindings. Currently this feature is open to abuse, since any kernel header file at all can be included, This could allow device tree files to become dependant on kernel headers files, and thus make them no longer OS-independent. This would also prevent separating the device tree source files from the kernel repository. Solve this by limiting the cpp include path for device tree files to separate directories. Signed-off-by: Stephen Warren --- Here, I allow header files in the .dts source directory, or in a per-arch include directory. Perhaps rather than: -I$(srctree)/arch/$(SRCARCH)/include/dts The following might be better?: -I$(srctree)/Documentation/devicetree/bindings i.e. is there a need to separate binding-related headers per arch? scripts/Makefile.lib | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7910229..07125e6 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -156,6 +156,11 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ ld_flags = $(LDFLAGS) $(ldflags-y) +dtc_cpp_flags = -Wp,-MD,$(depfile) -nostdinc \ + -I$(srctree)/arch/$(SRCARCH)/boot/dts \ + -I$(srctree)/arch/$(SRCARCH)/include/dts \ + -undef -D__DTS__ + # Finds the multi-part object the current object will be linked into modname-multi = $(sort $(foreach m,$(multi-used),\ $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) @@ -272,8 +277,7 @@ $(obj)/%.dtb: $(src)/%.dts FORCE dtc-tmp = $(subst $(comma),_,$(dot-target).dts) quiet_cmd_dtc_cpp = DTC+CPP $@ -cmd_dtc_cpp = $(CPP) $(cpp_flags) -x assembler-with-cpp -undef -D__DTS__ \ - -o $(dtc-tmp) $< ; \ +cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $(dtc-tmp) $(obj)/%.dtb: $(src)/%.dtsp FORCE