Skip to content

Commit

Permalink
fix certain old AMD builds, fixes #55
Browse files Browse the repository at this point in the history
  • Loading branch information
graysky2 committed Jun 15, 2020
1 parent 57e183d commit a399f2c
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ It also offers to compile passing the 'native' option which, "selects the CPU
to generate code for at compilation time by determining the processor type of
the compiling machine. Using -march=native enables all instruction subsets
supported by the local machine and will produce code optimized for the local
machine under the constraints of the selected instruction set."[3]
machine under the constraints of the selected instruction set."[2]

Do NOT try using the 'native' option on AMD Piledriver, Steamroller, or
Excavator CPUs (-march=bdver{2,3,4} flag). The build will error out due the
kernel's objtool issue with these.[3a,b]

MINOR NOTES
This patch also changes 'atom' to 'bonnell' in accordance with the gcc v4.9
changes. Note that upstream is using the deprecated 'match=atom' flags when I
believe it should use the newer 'march=bonnell' flag for atom processors.[2]
believe it should use the newer 'march=bonnell' flag for atom processors.[4]

It is not recommended to compile on Atom-CPUs with the 'native' option.[4] The
It is not recommended to compile on Atom-CPUs with the 'native' option.[5] The
recommendation is to use the 'atom' option instead.

BENEFITS
Expand All @@ -66,17 +70,19 @@ linux version 4.19-lts and 5.4-lts
gcc version >=10.1

ACKNOWLEDGMENTS
This patch builds on the seminal work by Jeroen.[5]
This patch builds on the seminal work by Jeroen.[6]

REFERENCES
1. https://gcc.gnu.org/gcc-4.9/changes.html
2. https://bugzilla.kernel.org/show_bug.cgi?id=77461
3. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
4. https://github.com/graysky2/kernel_gcc_patch/issues/15
5. http://www.linuxforge.net/docs/linux/linux-gcc.php
1. https://gcc.gnu.org/gcc-4.9/changes.html
2. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
3a. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95671#c11
3b. https://github.com/graysky2/kernel_gcc_patch/issues/55
4. https://bugzilla.kernel.org/show_bug.cgi?id=77461
5. https://github.com/graysky2/kernel_gcc_patch/issues/15
6. http://www.linuxforge.net/docs/linux/linux-gcc.php

--- a/arch/x86/include/asm/module.h 2020-05-14 01:58:30.000000000 -0400
+++ b/arch/x86/include/asm/module.h 2020-05-16 10:10:41.903122145 -0400
--- a/arch/x86/include/asm/module.h 2020-06-10 15:35:02.000000000 -0400
+++ b/arch/x86/include/asm/module.h 2020-06-15 10:31:48.627486708 -0400
@@ -25,6 +25,40 @@ struct mod_arch_specific {
#define MODULE_PROC_FAMILY "586MMX "
#elif defined CONFIG_MCORE2
Expand Down Expand Up @@ -147,8 +153,8 @@ REFERENCES
#elif defined CONFIG_MELAN
#define MODULE_PROC_FAMILY "ELAN "
#elif defined CONFIG_MCRUSOE
--- a/arch/x86/Kconfig.cpu 2020-05-14 01:58:30.000000000 -0400
+++ b/arch/x86/Kconfig.cpu 2020-05-16 10:12:29.508752718 -0400
--- a/arch/x86/Kconfig.cpu 2020-06-10 15:35:02.000000000 -0400
+++ b/arch/x86/Kconfig.cpu 2020-06-15 10:31:48.627486708 -0400
@@ -116,6 +116,7 @@ config MPENTIUMM
config MPENTIUM4
bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
Expand Down Expand Up @@ -548,9 +554,9 @@ REFERENCES

config X86_MINIMUM_CPU_FAMILY
int
--- a/arch/x86/Makefile 2020-05-14 01:58:30.000000000 -0400
+++ b/arch/x86/Makefile 2020-05-16 10:10:41.903122145 -0400
@@ -119,13 +119,57 @@ else
--- a/arch/x86/Makefile 2020-06-10 15:35:02.000000000 -0400
+++ b/arch/x86/Makefile 2020-06-15 10:32:39.508648036 -0400
@@ -119,13 +119,60 @@ else
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)

# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
Expand All @@ -563,8 +569,11 @@ REFERENCES
+ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
+ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
+ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
+ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-march=bdver3)
+ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-march=bdver4)
+ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MZEN) += $(call cc-option,-march=znver1)
+ cflags-$(CONFIG_MZEN2) += $(call cc-option,-march=znver2)
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
Expand Down Expand Up @@ -611,8 +620,8 @@ REFERENCES
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
KBUILD_CFLAGS += $(cflags-y)

--- a/arch/x86/Makefile_32.cpu 2020-05-14 01:58:30.000000000 -0400
+++ b/arch/x86/Makefile_32.cpu 2020-05-16 10:10:41.903122145 -0400
--- a/arch/x86/Makefile_32.cpu 2020-06-10 15:35:02.000000000 -0400
+++ b/arch/x86/Makefile_32.cpu 2020-06-15 10:31:48.627486708 -0400
@@ -23,7 +23,19 @@ cflags-$(CONFIG_MK6) += -march=k6
# Please note, that patches that add -march=athlon-xp and friends are pointless.
# They make zero difference whatsosever to performance at this time.
Expand Down Expand Up @@ -660,4 +669,3 @@ REFERENCES

# AMD Elan support
cflags-$(CONFIG_MELAN) += -march=i486

Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ It also offers to compile passing the 'native' option which, "selects the CPU
to generate code for at compilation time by determining the processor type of
the compiling machine. Using -march=native enables all instruction subsets
supported by the local machine and will produce code optimized for the local
machine under the constraints of the selected instruction set."[3]
machine under the constraints of the selected instruction set."[2]

Do NOT try using the 'native' option on AMD Piledriver, Steamroller, or
Excavator CPUs (-march=bdver{2,3,4} flag). The build will error out due the
kernel's objtool issue with these.[3a,b]

MINOR NOTES
This patch also changes 'atom' to 'bonnell' in accordance with the gcc v4.9
changes. Note that upstream is using the deprecated 'match=atom' flags when I
believe it should use the newer 'march=bonnell' flag for atom processors.[2]
believe it should use the newer 'march=bonnell' flag for atom processors.[4]

It is not recommended to compile on Atom-CPUs with the 'native' option.[4] The
It is not recommended to compile on Atom-CPUs with the 'native' option.[5] The
recommendation is to use the 'atom' option instead.

BENEFITS
Expand All @@ -66,18 +70,20 @@ linux version 5.5 and 5.6
gcc version >=10.1

ACKNOWLEDGMENTS
This patch builds on the seminal work by Jeroen.[5]
This patch builds on the seminal work by Jeroen.[6]

REFERENCES
1. https://gcc.gnu.org/gcc-4.9/changes.html
2. https://bugzilla.kernel.org/show_bug.cgi?id=77461
3. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
4. https://github.com/graysky2/kernel_gcc_patch/issues/15
5. http://www.linuxforge.net/docs/linux/linux-gcc.php
1. https://gcc.gnu.org/gcc-4.9/changes.html
2. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
3a. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95671#c11
3b. https://github.com/graysky2/kernel_gcc_patch/issues/55
4. https://bugzilla.kernel.org/show_bug.cgi?id=77461
5. https://github.com/graysky2/kernel_gcc_patch/issues/15
6. http://www.linuxforge.net/docs/linux/linux-gcc.php

--- a/arch/x86/include/asm/module.h 2020-05-14 01:58:30.000000000 -0400
+++ b/arch/x86/include/asm/module.h 2020-05-16 10:10:41.903122145 -0400
@@ -17,6 +17,40 @@
--- a/arch/x86/include/asm/module.h 2020-06-10 14:22:53.000000000 -0400
+++ b/arch/x86/include/asm/module.h 2020-06-15 10:35:59.206503896 -0400
@@ -27,6 +27,40 @@ struct mod_arch_specific {
#define MODULE_PROC_FAMILY "586MMX "
#elif defined CONFIG_MCORE2
#define MODULE_PROC_FAMILY "CORE2 "
Expand Down Expand Up @@ -118,7 +124,7 @@ REFERENCES
#elif defined CONFIG_MATOM
#define MODULE_PROC_FAMILY "ATOM "
#elif defined CONFIG_M686
@@ -35,6 +69,28 @@
@@ -45,6 +79,28 @@ struct mod_arch_specific {
#define MODULE_PROC_FAMILY "K7 "
#elif defined CONFIG_MK8
#define MODULE_PROC_FAMILY "K8 "
Expand Down Expand Up @@ -147,8 +153,8 @@ REFERENCES
#elif defined CONFIG_MELAN
#define MODULE_PROC_FAMILY "ELAN "
#elif defined CONFIG_MCRUSOE
--- a/arch/x86/Kconfig.cpu 2020-05-03 17:56:04.000000000 -0400
+++ b/arch/x86/Kconfig.cpu 2020-05-09 16:52:31.735387041 -0400
--- a/arch/x86/Kconfig.cpu 2020-06-10 14:22:53.000000000 -0400
+++ b/arch/x86/Kconfig.cpu 2020-06-15 10:35:59.206503896 -0400
@@ -123,6 +123,7 @@ config MPENTIUMM
config MPENTIUM4
bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
Expand Down Expand Up @@ -548,9 +554,9 @@ REFERENCES

config X86_MINIMUM_CPU_FAMILY
int
--- a/arch/x86/Makefile 2020-05-03 17:56:04.000000000 -0400
+++ b/arch/x86/Makefile 2020-05-09 16:55:30.162511254 -0400
@@ -119,13 +119,57 @@ else
--- a/arch/x86/Makefile 2020-06-10 14:22:53.000000000 -0400
+++ b/arch/x86/Makefile 2020-06-15 10:36:31.263892298 -0400
@@ -119,13 +119,60 @@ else
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)

# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
Expand All @@ -563,8 +569,11 @@ REFERENCES
+ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
+ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
+ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
+ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-march=bdver3)
+ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-march=bdver4)
+ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MZEN) += $(call cc-option,-march=znver1)
+ cflags-$(CONFIG_MZEN2) += $(call cc-option,-march=znver2)
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
Expand Down Expand Up @@ -611,8 +620,8 @@ REFERENCES
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
KBUILD_CFLAGS += $(cflags-y)

--- a/arch/x86/Makefile_32.cpu 2020-05-03 17:56:04.000000000 -0400
+++ b/arch/x86/Makefile_32.cpu 2020-05-09 16:56:02.613201096 -0400
--- a/arch/x86/Makefile_32.cpu 2020-06-10 14:22:53.000000000 -0400
+++ b/arch/x86/Makefile_32.cpu 2020-06-15 10:35:59.206503896 -0400
@@ -24,7 +24,19 @@ cflags-$(CONFIG_MK6) += -march=k6
# Please note, that patches that add -march=athlon-xp and friends are pointless.
# They make zero difference whatsosever to performance at this time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ It also offers to compile passing the 'native' option which, "selects the CPU
to generate code for at compilation time by determining the processor type of
the compiling machine. Using -march=native enables all instruction subsets
supported by the local machine and will produce code optimized for the local
machine under the constraints of the selected instruction set."[3]
machine under the constraints of the selected instruction set."[2]

Do NOT try using the 'native' option on AMD Piledriver, Steamroller, or
Excavator CPUs (-march=bdver{2,3,4} flag). The build will error out due the
kernel's objtool issue with these.[3a,b]

MINOR NOTES
This patch also changes 'atom' to 'bonnell' in accordance with the gcc v4.9
changes. Note that upstream is using the deprecated 'match=atom' flags when I
believe it should use the newer 'march=bonnell' flag for atom processors.[2]
believe it should use the newer 'march=bonnell' flag for atom processors.[4]

It is not recommended to compile on Atom-CPUs with the 'native' option.[4] The
It is not recommended to compile on Atom-CPUs with the 'native' option.[5] The
recommendation is to use the 'atom' option instead.

BENEFITS
Expand All @@ -66,17 +70,19 @@ linux version >=5.7
gcc version >=10.1

ACKNOWLEDGMENTS
This patch builds on the seminal work by Jeroen.[5]
This patch builds on the seminal work by Jeroen.[6]

REFERENCES
1. https://gcc.gnu.org/gcc-4.9/changes.html
2. https://bugzilla.kernel.org/show_bug.cgi?id=77461
3. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
4. https://github.com/graysky2/kernel_gcc_patch/issues/15
5. http://www.linuxforge.net/docs/linux/linux-gcc.php
1. https://gcc.gnu.org/gcc-4.9/changes.html
2. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
3a. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95671#c11
3b. https://github.com/graysky2/kernel_gcc_patch/issues/55
4. https://bugzilla.kernel.org/show_bug.cgi?id=77461
5. https://github.com/graysky2/kernel_gcc_patch/issues/15
6. http://www.linuxforge.net/docs/linux/linux-gcc.php

--- a/arch/x86/include/asm/vermagic.h 2020-05-03 17:56:04.000000000 -0400
+++ b/arch/x86/include/asm/vermagic.h 2020-05-09 16:47:06.358486082 -0400
--- a/arch/x86/include/asm/vermagic.h 2020-06-10 14:21:45.000000000 -0400
+++ b/arch/x86/include/asm/vermagic.h 2020-06-15 10:12:15.577746073 -0400
@@ -17,6 +17,40 @@
#define MODULE_PROC_FAMILY "586MMX "
#elif defined CONFIG_MCORE2
Expand Down Expand Up @@ -147,8 +153,8 @@ REFERENCES
#elif defined CONFIG_MELAN
#define MODULE_PROC_FAMILY "ELAN "
#elif defined CONFIG_MCRUSOE
--- a/arch/x86/Kconfig.cpu 2020-05-03 17:56:04.000000000 -0400
+++ b/arch/x86/Kconfig.cpu 2020-05-09 16:52:31.735387041 -0400
--- a/arch/x86/Kconfig.cpu 2020-06-10 14:21:45.000000000 -0400
+++ b/arch/x86/Kconfig.cpu 2020-06-15 10:12:15.577746073 -0400
@@ -123,6 +123,7 @@ config MPENTIUMM
config MPENTIUM4
bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
Expand Down Expand Up @@ -548,9 +554,9 @@ REFERENCES

config X86_MINIMUM_CPU_FAMILY
int
--- a/arch/x86/Makefile 2020-05-03 17:56:04.000000000 -0400
+++ b/arch/x86/Makefile 2020-05-09 16:55:30.162511254 -0400
@@ -119,13 +119,57 @@ else
--- a/arch/x86/Makefile 2020-06-10 14:21:45.000000000 -0400
+++ b/arch/x86/Makefile 2020-06-15 10:16:01.605959969 -0400
@@ -119,13 +119,60 @@ else
KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)

# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
Expand All @@ -563,8 +569,11 @@ REFERENCES
+ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
+ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
+ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
+ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-march=bdver3)
+ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-march=bdver4)
+ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-mno-tbm)
+ cflags-$(CONFIG_MZEN) += $(call cc-option,-march=znver1)
+ cflags-$(CONFIG_MZEN2) += $(call cc-option,-march=znver2)
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
Expand Down Expand Up @@ -611,8 +620,8 @@ REFERENCES
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
KBUILD_CFLAGS += $(cflags-y)

--- a/arch/x86/Makefile_32.cpu 2020-05-03 17:56:04.000000000 -0400
+++ b/arch/x86/Makefile_32.cpu 2020-05-09 16:56:02.613201096 -0400
--- a/arch/x86/Makefile_32.cpu 2020-06-10 14:21:45.000000000 -0400
+++ b/arch/x86/Makefile_32.cpu 2020-06-15 10:12:15.577746073 -0400
@@ -24,7 +24,19 @@ cflags-$(CONFIG_MK6) += -march=k6
# Please note, that patches that add -march=athlon-xp and friends are pointless.
# They make zero difference whatsosever to performance at this time.
Expand Down
Loading

0 comments on commit a399f2c

Please sign in to comment.