|
|
Message-ID: <c9827df9-7a96-1440-c2ae-35e1df69617f@gmail.com>
Date: Thu, 23 Nov 2017 01:03:21 -0700
From: Assaf Gordon <assafgordon@...il.com>
To: musl@...ts.openwall.com, Rich Felker <dalias@...c.org>
Subject: Linux headers for musl (was: Compiling libpcap from source using musl
and clang)
Hello Rich and all,
Regarding this:
On 2017-11-20 12:31 PM, Rich Felker wrote:
> On Mon, Nov 20, 2017 at 02:02:43PM -0500, Hamed Ghavamnia wrote:
>> [...]
>> The problem I'm currently facing is that the source codes require header
>> files such as linux/types.h, but there isn't any linux sub folder in the
>> include folder of my compiled musl library.
>
> [...] Otherwise you can install them yourself from the
> kernel sources or if you're using compiler wrappers on a glibc-based
> system you can make symlinks to the copies of the Linux headers in the
> glibc include dir (/usr/include/linux, etc.).
I encountered a similar issue when building libreSSL with musl
(on standard ubuntu 16.04 x86_64 machine).
The solution I've found is:
apt-get install -y linux-libc-dev
ln -s /usr/include/linux $MUSLROOT/include
ln -s /usr/include/asm-generic $MUSLROOT/include
ln -s /usr/include/x86_64-linux-gnu $MUSLROOT/include
And then there was one more strange issue:
Somewhere during compilation of libressl-portable
the file <asm/types.h> is included.
With gcc+glibc, this automatically resolves to
"/usr/include/x86_64-linux-gnu/asm/types.h".
With musl-gcc, it didn't "just work",
and adding "-I$MUSLROOT/include/x86_64-linux-gnu" seemed to have made
things worse (headers from <bits/XXX> failed to compile).
This issue can be reproduced with:
echo "#include <asm/types.h>" > 1.c
Then gcc/clang "just work":
$ gcc -E 1.c | head
# 1 "1.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "1.c"
# 1 "/usr/include/x86_64-linux-gnu/asm/types.h" 1 3 4
$ clang -E 1.c | head
# 1 "1.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 317 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "1.c" 2
# 1 "/usr/include/x86_64-linux-gnu/asm/types.h" 1 3 4
While musl does not:
$ musl-gcc -E 1.c | head
1.c:1:23: fatal error: asm/types.h: No such file or directory
compilation terminated.
# 1 "1.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "1.c"
My ugly work-around was:
cd $muslroot/include
ln -s x86_64-linux-gnu/asm asm
Is this the recommended way?
It seemed symlink'ing /usr/include/linux alone was not sufficient.
Comments very welcomed,
- assaf
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.