Bug 8291

Summary: systemd fails to start when compiled with GCC 5.2
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Jonathan Liu <net147>
Component: coreAssignee: Jonathan Liu <net147>
Status: VERIFIED FIXED QA Contact: Bogdan Alexandru Voiculescu <bogdanx.a.voiculescu>
Severity: critical    
Priority: Medium+ CC: andrei, bogdanx.a.voiculescu, kergoth, meta.mr.watcher, meta.watcher, ntl, raj.khem, richard.purdie, ross.burton
Version: 1.9   
Target Milestone: 1.9   
Hardware: All   
OS: arm   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Jonathan Liu 2015-09-12 09:42:18 UTC
systemd image fails to start on Raspberry Pi 2 if using GCC 5.2.

Repository revisions
bitbake: 135dff67216759286f584e501583584a9cb09f27
openembedded-core: 56c5fa106eeccda2ca92dbeb73ff01ba40992e7d

It will try to start the following services, timeout after 90 seconds and keep trying to again to start the services:
* Journal Service
* udev Kernel Device Manager

Workarounds:
 * Change -O2 to -O1 in optimization flags for systemd recipe:
FULL_OPTIMIZATION_remove = "-O2"
FULL_OPTIMIZATION =+ "-O1"
 * Set GCCVERSION = "4.9%" to use GCC 4.9 in local.conf or distro conf
Comment 1 Jonathan Liu 2015-09-12 09:45:03 UTC
Same issue with both systemd 219 in master and systemd 225 from master-next.
Comment 2 Khem Raj 2015-09-12 15:40:40 UTC
Can you try disabling lto with -fno-lto
Comment 3 Jonathan Liu 2015-09-12 21:54:40 UTC
The issue still persists with the following added to the recipe:
FULL_OPTIMIZATION += "-fno-lto"
Comment 4 Ross Burton 2015-09-14 11:09:17 UTC
Reassigning to Khem.
Comment 5 Nathan Lynch 2015-09-16 15:55:48 UTC
Check whether adding -fno-ipa-sra to the compiler flags works around it?

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932
Comment 6 Jonathan Liu 2015-09-16 22:46:55 UTC
The issue still persists with the following added to the recipe:
FULL_OPTIMIZATION += "-fno-ipa-sra"(In reply to comment #5)
> Check whether adding -fno-ipa-sra to the compiler flags works around it?
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932

The issue still persists with the following added to the recipe:
FULL_OPTIMIZATION += "-fno-ipa-sra"
Comment 7 Jonathan Liu 2015-09-16 22:52:19 UTC
Adding both -fno-lto and -fno-ipa-sra doesn't work either:
FULL_OPTIMIZATION += "-fno-lto -fno-ipa-sra"
Comment 8 Jonathan Liu 2015-09-21 08:51:32 UTC
I have narrowed down the compiler optimizations.

Disabling 2 compiler optimizations as follows resolves the issues when compiling systemd with GCC 5.2:
FULL_OPTIMIZATION += "-fno-schedule-insns -fno-schedule-insns2"

Both optimizations need to be disabled. Disabling only one of them does not resolve the issue.
Comment 9 Ross Burton 2015-09-23 11:01:58 UTC
Merged in 338f18e5808ea0472350d0c26edd0938ffbdcd23.
Comment 10 Jonathan Liu 2015-09-23 23:55:53 UTC
Looks like V1 of the patch was merged instead of V2 which makes it ARM-specific. Any reason in particular?
Comment 11 Ross Burton 2015-09-24 08:02:41 UTC
Human error - master-next has a revert and V2.
Comment 12 Bogdan Alexandru Voiculescu 2015-10-13 11:07:35 UTC
Verified with master e35c404537db0b46047fcb2ee7d3645e3e0935c5 
on BeagleBoneBlack board - ARMv7.

......
systemd[1]: systemd 225 running in system mode. (-PAM -AUDIT -SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP -LIBCRYPTSETUP -GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD -IDN)
systemd[1]: Detected architecture arm.

Welcome to Poky (Yocto Project Reference Distro) 2.0 (jethro)!

systemd[1]: Set hostname to <beaglebone>.
.....