Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1300628

Thoughts about introducing OPTIMIZATION_CFLAG

From Sedat Dilek <sedat.dilek@gmail.com>
Newsgroups linux.kernel
Subject Thoughts about introducing OPTIMIZATION_CFLAG
Date 2016-01-04 12:00 +0100
Message-ID <qNb1M-2kn-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

[ 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 -

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-04 12:00 +0100
  Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-04 12:30 +0100
  Re: Thoughts about introducing OPTIMIZATION_CFLAG One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-01-04 12:40 +0100
    Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-04 12:50 +0100
      Re: Thoughts about introducing OPTIMIZATION_CFLAG Michal Marek <mmarek@suse.cz> - 2016-01-04 23:40 +0100
        Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-08 11:10 +0100
          Re: Thoughts about introducing OPTIMIZATION_CFLAG Michal Marek <mmarek@suse.cz> - 2016-01-08 12:40 +0100
            Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-08 12:50 +0100
              Re: Thoughts about introducing OPTIMIZATION_CFLAG Michal Marek <mmarek@suse.cz> - 2016-01-08 13:40 +0100
                Re: Thoughts about introducing OPTIMIZATION_CFLAG Sedat Dilek <sedat.dilek@gmail.com> - 2016-01-08 14:30 +0100

csiph-web