Skip to contentSkip to conversation

poky-tiny: enable section removal

PATCH Superseded Sinan Kaya 3 participants 6 messages Nov 13, 2020 – Nov 14, 2020

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

PATCH v6 1/1 poky-tiny: enable section removal

Use GCC sections flags so that unused sections can be garbage collected at link time.

---
 meta-poky/conf/distro/include/gcsections.inc | 19 +++++++++++++++++++
 meta-poky/conf/distro/poky-tiny.conf         |  3 +++
 2 files changed, 22 insertions(+)
 create mode 100644 meta-poky/conf/distro/include/gcsections.inc
meta-poky/conf/distro/include/gcsections.inc new file +19 -0
new file mode 100644
index 00000000000..d94f25913bb
@@ -0,0 +1,19 @@
+CFLAGS_SECTION_REMOVAL = "-ffunction-sections -fdata-sections"
+LDFLAGS_SECTION_REMOVAL = "-Wl,--gc-sections"
+
+# packages with build problems using sections
+CFLAGS_SECTION_REMOVAL_pn-glibc = ""
+LDFLAGS_SECTION_REMOVAL_pn-glibc = ""
+CFLAGS_section_removal_pn-cairo = ""
+LDFLAGS_section_removal_pn-cairo = ""
+CFLAGS_section_removal_pn-perl = ""
+LDFLAGS_section_removal_pn-perl = ""
+
+# omit section removal on native builds
+CFLAGS_SECTION_REMOVAL_class-native = ""
+LDFLAGS_SECTION_REMOVAL_class-native = ""
+
+# set default for all targets
+CFLAGS_append = " ${CFLAGS_SECTION_REMOVAL}"
+LDFLAGS_append = " ${LDFLAGS_SECTION_REMOVAL}"
+
meta-poky/conf/distro/poky-tiny.conf +3 -0
index c6d4b88f83d..9507a68a11e 100644
@@ -29,6 +29,8 @@
 # [ ] Modify busybox to allow for DISTRO_FEATURES-like confiruration
 
 require conf/distro/poky.conf
+require conf/distro/include/gcsections.inc
+
 DISTRO = "poky-tiny"
 DISTROOVERRIDES = "poky:poky-tiny"
 TCLIBC = "musl"
@@ -122,3 +124,4 @@ PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny"
 
 # Disable python usage in opkg-utils since it won't build with tiny config
 PACKAGECONFIG_remove_pn-opkg-utils = "python"
+
Signature · 1 line
2.17.1
#1 lore raw
Quoted 10 lines · Sinan Kaya

Use GCC sections flags so that unused sections can be garbage collected at link time.

---
 meta-poky/conf/distro/include/gcsections.inc | 19
+++++++++++++++++++
 meta-poky/conf/distro/poky-tiny.conf         |  3 +++
 2 files changed, 22 insertions(+)
 create mode 100644 meta-poky/conf/distro/include/gcsections.inc

Still seems to be the same?

https://autobuilder.yoctoproject.org/typhoon/#/builders/15/builds/2984

How are you testing this? I know people can have problems with patches but this is getting a little silly :(.

Cheers,

Richard

#3 lore raw
In reply to Sinan Kaya
Quoted 17 lines · Sinan Kaya

Use GCC sections flags so that unused sections can be garbage collected at link time.

---
 meta-poky/conf/distro/include/gcsections.inc | 19 +++++++++++++++++++
 meta-poky/conf/distro/poky-tiny.conf         |  3 +++
 2 files changed, 22 insertions(+)
 create mode 100644 meta-poky/conf/distro/include/gcsections.inc
meta-poky/conf/distro/include/gcsections.inc new file +0 -0
new file mode 100644
index 00000000000..d94f25913bb

meta-poky/conf/distro/include/gcsections.inc line 10

Quoted 10 lines
meta-poky/conf/distro/include/gcsections.inc new file +10 -0
@@ -0,0 +1,19 @@
+CFLAGS_SECTION_REMOVAL = "-ffunction-sections -fdata-sections"
+LDFLAGS_SECTION_REMOVAL = "-Wl,--gc-sections"
+
+# packages with build problems using sections
+CFLAGS_SECTION_REMOVAL_pn-glibc = ""
+LDFLAGS_SECTION_REMOVAL_pn-glibc = ""
+CFLAGS_section_removal_pn-cairo = ""
+LDFLAGS_section_removal_pn-cairo = ""
+CFLAGS_section_removal_pn-perl = ""
+LDFLAGS_section_removal_pn-perl = ""

Are you sure "section_removal" should be lower case here?

meta-poky/conf/distro/include/gcsections.inc line 14

Quoted 4 lines
meta-poky/conf/distro/include/gcsections.inc new file +4 -0
+
+# omit section removal on native builds
+CFLAGS_SECTION_REMOVAL_class-native = ""
+LDFLAGS_SECTION_REMOVAL_class-native = ""

This still applies the flags to -nativesdk builds, possibly to other builds as well. Instead you should only append the flags for class-target.

meta-poky/conf/distro/include/gcsections.inc line 18

Quoted 4 lines
meta-poky/conf/distro/include/gcsections.inc new file +4 -0
+
+# set default for all targets
+CFLAGS_append = " ${CFLAGS_SECTION_REMOVAL}"
+LDFLAGS_append = " ${LDFLAGS_SECTION_REMOVAL}"

This isn't ideal. You should use CFLAGS_append_class-target and similar for LDFLAGS here.

meta-poky/conf/distro/include/gcsections.inc line 19

Quoted 1 line
meta-poky/conf/distro/include/gcsections.inc new file +1 -0
+

This looks like stray whitespace.

Quoted 14 lines
meta-poky/conf/distro/poky-tiny.conf +2 -0
index c6d4b88f83d..9507a68a11e 100644
@@ -29,6 +29,8 @@
 # [ ] Modify busybox to allow for DISTRO_FEATURES-like confiruration
 
 require conf/distro/poky.conf
+require conf/distro/include/gcsections.inc
+
 DISTRO = "poky-tiny"
 DISTROOVERRIDES = "poky:poky-tiny"
 TCLIBC = "musl"

meta-poky/conf/distro/poky-tiny.conf PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" · line 127

Quoted 4 lines
meta-poky/conf/distro/poky-tiny.conf +1 -0
@@ -122,3 +124,4 @@ PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny"
 
 # Disable python usage in opkg-utils since it won't build with tiny config
 PACKAGECONFIG_remove_pn-opkg-utils = "python"
+

This also looks like stray whitespace.

Signature · 2 lines
Paul Barker
Konsulko Group
author
#4 lore raw
Quoted 22 lines · Paul Barker
Quoted 21 lines · Sinan Kaya

Use GCC sections flags so that unused sections can be garbage collected at link time.

---
 meta-poky/conf/distro/include/gcsections.inc | 19 +++++++++++++++++++
 meta-poky/conf/distro/poky-tiny.conf         |  3 +++
 2 files changed, 22 insertions(+)
 create mode 100644 meta-poky/conf/distro/include/gcsections.inc
meta-poky/conf/distro/include/gcsections.inc new file +4 -0
new file mode 100644
index 00000000000..d94f25913bb
@@ -0,0 +1,19 @@
+CFLAGS_SECTION_REMOVAL = "-ffunction-sections -fdata-sections"
+LDFLAGS_SECTION_REMOVAL = "-Wl,--gc-sections"
+
+# packages with build problems using sections
Quoted 9 lines

meta-poky/conf/distro/include/gcsections.inc line 10

Quoted 6 lines
meta-poky/conf/distro/include/gcsections.inc new file +6 -0
+CFLAGS_SECTION_REMOVAL_pn-glibc = ""
+LDFLAGS_SECTION_REMOVAL_pn-glibc = ""
+CFLAGS_section_removal_pn-cairo = ""
+LDFLAGS_section_removal_pn-cairo = ""
+CFLAGS_section_removal_pn-perl = ""
+LDFLAGS_section_removal_pn-perl = ""

Are you sure "section_removal" should be lower case here?

Copy/paste screw up.

Quoted 9 lines

meta-poky/conf/distro/include/gcsections.inc line 14

Quoted 4 lines
meta-poky/conf/distro/include/gcsections.inc new file +4 -0
+
+# omit section removal on native builds
+CFLAGS_SECTION_REMOVAL_class-native = ""
+LDFLAGS_SECTION_REMOVAL_class-native = ""

This still applies the flags to -nativesdk builds, possibly to other builds as well. Instead you should only append the flags for class-target.

This was my original version. Khem wanted to increase the scope to nativesdk too. I'll go back to class-target.

Quoted 8 lines

meta-poky/conf/distro/include/gcsections.inc line 18

Quoted 4 lines
meta-poky/conf/distro/include/gcsections.inc new file +4 -0
+
+# set default for all targets
+CFLAGS_append = " ${CFLAGS_SECTION_REMOVAL}"
+LDFLAGS_append = " ${LDFLAGS_SECTION_REMOVAL}"

This isn't ideal. You should use CFLAGS_append_class-target and similar for LDFLAGS here.

sounds good.

Quoted 4 lines

meta-poky/conf/distro/include/gcsections.inc line 19

Quoted 1 line
meta-poky/conf/distro/include/gcsections.inc new file +1 -0
+

This looks like stray whitespace.

ok

Quoted 15 lines
Quoted 15 lines
meta-poky/conf/distro/poky-tiny.conf +2 -0
index c6d4b88f83d..9507a68a11e 100644
@@ -29,6 +29,8 @@
 # [ ] Modify busybox to allow for DISTRO_FEATURES-like confiruration
 
 require conf/distro/poky.conf
+require conf/distro/include/gcsections.inc
+
 DISTRO = "poky-tiny"
 DISTROOVERRIDES = "poky:poky-tiny"
 TCLIBC = "musl"
@@ -122,3 +124,4 @@ PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny"
 
Quoted 6 lines

meta-poky/conf/distro/poky-tiny.conf PNBLACKLIST[core-image-weston] = "not buildable with poky-tiny" · line 127

Quoted 3 lines
meta-poky/conf/distro/poky-tiny.conf +1 -0
 # Disable python usage in opkg-utils since it won't build with tiny config
 PACKAGECONFIG_remove_pn-opkg-utils = "python"
+

This also looks like stray whitespace.

ok

#5 lore raw
Quoted 46 lines · Sinan Kaya
Quoted 22 lines · Paul Barker
Quoted 21 lines · Sinan Kaya

Use GCC sections flags so that unused sections can be garbage collected at link time.

---
 meta-poky/conf/distro/include/gcsections.inc | 19 +++++++++++++++++++
 meta-poky/conf/distro/poky-tiny.conf         |  3 +++
 2 files changed, 22 insertions(+)
 create mode 100644 meta-poky/conf/distro/include/gcsections.inc
meta-poky/conf/distro/include/gcsections.inc new file +4 -0
new file mode 100644
index 00000000000..d94f25913bb
@@ -0,0 +1,19 @@
+CFLAGS_SECTION_REMOVAL = "-ffunction-sections -fdata-sections"
+LDFLAGS_SECTION_REMOVAL = "-Wl,--gc-sections"
+
+# packages with build problems using sections
Quoted 9 lines

meta-poky/conf/distro/include/gcsections.inc line 10

Quoted 6 lines
meta-poky/conf/distro/include/gcsections.inc new file +6 -0
+CFLAGS_SECTION_REMOVAL_pn-glibc = ""
+LDFLAGS_SECTION_REMOVAL_pn-glibc = ""
+CFLAGS_section_removal_pn-cairo = ""
+LDFLAGS_section_removal_pn-cairo = ""
+CFLAGS_section_removal_pn-perl = ""
+LDFLAGS_section_removal_pn-perl = ""

Are you sure "section_removal" should be lower case here?

Copy/paste screw up.

Quoted 9 lines

meta-poky/conf/distro/include/gcsections.inc line 14

Quoted 4 lines
meta-poky/conf/distro/include/gcsections.inc new file +4 -0
+
+# omit section removal on native builds
+CFLAGS_SECTION_REMOVAL_class-native = ""
+LDFLAGS_SECTION_REMOVAL_class-native = ""

This still applies the flags to -nativesdk builds, possibly to other builds as well. Instead you should only append the flags for class-target.

Quoted 2 lines

This was my original version. Khem wanted to increase the scope to nativesdk too. I'll go back to class-target.

If that's the case I advise explicitly listing the classes you do want the flags to apply to (_class-target & _class-nativesdk) instead of listing the classes to exclude. That would avoid the risk of applying flags to other classes which haven't been considered.

Khem: Any thoughts here?

Signature · 2 lines
Paul Barker
Konsulko Group