From patchwork Mon Jan 4 10:54:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sedat Dilek X-Patchwork-Id: 7946941 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 340E49F1C0 for ; Mon, 4 Jan 2016 10:54:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AE8A2035D for ; Mon, 4 Jan 2016 10:54:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2003920266 for ; Mon, 4 Jan 2016 10:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751728AbcADKyt (ORCPT ); Mon, 4 Jan 2016 05:54:49 -0500 Received: from mail-vk0-f54.google.com ([209.85.213.54]:33593 "EHLO mail-vk0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751188AbcADKyr (ORCPT ); Mon, 4 Jan 2016 05:54:47 -0500 Received: by mail-vk0-f54.google.com with SMTP id a188so248241572vkc.0; Mon, 04 Jan 2016 02:54:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:date:message-id:subject:from:to:cc :content-type; bh=WxszEMIjAQAfwIhcTGFsGEGiciVXXdcNBwvYsHFHdUI=; b=V49yFYAMhZuf5q3bQ6R3cnI+eJHTsHet+OlEKsJ+tXb6rKWA4N3wEm+vAu0ewacKIz WTg4lJ7qAZkXJlNeRcphAkjHO4aMjOXh3b/8Kyf7fi1eIkA0JKsSzRZj25UBWVMnGFiH zN8wQwe+cKgg9fKx03zQjF2eNPhYRnjC6LSSmoMtJl97WlMNr/Fct0H/WErBbjI9c3GM wwUVcIR/oxY48FmU4C3il1dNqfupJgrctoU4ikAHTwi0SM+r57tM4ANYmJE0RrfyWVei TEWmZKO51WlAgkX/j6H7QMN4AKl90/S7eqynwIw8RD6rBMGmRTIKkgPNtHiTVov77WN3 2DaA== MIME-Version: 1.0 X-Received: by 10.31.155.23 with SMTP id d23mr53183913vke.146.1451904886525; Mon, 04 Jan 2016 02:54:46 -0800 (PST) Received: by 10.103.82.146 with HTTP; Mon, 4 Jan 2016 02:54:46 -0800 (PST) Reply-To: sedat.dilek@gmail.com Date: Mon, 4 Jan 2016 11:54:46 +0100 Message-ID: Subject: Thoughts about introducing OPTIMIZATION_CFLAG From: Sedat Dilek To: Linus Torvalds , Andrew Morton , Michal Marek , Sam Ravnborg , "Rafael J. Wysocki" , Arnd Bergmann , Ingo Molnar Cc: linux-kbuild@vger.kernel.org, Linux ACPI , LKML , "the arch/x86 maintainers" Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP [ Not sure if I have addressed all the correct people and mailing-lists ] Hi, while still digging into a llvmlinux issue with workqueue I saw that the wrong optimization compiler-flag was used on x86 architecture and acpi subsystem. CLANG requires '-Oz' whereas GCC requires '-Os'. As acpi-daemon was throwing out the regression I looked by accident over the *_CFLAGS. As said... I checked only for x86 and acpi only. For example '-Os' is hardcoded in... arch/x86/Makefile arch/x86/purgatory/Makefile drivers/acpi/Makefile drivers/acpi/acpica/Makefile For acpi part we have currently both used '-O2' and '-Os' ('-Oz' for llvmlinux) in approx 200 make-lines. $ grep '\-O2' build-log_4.4.0-rc8-2-llvmlinux-amd64.txt | grep acpi | wc -l 226 $ grep '\-Oz' build-log_4.4.0-rc8-2-llvmlinux-amd64.txt | grep acpi | grep '\-O2' | wc -l 200 So, which optimization-cflags is now used if I have both in one make-line (and how can I check this)? [ EXAMPLE ] $ mycompiler --version clang version 3.7.0 (tags/RELEASE_370/final) Target: x86_64-unknown-linux-gnu Thread model: posix $ mycompiler -Wp,-MD,drivers/acpi/.video_detect.o.d -nostdinc -isystem /opt/llvm-toolchain-3.7.0/bin/../lib/clang/3.7.0/include -nostdinc -isystem /opt/llvm-toolchain-3.7.0/bin/../lib/clang/3.7.0/include -I./arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Qunused-arguments -Wno-unknown-warning-option -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -no-integrated-as -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables *** -O2 *** -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-variable -Wno-format-invalid-specifier -Wno-gnu -Wno-asm-operand-widths -Wno-initializer-overrides -fno-builtin -Wno-tautological-compare -mno-global-merge -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Wno-initializer-overrides -Wno-unused-value -Wno-format -Wno-unknown-warning-option -Wno-sign-compare -Wno-format-zero-length -Wno-uninitialized *** -Oz *** -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(video_detect)" -D"KBUILD_MODNAME=KBUILD_STR(video)" -c -o drivers/acpi/.tmp_video_detect.o drivers/acpi/video_detect.c How can I switch a optimization-cflags for certain code-parts in the Linux-kernel (with or without the kbuild-system)? ( So the default optimization-cflags is '-O2' whereas parts wants '-Os'. ) What to do when using CONFIG_CC_OPTIMIZE_FOR_SIZE=y which sets '-Os' explicitly? Below tools/ directory we have also an OPTIMIZATION variable used. Something like a "global" solution is desired from my side. I have attached a patchset on top of my llvmlinux-amd64-fixes-4.4, hope this helps a bit to see what I mean. It is not doing what I desire - still WIP. Thoughts? Thanks in advance. Regards, - Sedat - From 3ed0fdeafd219518ceff601cbb4df562c09374da Mon Sep 17 00:00:00 2001 From: Sedat Dilek Date: Mon, 4 Jan 2016 11:42:58 +0100 Subject: [PATCH 3/3] acpi: llvmlinux: Use OPTIMIZATION_CFLAGS Signed-off-by: Sedat Dilek --- drivers/acpi/Makefile | 4 +++- drivers/acpi/acpica/Makefile | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 675eaf337178..8a52558da32d 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -2,7 +2,9 @@ # Makefile for the Linux ACPI interpreter # -ccflags-y := -Os +OPTIMIZATION_CFLAGS := $(call cc-option,-Oz,-Os) + +ccflags-y := $(OPTIMIZATION_CFLAGS) ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT # diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 885936f79542..44b4648ccb46 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile @@ -2,7 +2,9 @@ # Makefile for ACPICA Core interpreter # -ccflags-y := -Os -DBUILDING_ACPICA +OPTIMIZATION_CFLAGS := $(call cc-option,-Oz,-Os) + +ccflags-y := $(OPTIMIZATION_CFLAGS) -DBUILDING_ACPICA ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT # use acpi.o to put all files here into acpi.o modparam namespace -- 2.6.4