* Compiling libpcap from source using musl and clang
@ 2017-11-20 19:02 Hamed Ghavamnia
2017-11-20 19:31 ` Rich Felker
0 siblings, 1 reply; 4+ messages in thread
From: Hamed Ghavamnia @ 2017-11-20 19:02 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 500 bytes --]
Hi to all,
I'm trying to compile the libpcap library from source using musl and clang.
It compiles if I only use clang with libc, but using musl it dies.
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. Is that normal? Should I be
able to compile libpcap using musl, or does it require any features which
haven't been implemented in musl yet?
Thanks,
Hamed
[-- Attachment #2: Type: text/html, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Compiling libpcap from source using musl and clang
2017-11-20 19:02 Compiling libpcap from source using musl and clang Hamed Ghavamnia
@ 2017-11-20 19:31 ` Rich Felker
2017-11-23 8:03 ` Linux headers for musl (was: Compiling libpcap from source using musl and clang) Assaf Gordon
0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2017-11-20 19:31 UTC (permalink / raw)
To: musl
On Mon, Nov 20, 2017 at 02:02:43PM -0500, Hamed Ghavamnia wrote:
> Hi to all,
>
> I'm trying to compile the libpcap library from source using musl and clang.
> It compiles if I only use clang with libc, but using musl it dies.
> 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. Is that normal? Should I be
> able to compile libpcap using musl, or does it require any features which
> haven't been implemented in musl yet?
To get the linux/* headers you need to install them. If you're using a
cross toolchain built with musl-cross-make, they're installed for you
in its sysroot. 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.). Do NOT add
-I/usr/include though to get them; this will use glibc headers and
badly break things.
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* Linux headers for musl (was: Compiling libpcap from source using musl and clang)
2017-11-20 19:31 ` Rich Felker
@ 2017-11-23 8:03 ` Assaf Gordon
2017-11-23 11:02 ` Szabolcs Nagy
0 siblings, 1 reply; 4+ messages in thread
From: Assaf Gordon @ 2017-11-23 8:03 UTC (permalink / raw)
To: musl, Rich Felker
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Linux headers for musl (was: Compiling libpcap from source using musl and clang)
2017-11-23 8:03 ` Linux headers for musl (was: Compiling libpcap from source using musl and clang) Assaf Gordon
@ 2017-11-23 11:02 ` Szabolcs Nagy
0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2017-11-23 11:02 UTC (permalink / raw)
To: musl
* Assaf Gordon <assafgordon@gmail.com> [2017-11-23 01:03:21 -0700]:
> 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
>
...
> My ugly work-around was:
>
> cd $muslroot/include
> ln -s x86_64-linux-gnu/asm asm
>
>
> Is this the recommended way?
no, the recommended way is to use a cross toolchain that
is built for musl (and has the linux headers installed),
instead of using your platform toolchain with various hacks
(like the musl-gcc wrapper around gcc)
in case you prefer musl-gcc then you should install your
deps to $MUSLROOT instead of trying to use platform components,
this includes library and header deps as well, so get linux
sources and install the headers yourself
make ARCH=x86 INSTALL_HDR_PATH=staging O=builddir headers_install
cp -a -n staging/include $MUSLROOT
(not tested)
(note that the ubuntu toolchain uses 'multi-arch' layout for
the include and library paths, but musl-gcc drops all platform
specific include paths and uses its own (standard) layout,
so symlinking stuff from ubuntu include path like
'x86_64-linux-gnu' wont work)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-23 11:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-20 19:02 Compiling libpcap from source using musl and clang Hamed Ghavamnia
2017-11-20 19:31 ` Rich Felker
2017-11-23 8:03 ` Linux headers for musl (was: Compiling libpcap from source using musl and clang) Assaf Gordon
2017-11-23 11:02 ` Szabolcs Nagy
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).