Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 834445 - sys-devel/gcc: fails to compile sys-apps/fakeroot with CFLAGS="-fno-semantic-interposition" (/usr/include/bits/fcntl2.h:117:1: error: inlining failed in call to 'always_inline' 'openat.localalias': function not inlinable)
Summary: sys-devel/gcc: fails to compile sys-apps/fakeroot with CFLAGS="-fno-semantic-...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2022-03-01 14:47 UTC by Matteo Salonia
Modified: 2024-03-01 23:18 UTC (History)
5 users (show)

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


Attachments
Patch used to fix fakeroot (fakeroot-revert-patch-changes.patch,1.26 KB, patch)
2022-03-01 14:47 UTC, Matteo Salonia
Details | Diff
emerge --info (some packages removed because not related to bug) (emerge-info.log,7.26 KB, text/plain)
2022-03-01 14:51 UTC, Matteo Salonia
Details
Fakeroot 1.25 build.log (failed build) (fakeroot-1.25.log,47.04 KB, text/plain)
2022-03-01 15:22 UTC, Matteo Salonia
Details
Archive containing photo proof (emerge -p fakeroot, portage applying custom patch, successful emerge) (fakeroot.tar.xz,837.82 KB, application/x-xz-compressed-tar)
2022-03-01 16:09 UTC, Matteo Salonia
Details
Successful fakeroot-1.27 build.log (fakeroot-1.27.log,54.63 KB, text/plain)
2022-03-01 16:28 UTC, Matteo Salonia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matteo Salonia 2022-03-01 14:47:15 UTC
Created attachment 766121 [details, diff]
Patch used to fix fakeroot

Hello everyone,
today I tried to emerge "fakeroot".

When trying to emerge it, however, portage errored out with a GCC error, with the following error:

```
In file included from usr/include/fcntl.h:342,
                 from libfakeroot.c:138:
libfakeroot.c: In function 'mknodat':
/usr/include/bits/fcntl2.h:117:1: error: inlining failed in call to 'always_inline' 'openat.localalias': function not inlinable
  117 | openat (int __fd, const char *__path, int __oflag, ...)
      | ~~~~~
libfakeroot.c:1130:6: note: called from here
 1130 |   fd=openat(dir_fd, pathname, O_WRONLY|O_CREAT|O_TRUNC, 00644);
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

and so on.

To fix this, I created a user patch in "/etc/portage/patches/sys-apps/fakeroot" with the following content:

```
diff --git a/libfakeroot.c b/libfakeroot.c
index 169f4da..7593dd6 100644
--- a/libfakeroot.c
+++ b/libfakeroot.c
@@ -2586,19 +2570,3 @@ int sysinfo(int command, char *buf, long count)
     }
 }
 #endif
-
-#ifdef HAVE_OPENAT
-int openat(int dir_fd, const char *pathname, int flags, ...)
-{
-	mode_t mode;
-
-    if (flags & O_CREAT) {
-        va_list args;
-        va_start(args, flags);
-        mode = va_arg(args, int);
-        va_end(args);
-    }
-
-    return next_openat(dir_fd, pathname, flags, mode);
-}
-#endif
diff --git a/wrapfunc.inp b/wrapfunc.inp
index f7ad186..556af34 100644
--- a/wrapfunc.inp
+++ b/wrapfunc.inp
@@ -198,7 +198,7 @@ fchownat;int;(int dir_fd, const char *path, uid_t owner, gid_t group, int flags)
 mkdirat;int;(int dir_fd, const char *pathname, mode_t mode);(dir_fd, pathname, mode)
 #endif /* HAVE_MKDIRAT */
 #ifdef HAVE_OPENAT
-openat;int;(int dir_fd, const char *pathname, int flags, mode_t mode);(dir_fd, pathname, flags, mode);;(int dir_fd, const char *pathname, int flags, ...)
+openat;int;(int dir_fd, const char *pathname, int flags);(dir_fd, pathname, flags)
 #endif /* HAVE_OPENAT */
 #ifdef HAVE_RENAMEAT
 renameat;int;(int olddir_fd, const char *oldpath, int newdir_fd, const char *newpath);(olddir_fd, oldpath, newdir_fd, newpath)
-- 
GitLab
```

With these changes, I reverted "fakeroot-1.25.3-glibc-2.33.patch" 's changes, patch provided by the package mantainer of fakeroot.

Changing these lines lets me successfully compile fakeroot.
Comment 1 Matteo Salonia 2022-03-01 14:51:34 UTC
Created attachment 766122 [details]
emerge --info (some packages removed because not related to bug)

Added output of `emerge --info`
Comment 2 Matteo Salonia 2022-03-01 14:54:11 UTC
Bug is present even without LTO and CCache:

"/etc/portage/package.env/sys-apps":                                                                                sys-apps/fakeroot no-ccache.conf perf-no-lto.conf

"/etc/portage/env/no-ccache.conf": 
CC="gcc"
CXX="g++"
COMPILER="gcc"
HOSTCC="gcc"
FEATURES="-ccache"

"/etc/portage/env/perf-no-lto.conf":
COMMON_FLAGS="-Ofast -pipe -march=haswell -mtune=haswell -fno-plt -falign-functions=32 -floop-nest-optimize -fipa-pta -fno-semantic-interposition -fno-common -fno-signed-zeros -fno-trapping-math -fassociative-math -freciprocal-math -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fcx-limited-range -fexcess-precision=fast -fdevirtualize-at-ltrans"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
Comment 3 Mike Gilbert gentoo-dev 2022-03-01 15:10:34 UTC
What version of fakeroot are you attempting to build?

Please attach a build log.
Comment 4 Matteo Salonia 2022-03-01 15:22:20 UTC
Created attachment 766123 [details]
Fakeroot 1.25 build.log (failed build)
Comment 5 Matteo Salonia 2022-03-01 15:22:48 UTC
(In reply to Mike Gilbert from comment #3)
> What version of fakeroot are you attempting to build?
> 
> Please attach a build log.

Mike,
this error occurs with every available fakeroot version, from 1.25 to 1.27.

In the attachments you'll find "fakeroot-1.25.log", a build log from fakeroot-1.25's failed build.
Comment 6 Mike Gilbert gentoo-dev 2022-03-01 15:31:24 UTC
> With these changes, I reverted "fakeroot-1.25.3-glibc-2.33.patch" 's changes, patch provided by the package mantainer of fakeroot.

Do you mean that this change been applied upstream already? Please provide a link.
Comment 7 Matteo Salonia 2022-03-01 15:38:33 UTC
(In reply to Mike Gilbert from comment #6)
> > With these changes, I reverted "fakeroot-1.25.3-glibc-2.33.patch" 's changes, patch provided by the package mantainer of fakeroot.
> 
> Do you mean that this change been applied upstream already? Please provide a
> link.

Sorry if I haven't been clear, here's what I mean.
The Gentoo package mantainer, "Gentoo Base System", provides a patch called "fakeroot-1.25.3-glibc-2.33.patch". You can find this patch in the following directory: "/var/db/repos/gentoo/sys-apps/fakeroot/files/fakeroot-1.25.3-glibc-2.33.patch"

Then, what I did is fix two lines of that patch, which regard the "openat" function, that causes build issues, at least for me (see fakeroot-1.25.log)

To temporarily override the patch, I added this patch in my user patches folder.
What should be done is fix the patch (/var/db/repos/gentoo/sys-apps/fakeroot/files/fakeroot-1.25.3-glibc-2.33.patch) and remove those lines (lines 331 to 350, lines 402 to 410).

Removing those lines fixes build problems, at least for me.
Comment 8 Matteo Salonia 2022-03-01 15:39:47 UTC
(In reply to Matteo Salonia from comment #7)
> The Gentoo package mantainer, "Gentoo Base System"

If it wasn't obvious, I meant the maintainer of the "fakeroot" Gentoo package.
Comment 9 Mike Gilbert gentoo-dev 2022-03-01 15:45:47 UTC
You said you also tried fakeroot-1.27. That version does not apply fakeroot-1.25.3-glibc-2.33.patch.

Do you experience the same failure with that version?
Comment 10 Matteo Salonia 2022-03-01 15:48:18 UTC
(In reply to Mike Gilbert from comment #9)
> You said you also tried fakeroot-1.27. That version does not apply
> fakeroot-1.25.3-glibc-2.33.patch.
> 
> Do you experience the same failure with that version?

Yes, yes I do.
Comment 11 Mike Gilbert gentoo-dev 2022-03-01 15:51:24 UTC
In that case, the problem exists in the upstream code and must be fixed there first.

I think it would be helpful if you could do some more testing to figure out which of your CFLAGS is triggering the issue.
Comment 12 Matteo Salonia 2022-03-01 15:55:57 UTC
(In reply to Mike Gilbert from comment #11)
> In that case, the problem exists in the upstream code and must be fixed
> there first.

I don't think so: the patch is provided by Gentoo and causes issues for me, I don't know about others

> I think it would be helpful if you could do some more testing to figure out
> which of your CFLAGS is triggering the issue.

I built fakeroot with the same CFLAGS, I didn't change them, for both the failed and the successful build.

The failed build is the build before this patch (fakeroot-revert-patch-changes.patch), the successful build is the build after applying it.

(CFLAGS: "-Ofast -pipe -march=haswell -mtune=haswell -fno-plt -falign-functions=32 -floop-nest-optimize -fipa-pta -fno-semantic-interposition -fno-common -fno-signed-zeros -fno-trapping-math -fassociative-math -freciprocal-math -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fcx-limited-range -fexcess-precision=fast -fdevirtualize-at-ltrans"; no LTO here and ccache was disabled with FEATURES="-ccache" and other options described above.)
Comment 13 Mike Gilbert gentoo-dev 2022-03-01 16:06:02 UTC
(In reply to Matteo Salonia from comment #12)
> (In reply to Mike Gilbert from comment #11)
> > In that case, the problem exists in the upstream code and must be fixed
> > there first.
> 
> I don't think so: the patch is provided by Gentoo and causes issues for me,
> I don't know about others

fakeroot-1.25.3-glibc-2.33.patch just backports bug fixes to fakeroot-1.25.3 from newer versions of fakeroot.

fakeroot-1.27.ebuild applies no patches. We do not alter the upstream code in any way for that that version.

> I built fakeroot with the same CFLAGS, I didn't change them, for both the failed and the successful build.

I am unable to reproduce the issue. The obvious trigger is your crazy-looking CFLAGS. If you can identify which one causes this problem, that would be helpful.
Comment 14 Matteo Salonia 2022-03-01 16:09:26 UTC
Created attachment 766124 [details]
Archive containing photo proof (emerge -p fakeroot, portage applying custom patch, successful emerge)

Added archive (fakeroot.tar.xz) containing the following pictures:

emerge -p fakeroot
portage successfully applies patch I created (fakeroot-revert-patch-changes.patch)
portage emerges fakeroot successfully
Comment 15 Matteo Salonia 2022-03-01 16:10:11 UTC
(In reply to Mike Gilbert from comment #13)
> I am unable to reproduce the issue. The obvious trigger is your
> crazy-looking CFLAGS. If you can identify which one causes this problem,
> that would be helpful.

OK. I'll test the CFLAGS and get back to you.
Comment 16 Matteo Salonia 2022-03-01 16:19:08 UTC
Update:

- Build FAILS with CFLAGS: "-Ofast -pipe -march=haswell -mtune=haswell -fno-plt -falign-functions=32 -floop-nest-optimize -fipa-pta -fno-semantic-interposition -fno-common"

- Build is SUCCESSFUL with CFLAGS: "-Ofast -pipe -march=haswell -mtune=haswell -fno-plt -falign-functions=32 -floop-nest-optimize -fipa-pta -fno-common"

- Build is SUCCESSFUL with CFLAGS: "-Ofast -pipe -march=haswell -mtune=haswell -fno-plt -falign-functions=32 -floop-nest-optimize -fipa-pta -fno-common -fno-signed-zeros -fno-trapping-math -fassociative-math -freciprocal-math -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fcx-limited-range -fexcess-precision=fast -fdevirtualize-at-ltrans"

The culprit seems to be "-fno-semantic-interposition". Removing it fixes the problem. Strangely, with this flag on, I have no issues when building with the patch I provided.
Comment 17 Matteo Salonia 2022-03-01 16:28:30 UTC
Created attachment 766125 [details]
Successful fakeroot-1.27 build.log

Added fakeroot-1.27 build.log

With this build, you can see the CFLAGS include -fno-semantic-interposition.
This build is SUCCESSFUL because portage applies the patch I created, "fakeroot-revert-patch-changes.patch"
Comment 18 Mike Gilbert gentoo-dev 2022-03-01 17:08:45 UTC
Thanks for testing!

Although your patch "fixes" the issue for you, I'm not convinced it is the correct solution here. Presumably that code was added to fix some other issue, and just needs to be adjusted rather than removed entirely.

I would suggest reporting the problem to the upstream maintainer.

https://bugs.debian.org/fakeroot
Comment 19 Mike Gilbert gentoo-dev 2022-03-01 18:50:28 UTC
Actually, it looks like this might be a bug in gcc.
Comment 20 Larry the Git Cow gentoo-dev 2022-04-12 22:38:02 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7af3ec75563c6744dba7db4bd94da818844c6039

commit 7af3ec75563c6744dba7db4bd94da818844c6039
Author:     Randall Vasquez <ran.dall@icloud.com>
AuthorDate: 2022-04-12 13:34:17 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-04-12 22:37:51 +0000

    sys-apps/fakeroot: add flag-o-matic filter for flag -fno-semantic-interposition
    
    Bug: https://bugs.gentoo.org/834445
    Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101270
    Signed-off-by: Randall Vasquez <ran.dall@icloud.com>
    Closes: https://github.com/gentoo/gentoo/pull/25007
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/fakeroot/fakeroot-1.25.3-r1.ebuild | 4 ++++
 sys-apps/fakeroot/fakeroot-1.26-r1.ebuild   | 4 ++++
 sys-apps/fakeroot/fakeroot-1.27.ebuild      | 4 ++++
 3 files changed, 12 insertions(+)
Comment 21 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-01 23:18:18 UTC
We've added a workaround downstream, but I don't think we can do much more.