Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 726130 - x11-apps/xinit fails to compile if CPP is set to CC -E (x11-misc/util-macros fix)
Summary: x11-apps/xinit fails to compile if CPP is set to CC -E (x11-misc/util-macros ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2020-05-29 21:39 UTC by Agostino Sarubbo
Modified: 2020-10-11 09:34 UTC (History)
2 users (show)

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


Attachments
build.log (build.log,13.09 KB, text/plain)
2020-05-29 21:39 UTC, Agostino Sarubbo
Details
other.tar.bz2 (other.tar.bz2,7.18 KB, application/x-bzip2)
2020-05-29 21:39 UTC, Agostino Sarubbo
Details
0001-XORG_PROG_RAWCPP-Use-AC_PATH_TOOL-to-find-preprocess.patch (0001-XORG_PROG_RAWCPP-Use-AC_PATH_TOOL-to-find-preprocess.patch,1.05 KB, patch)
2020-06-16 08:15 UTC, Sergei Trofimovich (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2020-05-29 21:39:22 UTC
This is an auto-filed bug because x11-apps/xinit fails to compile if CPP is set to CC -E.
The issue was originally discovered on amd64, but it may be reproducible on other arches as well.
If you think that a different summary clarifies the issue better, feel free to change it.
Attached build log and emerge --info.

NOTE:
To reproduce this issue you may want to set the CPP variable to gcc -E.
Comment 1 Agostino Sarubbo gentoo-dev 2020-05-29 21:39:27 UTC
Created attachment 642584 [details]
build.log

build log and emerge --info
Comment 2 Agostino Sarubbo gentoo-dev 2020-05-29 21:39:30 UTC
Created attachment 642586 [details]
other.tar.bz2

other logs
Comment 3 Kent Fredric (IRC: kent\n) (RETIRED) gentoo-dev 2020-06-13 08:46:40 UTC
I'm seeing this happen without an explicit CC including '-E', and it seems this is turning up from somewhere in an inherited eclass.

Though it also turns up mentioned in config.guess ....

Using:
- Gcc 10
- gcc-config[-native-symlinks]
- binutils-config[-native-symlinks]

So this *might* be bug #tc-directly
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2020-06-16 07:41:48 UTC
This one is fun. xinit's  'XORG_PROG_RAWCPP' .m4 macro attempts to use as a raw CPP two tools: 'cpp' and '${CC} -E':
    https://cgit.freedesktop.org/xorg/util/macros/tree/xorg-macros.m4.in#n52

1. 'cpp' fails because system has only ${CHOST}-cpp. Can be fixed with one-liner:

--- a/aclocal.m4
+++ b/aclocal.m4
@@ -355,7 +355,7 @@ m4_undefine([maj_needed])
 # such as man pages and config files
 AC_DEFUN([XORG_PROG_RAWCPP],[
 AC_REQUIRE([AC_PROG_CPP])
-AC_PATH_PROGS(RAWCPP, [cpp], [${CPP}],
+AC_CHECK_TOOLS(RAWCPP, [cpp], [${CPP}],
    [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib])

 # Check for flag to avoid builtin definitions - assumes unix is predefined,

2. '${CC} -E' can't be used at all in a context expected by XORG_PROG_RAWCPP:

$ /usr/bin/x86_64-pc-linux-gnu-cpp < /dev/null
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

$ /usr/bin/x86_64-pc-linux-gnu-gcc -E < /dev/null
x86_64-pc-linux-gnu-gcc: fatal error: no input files
compilation terminated.

Looks like both should be fixed upstream.

As a workaround xorg ebuilds could set RAWCPP to an absolute path of tool-prefixed CPP:

--- a/x11-apps/xinit/xinit-1.4.1.ebuild
+++ b/x11-apps/xinit/xinit-1.4.1.ebuild
@@ -3,7 +3,7 @@

 EAPI=7

-inherit xorg-3
+inherit xorg-3 toolchain-funcs

 DESCRIPTION="X Window System initializer"

@@ -35,6 +35,12 @@ XORG_CONFIGURE_OPTIONS=(
 	--with-xinitdir="${EPREFIX}"/etc/X11/xinit
 )

+src_prepare() {
+	default
+
+	export RAWCPP=$(type -P "$(tc-getPROG RAWCPP cpp)")
+}
+
 src_install() {
 	xorg-3_src_install
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2020-06-16 08:11:12 UTC
Upstream
    https://gitlab.freedesktop.org/trofi/macros/-/commit/bd66ce3ba4a9d1d1490cb5775a2fdd0b408879b6
commit might have fixed prefixed tool detection: 

"""
On some distributions tools like cpp are prefixed with the host-triple,
to check for this prefixed version first AC_PATH_TOOL should be used. If
no prefixed cpp, it will fallback to the unprefixed name.
"""
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2020-06-16 08:15:11 UTC
Created attachment 644960 [details, diff]
0001-XORG_PROG_RAWCPP-Use-AC_PATH_TOOL-to-find-preprocess.patch

Applying 0001-XORG_PROG_RAWCPP-Use-AC_PATH_TOOL-to-find-preprocess.patch to x11-misc/util-macros makes xinit compile for me.
Comment 7 Larry the Git Cow gentoo-dev 2020-10-11 09:34:09 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8172b34489455d1cb6d6abef0a0742a3d463e919

commit 8172b34489455d1cb6d6abef0a0742a3d463e919
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-10-11 09:33:29 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-10-11 09:34:05 +0000

    x11-misc/util-macros: lookup tool-prefixed 'cpp'
    
    Reported-by: Agostino Sarubbo
    Closes: https://bugs.gentoo.org/726130
    Package-Manager: Portage-3.0.8, Repoman-3.0.1
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 .../util-macros/files/util-macros-1.19.2-CPP.patch | 33 ++++++++++++++++++++++
 x11-misc/util-macros/util-macros-1.19.2-r2.ebuild  | 21 ++++++++++++++
 2 files changed, 54 insertions(+)