mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Assaf Gordon <assafgordon@gmail.com>
To: musl@lists.openwall.com, Rich Felker <dalias@libc.org>
Subject: Linux headers for musl (was: Compiling libpcap from source using musl and clang)
Date: Thu, 23 Nov 2017 01:03:21 -0700	[thread overview]
Message-ID: <c9827df9-7a96-1440-c2ae-35e1df69617f@gmail.com> (raw)
In-Reply-To: <20171120193126.GK1627@brightrain.aerifal.cx>

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






  reply	other threads:[~2017-11-23  8:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Assaf Gordon [this message]
2017-11-23 11:02     ` Linux headers for musl (was: Compiling libpcap from source using musl and clang) Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9827df9-7a96-1440-c2ae-35e1df69617f@gmail.com \
    --to=assafgordon@gmail.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).