Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 620092 - sys-apps/systemd-233-r1 fails to build with gcc 7.1
Summary: sys-apps/systemd-233-r1 fails to build with gcc 7.1
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL: https://github.com/systemd/systemd/is...
Whiteboard:
Keywords:
Depends on:
Blocks: gcc-7
  Show dependency tree
 
Reported: 2017-05-29 10:04 UTC by Mike Lothian
Modified: 2018-02-01 15:58 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
XZ Compressed Build Log (build.log.xz,19.86 KB, application/x-xz)
2017-05-29 10:05 UTC, Mike Lothian
Details
Ensure not-null path to basename function. (233-ensure-not-null-pall-to-basename.patch,774 bytes, patch)
2017-06-29 10:42 UTC, Luigi 'Comio' Mantellini
Details | Diff
emerge --info gcc:7.1.0 systemd (emerge--info.txt,7.54 KB, text/plain)
2017-06-29 19:10 UTC, josef.95
Details
emerge --info gcc:7.1.0 systemd output (emergeinfo,7.36 KB, text/plain)
2017-06-29 21:12 UTC, Luigi 'Comio' Mantellini
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Lothian 2017-05-29 10:04:44 UTC
I'm sure systemd used to build with gcc 7.1 when it was first released


/var/tmp/portage/sys-apps/systemd-233-r1/work/systemd-233/src/shared/install.c: In function ‘unit_file_disable’:
/var/tmp/portage/sys-apps/systemd-233-r1/work/systemd-233/src/shared/install.c:1007:22: error: argument 1 null where non-null expected [-Werror=nonnull]
                 name = basename(path);
                 ~~~~~^~~~~~~~~~~~~~~~
In file included from /var/tmp/portage/sys-apps/systemd-233-r1/work/systemd-233/src/shared/install.c:28:0:
/usr/include/string.h:599:14: note: in a call to function ‘basename’ declared here
 extern char *basename (const char *__filename) __THROW __nonnull ((1));
              ^~~~~~~~

I'm not sure if this warning can be ignored or not
Comment 1 Mike Lothian 2017-05-29 10:05:56 UTC
Created attachment 474620 [details]
XZ Compressed Build Log
Comment 2 Mike Gilbert gentoo-dev 2017-05-30 15:16:37 UTC
Could you please try to reproduce this with systemd-9999?
Comment 3 josef.95 2017-05-30 15:53:16 UTC
Hm, =systemd-233-r1 build and works here fine with gcc-7.1.0
(I have just a rebuild tested)
Comment 4 Mike Lothian 2017-06-14 01:32:43 UTC
Do you have anything in your flags that's downgrading the error?

It looks like the issue isn't happening with GCC 7.1.1 which is used by RedHat
Comment 5 Luigi 'Comio' Mantellini 2017-06-29 10:30:25 UTC
basename(path) function requires that path is ensured to be not null. I will prepare a patch.

*To be clear: gcc 7.1 is working fine.*
Comment 6 Mike Lothian 2017-06-29 10:34:27 UTC
The systemd maintainers are adamant that the issue lies in GCC 7.1.0, they're using a Redhat patched version (GCC 7.1.1) which compiles it fine.

Please see the systemd bug for more details https://github.com/systemd/systemd/issues/6119
Comment 7 Luigi 'Comio' Mantellini 2017-06-29 10:42:38 UTC
Created attachment 478330 [details, diff]
Ensure not-null path to basename function.
Comment 8 josef.95 2017-06-29 19:10:39 UTC
Created attachment 478354 [details]
emerge --info gcc:7.1.0 systemd

(In reply to Mike Lothian from comment #4)
> Do you have anything in your flags that's downgrading the error?
> 
> It looks like the issue isn't happening with GCC 7.1.1 which is used by
> RedHat

Hn no, I have nothing special, build here fine with standard sys-devel/gcc-7.1.0-r1::gentoo compiler.

Can you please add your "emerge --info gcc:7.1.0 systemd" to this Bug.
And please make a build test with -O2 instead of -O3 optimization.
Comment 9 Luigi 'Comio' Mantellini 2017-06-29 21:12:35 UTC
Created attachment 478424 [details]
emerge --info gcc:7.1.0 systemd output
Comment 10 Luigi 'Comio' Mantellini 2017-06-29 21:49:30 UTC
test:

-O2 -> success
-O3 -> fail
Comment 11 josef.95 2017-07-02 21:55:00 UTC
Hm, you using a 17.0 profile with gcc-7.1.0[pie,ssp]
I think it is not good idea building packages with ssp on, and -O3 optimization.
On gentoo hardened this combination is unsupported - see https://wiki.gentoo.org/wiki/Hardened/FAQ#Why_don.27t_my_programs_work_when_I_use_CFLAGS.3D.22-O3.22_and_hardened_gcc.3F

I think with stack-smashing protector (SSP) you should not using -O3 optimization.
Comment 12 Luigi 'Comio' Mantellini 2017-07-03 07:47:15 UTC
(In reply to josef.95 from comment #11)
> Hm, you using a 17.0 profile with gcc-7.1.0[pie,ssp]
> I think it is not good idea building packages with ssp on, and -O3
> optimization.
> On gentoo hardened this combination is unsupported - see
> https://wiki.gentoo.org/wiki/Hardened/FAQ#Why_don.
> 27t_my_programs_work_when_I_use_CFLAGS.3D.22-O3.22_and_hardened_gcc.3F
> 
> I think with stack-smashing protector (SSP) you should not using -O3
> optimization.

I moved from the previous profile without ssp. At this point I will follow your suggestion to keep away from -O3 flag.

Furthermore, the proposed patch should be safe because implement a trivial check on a null pointer, even if the same check has been performed by means of an "assert" macro.

thanks

luigi
Comment 13 Mike Lothian 2017-07-03 22:20:25 UTC
I think ssp is enabled by the eclass for all gcc's newer than 6, can you confirm I should be switching this off for O3, or are you recommending that O3 in general should be avoided? 

There are are few packages that use O3 by default
Comment 14 Konstantin (elxa) 2017-09-28 16:29:36 UTC
This was solved upstream via https://github.com/systemd/systemd/commit/fb1b58820fc4622a3b7f54b4096943e4768505cb.patch

Please add the patch to gentoo until > systemd-234 is out, thanks. Patched systemd-234 compiled with gcc-7.2.0 and both  "-O2" or "-O3" in C(XX)FLAGS.
Comment 15 Mike Gilbert gentoo-dev 2017-09-28 18:20:06 UTC
235 is due out soon, so I'm more inclined to just wait for it.
Comment 16 Pacho Ramos gentoo-dev 2018-02-01 15:58:54 UTC
this should be fixed now