Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 485146

Summary: sys-libs/glibc-2.17 with CPP="clang -E" - fails due to incompatible check in src_unpack.eblit
Product: Gentoo Linux Reporter: eroen <erikdenstore+gbugs>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 408963    
Attachments: build.log

Description eroen 2013-09-16 22:57:04 UTC
The get_kheader_version() function in sys-libs/glibc/files/eblits/src_unpack.eblit seems to be incompatible with sys-devel/clang . This causes problems when trying to use clang as a system compiler.

Reproducible: Always

Steps to Reproduce:
1. emerge clang
2. CC=clang CPP="clang -E" emerge -1 sys-libs/glibc
Actual Results:  
(...)
 * Checking linux-headers version (0.0.0 >= 2.6.16) ...                                   [ !! ]

 * You need linux-headers of at least 2.6.16 for NPTL support!
 * ERROR: sys-libs/glibc-2.17::gentoo failed (unpack phase):
 *   linux-headers version too low!
(...)

Expected Results:  
Everything "just works".

The following patch seems to solve the issue for me, although I only tried with clang-3.3-r100 and gcc-4.8.1 . It is possible it will not work as well with other versions of either compiler, necessitating different checks based on compiler (or a different approach altogether).

diff --git a/sys-libs/glibc/files/eblits/src_unpack.eblit b/sys-libs/glibc/files/eblits/src_unpack.eblit
index 52f22f9..c397a73 100644
--- a/sys-libs/glibc/files/eblits/src_unpack.eblit
+++ b/sys-libs/glibc/files/eblits/src_unpack.eblit
@@ -17,7 +17,7 @@ eend_KV() {
 
 get_kheader_version() {
        printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
-       $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" | \
+       $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \
   

For reference, a more minimal reproduction of the issue:
eroen@occam ~ $ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | x86_64-pc-linux-gnu-cpp -I /usr/include/
# 1 "<stdin>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
# 1 "/usr/include/linux/version.h" 1 3 4
# 2 "<stdin>" 2
199424
eroen@occam ~ $ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | clang -E -I /usr/include/
clang: error: no input files
eroen@occam ~ $ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | x86_64-pc-linux-gnu-cpp -I /usr/include/ -
# 1 "<stdin>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
# 1 "/usr/include/linux/version.h" 1 3 4
# 2 "<stdin>" 2
199424
eroen@occam ~ $ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | clang -E -I /usr/include/ -
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 159 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
# 1 "/usr/include/linux/version.h" 1 3 4
# 2 "<stdin>" 2
199424
Comment 1 eroen 2013-09-16 22:58:22 UTC
Created attachment 358840 [details]
build.log
Comment 2 SpanKY gentoo-dev 2013-09-28 22:06:30 UTC
last i checked, clang didn't produce a usable glibc.  i don't mind committing this change, but if the resulting glibc build doesn't work, that's to be expected.
Comment 3 SpanKY gentoo-dev 2013-09-28 22:08:03 UTC
should be all set now in the tree; thanks for the report!

Commit message: Tweak how we check the kernel header version to work w/clang
http://sources.gentoo.org/sys-libs/glibc/files/eblits/src_unpack.eblit?r1=1.23&r2=1.24