mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH 1/1] Use compiler includes for musl-clang, like musl-gcc
@ 2016-07-06 17:22 Aidan Hobson Sayers
  2016-07-06 17:44 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Aidan Hobson Sayers @ 2016-07-06 17:22 UTC (permalink / raw)
  To: musl; +Cc: Aidan Hobson Sayers

#include <unwind.h>
int main() {}

The above currently compiles with musl-gcc but not with musl-clang. This
patch fixes the latter.

---
 tools/musl-clang.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/musl-clang.in b/tools/musl-clang.in
index 623de6f..0018932 100644
--- a/tools/musl-clang.in
+++ b/tools/musl-clang.in
@@ -24,7 +24,7 @@ exec $cc \
     -B"$thisdir" \
     -fuse-ld=musl-clang \
     -static-libgcc \
-    -nostdinc \
+    -nostdlibinc \
     --sysroot "$libc" \
     -isystem "$libc_inc" \
     -L-user-start \
-- 
1.9.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] Use compiler includes for musl-clang, like musl-gcc
  2016-07-06 17:22 [PATCH 1/1] Use compiler includes for musl-clang, like musl-gcc Aidan Hobson Sayers
@ 2016-07-06 17:44 ` Rich Felker
  2016-07-06 17:47   ` Aidan Hobson Sayers
  2016-10-29 11:49   ` Aidan Hobson Sayers
  0 siblings, 2 replies; 5+ messages in thread
From: Rich Felker @ 2016-07-06 17:44 UTC (permalink / raw)
  To: musl

On Wed, Jul 06, 2016 at 06:22:05PM +0100, Aidan Hobson Sayers wrote:
> #include <unwind.h>
> int main() {}
> 
> The above currently compiles with musl-gcc but not with musl-clang. This
> patch fixes the latter.
> 
> ---
>  tools/musl-clang.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/musl-clang.in b/tools/musl-clang.in
> index 623de6f..0018932 100644
> --- a/tools/musl-clang.in
> +++ b/tools/musl-clang.in
> @@ -24,7 +24,7 @@ exec $cc \
>      -B"$thisdir" \
>      -fuse-ld=musl-clang \
>      -static-libgcc \
> -    -nostdinc \
> +    -nostdlibinc \
>      --sysroot "$libc" \
>      -isystem "$libc_inc" \
>      -L-user-start \
> -- 

What happens when you #include <stddef.h> after making this change? Do
you get the compiler-provided one or musl's? You should be able to
tell by running musl-clang -E foo.c

Rich


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Re: [PATCH 1/1] Use compiler includes for musl-clang, like musl-gcc
  2016-07-06 17:44 ` Rich Felker
@ 2016-07-06 17:47   ` Aidan Hobson Sayers
  2016-10-29 11:49   ` Aidan Hobson Sayers
  1 sibling, 0 replies; 5+ messages in thread
From: Aidan Hobson Sayers @ 2016-07-06 17:47 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]

```
/tmp/tmp.C3EY2NIDbS $ cat x.c
#include <unwind.h>
#include <stddef.h>
int main() {}
/tmp/tmp.C3EY2NIDbS $ ./musl/prefix/bin/musl-clang -E x.c | grep stddef
clang: warning: argument unused during compilation: '-static-libgcc'
clang: warning: argument unused during compilation: '-L-user-start'
clang: warning: argument unused during compilation:
'-L/tmp/tmp.C3EY2NIDbS/musl/prefix/lib'
clang: warning: argument unused during compilation: '-L-user-end'
# 1 "/tmp/tmp.C3EY2NIDbS/musl/prefix/include/stddef.h" 1 3
# 17 "/tmp/tmp.C3EY2NIDbS/musl/prefix/include/stddef.h" 3
# 18 "/tmp/tmp.C3EY2NIDbS/musl/prefix/include/stddef.h" 2 3
```

On 6 July 2016 at 18:44, Rich Felker <dalias@libc.org> wrote:

> On Wed, Jul 06, 2016 at 06:22:05PM +0100, Aidan Hobson Sayers wrote:
> > #include <unwind.h>
> > int main() {}
> >
> > The above currently compiles with musl-gcc but not with musl-clang. This
> > patch fixes the latter.
> >
> > ---
> >  tools/musl-clang.in | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/musl-clang.in b/tools/musl-clang.in
> > index 623de6f..0018932 100644
> > --- a/tools/musl-clang.in
> > +++ b/tools/musl-clang.in
> > @@ -24,7 +24,7 @@ exec $cc \
> >      -B"$thisdir" \
> >      -fuse-ld=musl-clang \
> >      -static-libgcc \
> > -    -nostdinc \
> > +    -nostdlibinc \
> >      --sysroot "$libc" \
> >      -isystem "$libc_inc" \
> >      -L-user-start \
> > --
>
> What happens when you #include <stddef.h> after making this change? Do
> you get the compiler-provided one or musl's? You should be able to
> tell by running musl-clang -E foo.c
>
> Rich
>



-- 
Aidan

Co-authored a book on Docker
<http://manning.com/miell/?a_aid=aidanhs&a_bid=e0d48f62> - get 39% off with
the code 39miell

[-- Attachment #2: Type: text/html, Size: 3243 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Re: [PATCH 1/1] Use compiler includes for musl-clang, like musl-gcc
  2016-07-06 17:44 ` Rich Felker
  2016-07-06 17:47   ` Aidan Hobson Sayers
@ 2016-10-29 11:49   ` Aidan Hobson Sayers
  2017-06-04  2:40     ` Aidan Hobson Sayers
  1 sibling, 1 reply; 5+ messages in thread
From: Aidan Hobson Sayers @ 2016-10-29 11:49 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

On 6 July 2016 at 18:44, Rich Felker <dalias@libc.org> wrote:
>
> What happens when you #include <stddef.h> after making this change? Do
> you get the compiler-provided one or musl's? You should be able to
> tell by running musl-clang -E foo.c
>

Wondering where this patch is up to?
Per my (terse) previous response, stddef seems to be picked up from musl,
which I think is the correct behaviour.

[-- Attachment #2: Type: text/html, Size: 843 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Re: [PATCH 1/1] Use compiler includes for musl-clang, like musl-gcc
  2016-10-29 11:49   ` Aidan Hobson Sayers
@ 2017-06-04  2:40     ` Aidan Hobson Sayers
  0 siblings, 0 replies; 5+ messages in thread
From: Aidan Hobson Sayers @ 2017-06-04  2:40 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 2647 bytes --]

It was pointed out to me that it's not clear why this is the correct fix
for the problem, so I'll elaborate a bit.

First, it's useful to note the (working and likely well-tested) musl-gcc
wrapper specs file [0], with this line of interest:


-nostdinc -isystem $incdir -isystem include%s


`-nostdinc` throws away all default include directories. The following
`-isystem` arguments then add the musl includes directory, and re-add the
compiler builtins include directory. Here are the expanded arguments when
compiling my example C file with `musl-gcc -v x.c`:

-nostdinc -isystem /tmp/tmp.TG88Sa26oT/musl/prefix/include -isystem
/usr/lib/gcc/x86_64-linux-gnu/5/include


Clang does not have an equivalent of specs file, so it uses a shell script
[1]. The arguments corresponding to the gcc ones above are:

    -nostdinc \
    --sysroot "$libc" \
    -isystem "$libc_inc"


This does *not* re-add the compiler builtins include directory and so some
headers are inaccessible (this possibly hasn't come up before because
commonly-used builtins like stdbool.h are also present in the musl include
directory, leaving effectively just unwind.h and intrinsics as
inaccessible).

By altering `-nostdinc` to -nostdlibinc`, the compiler builtins are never
removed from the include directories. Although I can't find any
documentation for the priority builtins have, it's logical that they would
come last and that's backed up by the include list produced by
`./musl/prefix/bin/musl-clang -Wp,-v -E - </dev/null` after applying my
patch:

#include <...> search starts here:
 /tmp/tmp.TG88Sa26oT/musl/prefix/include
 /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include


Without my patch, the `/usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include`
directory is not present. For completeness, here's the musl-gcc output
snippet:

#include <...> search starts here:
 /tmp/tmp.TG88Sa26oT/musl/prefix/include
 /usr/lib/gcc/x86_64-linux-gnu/5/include


[0]
https://git.musl-libc.org/cgit/musl/tree/tools/musl-gcc.specs.sh?id=179766aa2ef06df854bc1d9616bf6f00ce49b7f9
[1]
https://git.musl-libc.org/cgit/musl/tree/tools/musl-clang.in?id=179766aa2ef06df854bc1d9616bf6f00ce49b7f9

On 29 October 2016 at 12:49, Aidan Hobson Sayers <aidanhs@cantab.net> wrote:

> On 6 July 2016 at 18:44, Rich Felker <dalias@libc.org> wrote:
>>
>> What happens when you #include <stddef.h> after making this change? Do
>> you get the compiler-provided one or musl's? You should be able to
>> tell by running musl-clang -E foo.c
>>
>
> Wondering where this patch is up to?
> Per my (terse) previous response, stddef seems to be picked up from musl,
> which I think is the correct behaviour.
>

[-- Attachment #2: Type: text/html, Size: 4623 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-04  2:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-06 17:22 [PATCH 1/1] Use compiler includes for musl-clang, like musl-gcc Aidan Hobson Sayers
2016-07-06 17:44 ` Rich Felker
2016-07-06 17:47   ` Aidan Hobson Sayers
2016-10-29 11:49   ` Aidan Hobson Sayers
2017-06-04  2:40     ` Aidan Hobson Sayers

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).