Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1505799 > unrolled thread
| Started by | Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
|---|---|
| First post | 2016-10-21 13:20 +0200 |
| Last post | 2016-10-24 12:00 +0200 |
| Articles | 11 — 4 participants |
Back to article view | Back to linux.kernel
[RFC PATCH] kbuild: add -fno-PIE Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-21 13:20 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Adam Borowski <kilobyte@angband.pl> - 2016-10-21 23:30 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Sven Joachim <svenjoac@gmx.de> - 2016-10-23 18:30 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Joe Perches <joe@perches.com> - 2016-10-23 21:30 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Sven Joachim <svenjoac@gmx.de> - 2016-10-24 09:40 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-24 09:50 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Sven Joachim <svenjoac@gmx.de> - 2016-10-24 19:40 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Joe Perches <joe@perches.com> - 2016-10-24 19:50 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-10-25 09:40 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Sven Joachim <svenjoac@gmx.de> - 2016-10-26 20:00 +0200
Re: [RFC PATCH] kbuild: add -fno-PIE Joe Perches <joe@perches.com> - 2016-10-24 12:00 +0200
| From | Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
|---|---|
| Date | 2016-10-21 13:20 +0200 |
| Subject | [RFC PATCH] kbuild: add -fno-PIE |
| Message-ID | <suG1I-4Ml-39@gated-at.bofh.it> |
Debian started to build the gcc with --enable-default-pie by default so the kernel build ends before it starts properly with: |kernel/bounds.c:1:0: error: code model kernel does not support PIC mode Is this okay or do we want some kind of check to see if -fno-PIE is supported? It is mentioned in the 4.4.7 gcc manpage is it is not *that* new :) Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bf6e44a421df..97296d66b586 100644 --- a/Makefile +++ b/Makefile @@ -398,7 +398,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ - -Wno-format-security \ + -Wno-format-security -fno-PIE \ -std=gnu89 KBUILD_AFLAGS_KERNEL := -- 2.9.3
[toc] | [next] | [standalone]
| From | Adam Borowski <kilobyte@angband.pl> |
|---|---|
| Date | 2016-10-21 23:30 +0200 |
| Message-ID | <suPy2-2Jv-27@gated-at.bofh.it> |
| In reply to | #1505799 |
On Fri, Oct 21, 2016 at 01:16:00PM +0200, Sebastian Andrzej Siewior wrote: > Debian started to build the gcc with --enable-default-pie by default To be exact: this is since gcc-6 6.2.0-7 dated Tue, 18 Oct 2016 13:53:00 +0200 on amd64 arm64 armel armhf i386 mips mipsel mips64el ppc64el s390x. > so the kernel build ends before it starts properly with: > |kernel/bounds.c:1:0: error: code model kernel does not support PIC mode > > Is this okay or do we want some kind of check to see if -fno-PIE is supported? > It is mentioned in the 4.4.7 gcc manpage is it is not *that* new :) A naive "git log -Sno-PIE" on gcc sources shows commit 3e7f6cce[1] from Feb 2004, and as gcc automatically supports no-XXX whenever XXX is added, it appears the option is older than that. > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> > --- > Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index bf6e44a421df..97296d66b586 100644 > --- a/Makefile > +++ b/Makefile > @@ -398,7 +398,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__ > KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ > -fno-strict-aliasing -fno-common \ > -Werror-implicit-function-declaration \ > - -Wno-format-security \ > + -Wno-format-security -fno-PIE \ > -std=gnu89 > > KBUILD_AFLAGS_KERNEL := > -- > 2.9.3 The patch works for me. I haven't done any but most trivial testing, though. [1]. Using the https://gcc.gnu.org/git/gcc.git git gateway, commit hashes may be different elsewhere. -- A MAP07 (Dead Simple) raspberry tincture recipe: 0.5l 95% alcohol, 1kg raspberries, 0.4kg sugar; put into a big jar for 1 month. Filter out and throw away the fruits (can dump them into a cake, etc), let the drink age at least 3-6 months.
[toc] | [prev] | [next] | [standalone]
| From | Sven Joachim <svenjoac@gmx.de> |
|---|---|
| Date | 2016-10-23 18:30 +0200 |
| Message-ID | <svtON-3hR-1@gated-at.bofh.it> |
| In reply to | #1506310 |
On 2016-10-21 23:21 +0200, Adam Borowski wrote:
> On Fri, Oct 21, 2016 at 01:16:00PM +0200, Sebastian Andrzej Siewior wrote:
>> Debian started to build the gcc with --enable-default-pie by default
>
> To be exact: this is since gcc-6 6.2.0-7 dated Tue, 18 Oct 2016 13:53:00 +0200
> on amd64 arm64 armel armhf i386 mips mipsel mips64el ppc64el s390x.
>
>> so the kernel build ends before it starts properly with:
>> |kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
>>
>> Is this okay or do we want some kind of check to see if -fno-PIE is supported?
>> It is mentioned in the 4.4.7 gcc manpage is it is not *that* new :)
>
> A naive "git log -Sno-PIE" on gcc sources shows commit 3e7f6cce[1] from Feb
> 2004, and as gcc automatically supports no-XXX whenever XXX is added, it
> appears the option is older than that.
Testing on Debian 3.1 (sarge) chroot, it seems that GCC 3.4 is the first
release to accept -fPIE/-fno-PIE. Which could be a problem since
according to Documentation/Changes GCC 3.2 is sufficient to build the
kernel.
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> ---
>> Makefile | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index bf6e44a421df..97296d66b586 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -398,7 +398,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__
>> KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>> -fno-strict-aliasing -fno-common \
>> -Werror-implicit-function-declaration \
>> - -Wno-format-security \
>> + -Wno-format-security -fno-PIE \
>> -std=gnu89
>>
>> KBUILD_AFLAGS_KERNEL :=
>> --
>> 2.9.3
>
> The patch works for me. I haven't done any but most trivial testing,
> though.
>
>
> [1]. Using the https://gcc.gnu.org/git/gcc.git git gateway, commit hashes
> may be different elsewhere.
Cheers,
Sven
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-10-23 21:30 +0200 |
| Message-ID | <svwCZ-51I-5@gated-at.bofh.it> |
| In reply to | #1506722 |
On Sun, 2016-10-23 at 18:19 +0200, Sven Joachim wrote: > On 2016-10-21 23:21 +0200, Adam Borowski wrote: > > On Fri, Oct 21, 2016 at 01:16:00PM +0200, Sebastian Andrzej Siewior wrote: > > > Debian started to build the gcc with --enable-default-pie by default [] > > > diff --git a/Makefile b/Makefile [] > > > @@ -398,7 +398,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__ > > > KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ > > > -fno-strict-aliasing -fno-common \ > > > -Werror-implicit-function-declaration \ > > > - -Wno-format-security \ > > > + -Wno-format-security -fno-PIE \ > > > -std=gnu89 I've used this here instead: KBUILD_CFLAGS += $(call cc-option,-fno-pie)
[toc] | [prev] | [next] | [standalone]
| From | Sven Joachim <svenjoac@gmx.de> |
|---|---|
| Date | 2016-10-24 09:40 +0200 |
| Message-ID | <svI1s-4up-13@gated-at.bofh.it> |
| In reply to | #1506745 |
On 2016-10-23 12:23 -0700, Joe Perches wrote:
> On Sun, 2016-10-23 at 18:19 +0200, Sven Joachim wrote:
>> On 2016-10-21 23:21 +0200, Adam Borowski wrote:
>> > On Fri, Oct 21, 2016 at 01:16:00PM +0200, Sebastian Andrzej Siewior wrote:
>> > > Debian started to build the gcc with --enable-default-pie by default
> []
>> > > diff --git a/Makefile b/Makefile
> []
>> > > @@ -398,7 +398,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__
>> > > KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>> > > -fno-strict-aliasing -fno-common \
>> > > -Werror-implicit-function-declaration \
>> > > - -Wno-format-security \
>> > > + -Wno-format-security -fno-PIE \
>> > > -std=gnu89
>
> I've used this here instead:
>
> KBUILD_CFLAGS += $(call cc-option,-fno-pie)
Where exactly do you set that? I tried this patch:
--8<---------------cut here---------------start------------->8---
diff --git a/Makefile b/Makefile
index 93beca4..fde1e21 100644
--- a/Makefile
+++ b/Makefile
@@ -619,6 +619,7 @@ ARCH_AFLAGS :=
ARCH_CFLAGS :=
include arch/$(SRCARCH)/Makefile
+KBUILD_CFLAGS += $(call cc-option,-fno-pie,)
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
--8<---------------cut here---------------end--------------->8---
But make still fails with it. :-(
,----
| $ LANG=C make
| scripts/kconfig/conf --silentoldconfig Kconfig
| SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_32.h
| SYSHDR arch/x86/entry/syscalls/../../include/generated/asm/unistd_32_ia32.h
| SYSHDR arch/x86/entry/syscalls/../../include/generated/asm/unistd_64_x32.h
| SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_64.h
| SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_32.h
| SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_64.h
| SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_x32.h
| HOSTCC arch/x86/tools/relocs_32.o
| HOSTCC arch/x86/tools/relocs_64.o
| HOSTCC arch/x86/tools/relocs_common.o
| HOSTLD arch/x86/tools/relocs
| CHK include/config/kernel.release
| UPD include/config/kernel.release
| Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong available but compiler is broken
| Makefile:1066: recipe for target 'prepare-compiler-check' failed
| make: *** [prepare-compiler-check] Error 1
`----
Cheers,
Sven
[toc] | [prev] | [next] | [standalone]
| From | Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
|---|---|
| Date | 2016-10-24 09:50 +0200 |
| Message-ID | <svIb7-4yd-7@gated-at.bofh.it> |
| In reply to | #1506963 |
On 2016-10-24 09:38:49 [+0200], Sven Joachim wrote: > > But make still fails with it. :-( try setting CONFIG_CC_STACKPROTECTOR_NONE=y and please let me know if the resulting kernel built with v3.2 gcc boots & works. > > Cheers, > Sven Sebastian
[toc] | [prev] | [next] | [standalone]
| From | Sven Joachim <svenjoac@gmx.de> |
|---|---|
| Date | 2016-10-24 19:40 +0200 |
| Message-ID | <svRo6-2jl-33@gated-at.bofh.it> |
| In reply to | #1506965 |
[Multipart message — attachments visible in raw view] — view raw
On 2016-10-24 09:43 +0200, Sebastian Andrzej Siewior wrote:
> On 2016-10-24 09:38:49 [+0200], Sven Joachim wrote:
>>
>> But make still fails with it. :-(
>
> try setting CONFIG_CC_STACKPROTECTOR_NONE=y and please let me know if
> the resulting kernel built with v3.2 gcc boots & works.
Sorry, I don't have gcc 3.2 around, and my gcc 3.3 environment produces
assembler errors in arch/x86/entry/entry_32.S. Maybe binutils 2.15 is
not recent enough anymore?
Anyway, with CONFIG_CC_STACKPROTECTOR=y it is necessary to add -fno-pie
in scripts/gcc-x86_64-has-stack-protector.sh as well, because that
script invokes the compiler without KBUILD_CFLAGS. That's probably not
a problem since -fstack-protector is newer than -fno-pie. The attached
patch works for me with Debian's gcc-6 package.
Cheers,
Sven
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-10-24 19:50 +0200 |
| Message-ID | <svRxM-2mA-23@gated-at.bofh.it> |
| In reply to | #1507486 |
On Mon, 2016-10-24 at 19:32 +0200, Sven Joachim wrote:
(in the attachment)
> +KBUILD_CFLAGS += $(call cc-option,-fno-pie,)
trivia:
The trailing comma is not necessary though the Makefile
is a bit inconsistent about this.
$ git grep "KBUILD_CFLAGS.*call cc-option" Makefile
Makefile:KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
Makefile:KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,)
Makefile:KBUILD_CFLAGS += $(call cc-option,-fdata-sections,)
Makefile:KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
Makefile:KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
Makefile:KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
Makefile:KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
Makefile:KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
Makefile:KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments)
Makefile:KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g)
Makefile:KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,)
Makefile:KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
Makefile:KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
Makefile:KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
Makefile:KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
Makefile:KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
Makefile:KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int)
Makefile:KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes)
Makefile:KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
Makefile:KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
[toc] | [prev] | [next] | [standalone]
| From | Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
|---|---|
| Date | 2016-10-25 09:40 +0200 |
| Message-ID | <sw4uZ-2vP-15@gated-at.bofh.it> |
| In reply to | #1507486 |
On 2016-10-24 19:32:30 [+0200], Sven Joachim wrote: > On 2016-10-24 09:43 +0200, Sebastian Andrzej Siewior wrote: > > > On 2016-10-24 09:38:49 [+0200], Sven Joachim wrote: > >> > >> But make still fails with it. :-( > > > > try setting CONFIG_CC_STACKPROTECTOR_NONE=y and please let me know if > > the resulting kernel built with v3.2 gcc boots & works. > > Sorry, I don't have gcc 3.2 around, and my gcc 3.3 environment produces > assembler errors in arch/x86/entry/entry_32.S. Maybe binutils 2.15 is > not recent enough anymore? so we use stone age gcc but take latest binutils and kernel? What about lifting the limit of gcc 3.2? Is there any use case in 2016 to use gcc 3.2 on a recent kernel except whether it still compiles or not? Sebastian
[toc] | [prev] | [next] | [standalone]
| From | Sven Joachim <svenjoac@gmx.de> |
|---|---|
| Date | 2016-10-26 20:00 +0200 |
| Message-ID | <swAEx-73J-17@gated-at.bofh.it> |
| In reply to | #1508034 |
On 2016-10-25 09:30 +0200, Sebastian Andrzej Siewior wrote:
> On 2016-10-24 19:32:30 [+0200], Sven Joachim wrote:
>> On 2016-10-24 09:43 +0200, Sebastian Andrzej Siewior wrote:
>>
>> > On 2016-10-24 09:38:49 [+0200], Sven Joachim wrote:
>> >>
>> >> But make still fails with it. :-(
>> >
>> > try setting CONFIG_CC_STACKPROTECTOR_NONE=y and please let me know if
>> > the resulting kernel built with v3.2 gcc boots & works.
>>
>> Sorry, I don't have gcc 3.2 around, and my gcc 3.3 environment produces
>> assembler errors in arch/x86/entry/entry_32.S. Maybe binutils 2.15 is
>> not recent enough anymore?
I have done a few more tests, and I can confirm that binutils 2.17 is
the oldest version that works. Also, I have succeeded installing gcc
3.2 in a Debian 4.0 chroot now.
> so we use stone age gcc but take latest binutils and kernel? What about
> lifting the limit of gcc 3.2?
Would probably make sense, since gcc 3.2 cannot compile kernel/bounds.c,
at least not on x86.
,----
| CC kernel/bounds.s
| In file included from /tmp/linux/arch/x86/include/asm/bitops.h:512,
| from include/linux/bitops.h:22,
| from include/linux/kernel.h:10,
| from include/asm-generic/bug.h:13,
| from /tmp/linux/arch/x86/include/asm/bug.h:38,
| from include/linux/bug.h:4,
| from include/linux/page-flags.h:9,
| from kernel/bounds.c:9:
| /tmp/linux/arch/x86/include/asm/arch_hweight.h: In function `__arch_hweight32':
| /tmp/linux/arch/x86/include/asm/arch_hweight.h:29: syntax error before string constant
| make[1]: *** [kernel/bounds.s] Error 1
`----
Building with gcc 3.3 is apparently still possible, although it produces
tons of warnings and a modpost section mismatch. Still, requiring gcc
4.1 or newer would not be unreasonable, I think (still released a few
months earlier than binutils 2.17).
Cheers,
Sven
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-10-24 12:00 +0200 |
| Message-ID | <svKd1-5NX-13@gated-at.bofh.it> |
| In reply to | #1506963 |
On Mon, 2016-10-24 at 09:38 +0200, Sven Joachim wrote: > On 2016-10-23 12:23 -0700, Joe Perches wrote: > > > On Sun, 2016-10-23 at 18:19 +0200, Sven Joachim wrote: > > > On 2016-10-21 23:21 +0200, Adam Borowski wrote: > > > > On Fri, Oct 21, 2016 at 01:16:00PM +0200, Sebastian Andrzej Siewior wrote: > > > > > Debian started to build the gcc with --enable-default-pie by default > > > > [] > > > > > diff --git a/Makefile b/Makefile > > > > [] > > > > > @@ -398,7 +398,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__ > > > > > KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ > > > > > -fno-strict-aliasing -fno-common \ > > > > > -Werror-implicit-function-declaration \ > > > > > - -Wno-format-security \ > > > > > + -Wno-format-security -fno-PIE \ > > > > > -std=gnu89 > > > > I've used this here instead: > > > > KBUILD_CFLAGS += $(call cc-option,-fno-pie) > > Where exactly do you set that? I tried this patch: > > --8<---------------cut here---------------start------------->8--- > diff --git a/Makefile b/Makefile > index 93beca4..fde1e21 100644 > --- a/Makefile > +++ b/Makefile > @@ -619,6 +619,7 @@ ARCH_AFLAGS := > ARCH_CFLAGS := > include arch/$(SRCARCH)/Makefile > > +KBUILD_CFLAGS += $(call cc-option,-fno-pie,) > KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) > KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) > KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) > --8<---------------cut here---------------end--------------->8--- > > But make still fails with it. :-( --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 512e47a53e9a..e2a0d46820e4 100644 --- a/Makefile +++ b/Makefile @@ -400,6 +400,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Werror-implicit-function-declaration \ -Wno-format-security \ -std=gnu89 +KBUILD_CFLAGS += $(call cc-option,-fno-pie) KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL :=
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web