mailing list of musl libc
 help / color / mirror / code / Atom feed
* converting gcc from glibc to musl
@ 2014-10-01 15:37 stephen Turner
  2014-10-01 16:10 ` Szabolcs Nagy
  0 siblings, 1 reply; 18+ messages in thread
From: stephen Turner @ 2014-10-01 15:37 UTC (permalink / raw)
  To: musl

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

Im having a really hard time getting this working correctly. Long story
short i have probobly made every mistake possible but now i have a system
with busybox, make, bash, musl (no wrapper) 3.2 headers (using 3.2 debian
kernel) and a patched binutils-2.24 and gcc-4.6.4 (with math libs)

I compile everything static and use the musl-gcc wrapper installed on by
host system to compile binutils and gcc. everything runs in the target
system but i get a error when running configure that talks about the a.out
file is not executable and gcc cannot compile programs (it does make the
a.out file though it just cant run)

would this be an issue with my headers/libs or binutils/gcc ?

The end goal here is to create the most vanilla system possible that can
dynamically use musl. albiet ive chosen some rather un-vanilla programs for
the base.

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

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

* Re: converting gcc from glibc to musl
  2014-10-01 15:37 converting gcc from glibc to musl stephen Turner
@ 2014-10-01 16:10 ` Szabolcs Nagy
  2014-10-01 17:54   ` stephen Turner
  0 siblings, 1 reply; 18+ messages in thread
From: Szabolcs Nagy @ 2014-10-01 16:10 UTC (permalink / raw)
  To: musl

* stephen Turner <stephen.n.turner@gmail.com> [2014-10-01 11:37:22 -0400]:
> Im having a really hard time getting this working correctly. Long story
> short i have probobly made every mistake possible but now i have a system
> with busybox, make, bash, musl (no wrapper) 3.2 headers (using 3.2 debian
> kernel) and a patched binutils-2.24 and gcc-4.6.4 (with math libs)
> 
> I compile everything static and use the musl-gcc wrapper installed on by
> host system to compile binutils and gcc. everything runs in the target
> system but i get a error when running configure that talks about the a.out
> file is not executable and gcc cannot compile programs (it does make the
> a.out file though it just cant run)
> 

do you have a static linked gcc with musl support on the target?
does the configure script run on the target?
you need to be more clear and provide more information like:

- can gcc compile a minimal program (empty main)?
- where does gcc/ld fail, how were they invoked (gcc -v)?
- in the executable is the loader properly set up (readelf)?
- check if the loader/libc at the right path
- can you run the executable with the loader explicitly?
- strace the executable, where does it fail?

> would this be an issue with my headers/libs or binutils/gcc ?
> 
> The end goal here is to create the most vanilla system possible that can
> dynamically use musl. albiet ive chosen some rather un-vanilla programs for
> the base.


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

* Re: converting gcc from glibc to musl
  2014-10-01 16:10 ` Szabolcs Nagy
@ 2014-10-01 17:54   ` stephen Turner
  2014-10-01 18:13     ` Szabolcs Nagy
  2014-10-01 19:00     ` Samuel Holland
  0 siblings, 2 replies; 18+ messages in thread
From: stephen Turner @ 2014-10-01 17:54 UTC (permalink / raw)
  To: musl

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

On Wed, Oct 1, 2014 at 12:10 PM, Szabolcs Nagy <nsz@port70.net> wrote:

> * stephen Turner <stephen.n.turner@gmail.com> [2014-10-01 11:37:22 -0400]:
> > Im having a really hard time getting this working correctly. Long story
> > short i have probobly made every mistake possible but now i have a system
> > with busybox, make, bash, musl (no wrapper) 3.2 headers (using 3.2 debian
> > kernel) and a patched binutils-2.24 and gcc-4.6.4 (with math libs)
> >
> > I compile everything static and use the musl-gcc wrapper installed on by
> > host system to compile binutils and gcc. everything runs in the target
> > system but i get a error when running configure that talks about the
> a.out
> > file is not executable and gcc cannot compile programs (it does make the
> > a.out file though it just cant run)
> >
>
> do you have a static linked gcc with musl support on the target?
> does the configure script run on the target?
> you need to be more clear and provide more information like:
>
> - can gcc compile a minimal program (empty main)?
>

I can compile the following program sucessfully to a.out but cannot run it.

# include <stdio.h>
main()
{
printf("hello world\n");
}

gcc test.c && chmod +x a.out && ./a.out



> - where does gcc/ld fail, how were they invoked (gcc -v)?


configure:2078: loading cache /dev/null
configure:2222: checking build system type
configure:2236: result: i686-pc-linux-gnu
configure:2283: checking host system type
configure:2296: result: i686-pc-linux-gnu
configure:2316: checking target system type
configure:2329: result: i686-pc-linux-gnu
configure:2383: checking for a BSD-compatible install
configure:2451: result: /usr/bin/install -c
configure:2462: checking whether ln works
configure:2484: result: yes
configure:2488: checking whether ln -s works
configure:2492: result: yes
configure:2499: checking for a sed that does not truncate output
configure:2563: result: /bin/sed
configure:2572: checking for gawk
configure:2602: result: no
configure:2572: checking for mawk
configure:2602: result: no
configure:2572: checking for nawk
configure:2602: result: no
configure:2572: checking for awk
configure:2588: found /usr/bin/awk
configure:2599: result: awk
configure:3913: checking for gcc
configure:3929: found /bin/gcc
configure:3940: result: gcc
configure:4169: checking for C compiler version
configure:4178: gcc --version >&5
gcc (GCC) 4.6.4
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:4189: $? = 0
configure:4178: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/root/targetfs --disable-nls
--disable-shared --without-headers --with-newlib --enable-languages=c
--disable-multilib --disable-bootstrap : (reconfigured) ../gcc/configure
--prefix=/root/targetfs --disable-nls --disable-shared --without-headers
--with-newlib --enable-languages=c --disable-multilib --disable-bootstrap
Thread model: posix
gcc version 4.6.4 (GCC)
configure:4189: $? = 0
configure:4178: gcc -V >&5
gcc: error: unrecognized option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:4189: $? = 1
configure:4178: gcc -qversion >&5
gcc: error: unrecognized option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:4189: $? = 1
configure:4209: checking for C compiler default output file name
configure:4231: gcc    conftest.c  >&5
configure:4235: $? = 0
configure:4272: result: a.out
configure:4288: checking whether the C compiler works
configure:4297: ./a.out
../gcc/configure: line 4299: ./a.out: No such file or directory
configure:4301: $? = 127
configure:4308: error: in `/gcc-build':
configure:4312: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.

- in the executable is the loader properly set up (readelf)?

- check if the loader/libc at the right path

- can you run the executable with the loader explicitly?
> - strace the executable, where does it fail?
>

I dont know how to do what your asking here is there a site i can ref on
these troubleshooting steps?


>
> > would this be an issue with my headers/libs or binutils/gcc ?
> >
> > The end goal here is to create the most vanilla system possible that can
> > dynamically use musl. albiet ive chosen some rather un-vanilla programs
> for
> > the base.
>

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

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

* Re: converting gcc from glibc to musl
  2014-10-01 17:54   ` stephen Turner
@ 2014-10-01 18:13     ` Szabolcs Nagy
  2014-10-01 19:11       ` stephen Turner
  2014-10-01 19:00     ` Samuel Holland
  1 sibling, 1 reply; 18+ messages in thread
From: Szabolcs Nagy @ 2014-10-01 18:13 UTC (permalink / raw)
  To: musl

* stephen Turner <stephen.n.turner@gmail.com> [2014-10-01 13:54:25 -0400]:
> On Wed, Oct 1, 2014 at 12:10 PM, Szabolcs Nagy <nsz@port70.net> wrote:
> > - can gcc compile a minimal program (empty main)?
> >
> 
> I can compile the following program sucessfully to a.out but cannot run it.
> 
> # include <stdio.h>
> main()
> {
> printf("hello world\n");
> }
> 
> gcc test.c && chmod +x a.out && ./a.out
> 
> 
> > - where does gcc/ld fail, how were they invoked (gcc -v)?
> 
> 
> configure:2078: loading cache /dev/null
...

i meant running

 gcc -v test.c

not the configure thing

(so we know if the compiler works at all before
starting to debug the configure script)

> - in the executable is the loader properly set up (readelf)?
> 

check if the machine type/abi is ok:

 readelf -h a.out

check if the musl loader is set up as expected:

 readelf -l a.out

(in case of dynamic linking the interpreter should be
/lib/ld-musl-ARCH.so.1 otherwise there should be no
interpreter)


> - check if the loader/libc at the right path
> 

ls -l /lib/ld-musl-*

> - can you run the executable with the loader explicitly?

run

/lib/ld-musl-ARCH.so.1 ./a.out

> > - strace the executable, where does it fail?

strace ./a.out

> 
> I dont know how to do what your asking here is there a site i can ref on
> these troubleshooting steps?

if you are not experienced with toolchains i'd try
alpine or sabotage linux first
you might be able to customize them to your liking


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

* Re: converting gcc from glibc to musl
  2014-10-01 17:54   ` stephen Turner
  2014-10-01 18:13     ` Szabolcs Nagy
@ 2014-10-01 19:00     ` Samuel Holland
  2014-10-01 19:13       ` stephen Turner
  1 sibling, 1 reply; 18+ messages in thread
From: Samuel Holland @ 2014-10-01 19:00 UTC (permalink / raw)
  To: musl

On 10/01/2014 12:54 PM, Stephen Turner wrote:
> I can compile the following program sucessfully to a.out but cannot run it.
>
> # include <stdio.h>
> main()
> {
> printf("hello world\n");
> }
>
> gcc test.c && chmod +x a.out && ./a.out

Also try compiling it statically and then running it.

     gcc -v -static test.c

What compiler flags did you use when compiling musl? If static linking 
works, but dynamic doesn't, that points to a library issue, either with 
musl or libgcc.

-- 
Regards,
Samuel Holland <samuel@sholland.net>


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

* Re: converting gcc from glibc to musl
  2014-10-01 18:13     ` Szabolcs Nagy
@ 2014-10-01 19:11       ` stephen Turner
  2014-10-01 20:44         ` Szabolcs Nagy
  0 siblings, 1 reply; 18+ messages in thread
From: stephen Turner @ 2014-10-01 19:11 UTC (permalink / raw)
  To: musl

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

On Wed, Oct 1, 2014 at 2:13 PM, Szabolcs Nagy <nsz@port70.net> wrote:

> * stephen Turner <stephen.n.turner@gmail.com> [2014-10-01 13:54:25 -0400]:
> > On Wed, Oct 1, 2014 at 12:10 PM, Szabolcs Nagy <nsz@port70.net> wrote:
> > > - can gcc compile a minimal program (empty main)?
> > >
> >
> > I can compile the following program sucessfully to a.out but cannot run
> it.
> >
> > # include <stdio.h>
> > main()
> > {
> > printf("hello world\n");
> > }
> >
> > gcc test.c && chmod +x a.out && ./a.out
> >
> >
> > > - where does gcc/ld fail, how were they invoked (gcc -v)?
> >
> >
> > configure:2078: loading cache /dev/null
> ...
>
> i meant running
>
>  gcc -v test.c
>
> not the configure thing
>
> (so we know if the compiler works at all before
> starting to debug the configure script)
>

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.7/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --enable-objc-gc
--enable-targets=all --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=i586'
 /usr/lib/gcc/i486-linux-gnu/4.7/cc1 -quiet -v -imultiarch i386-linux-gnu
test.c -quiet -dumpbase test.c -mtune=generic -march=i586 -auxbase test
-version -o /tmp/ccc9a5Pc.s
GNU C (Debian 4.7.2-5) version 4.7.2 (i486-linux-gnu)
compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10,
MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.7/../../../../i486-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i486-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.7/include-fixed
 /usr/include/i386-linux-gnu
 /usr/include
End of search list.
GNU C (Debian 4.7.2-5) version 4.7.2 (i486-linux-gnu)
compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10,
MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 86d53dcb5a2b688dea58f7b6bd2d835d
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=i586'
 as -v --32 -o /tmp/ccHDIj0a.o /tmp/ccc9a5Pc.s
GNU assembler version 2.22 (i486-linux-gnu) using BFD version (GNU Binutils
for Debian) 2.22
COMPILER_PATH=/usr/lib/gcc/i486-linux-gnu/4.7/:/usr/lib/gcc/i486-linux-gnu/4.7/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.7/:/usr/lib/gcc/i486-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i486-linux-gnu/4.7/:/usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.7/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/i486-linux-gnu/4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=i586'
 /usr/lib/gcc/i486-linux-gnu/4.7/collect2 --sysroot=/ --build-id
--no-add-needed --eh-frame-hdr -m elf_i386 --hash-style=both
-dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o
/usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu/crti.o
/usr/lib/gcc/i486-linux-gnu/4.7/crtbegin.o
-L/usr/lib/gcc/i486-linux-gnu/4.7
-L/usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu
-L/usr/lib/gcc/i486-linux-gnu/4.7/../../../../lib -L/lib/i386-linux-gnu
-L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/i486-linux-gnu/4.7/../../.. /tmp/ccHDIj0a.o -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib/gcc/i486-linux-gnu/4.7/crtend.o
/usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu/crtn.o




>
> > - in the executable is the loader properly set up (readelf)?
> >
>
> check if the machine type/abi is ok:
>
>  readelf -h a.out
>

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x8048240
  Start of program headers:          52 (bytes into file)
  Start of section headers:          1424 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         7
  Size of section headers:           40 (bytes)
  Number of section headers:         24
  Section header string table index: 21



> check if the musl loader is set up as expected:
>
>  readelf -l a.out
>
> (in case of dynamic linking the interpreter should be
> /lib/ld-musl-ARCH.so.1 otherwise there should be no
> interpreter)
>


Elf file type is EXEC (Executable file)
Entry point 0x8048240
There are 7 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x000e0 0x000e0 R E 0x4
  INTERP         0x000114 0x08048114 0x08048114 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x0040c 0x0040c R E 0x1000
  LOAD           0x00040c 0x0804940c 0x0804940c 0x000c4 0x000e4 RW  0x1000
  DYNAMIC        0x000420 0x08049420 0x08049420 0x00098 0x00098 RW  0x4
  GNU_EH_FRAME   0x000390 0x08048390 0x08048390 0x0001c 0x0001c R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10

 Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .interp .hash .dynsym .dynstr .rel.plt .init .plt .text .fini
.rodata .eh_frame_hdr .eh_frame
   03     .ctors .dtors .jcr .dynamic .got.plt .data .bss
   04     .dynamic
   05     .eh_frame_hdr
   06




>
>
> > - check if the loader/libc at the right path
> >
>
> ls -l /lib/ld-musl-*
>

not exactly, i found /lib/libc.so but no ld-musl* i created a symlink of
ld-musl* to libc.so and gcc is able to work (initially gcc doesnt work as
it cant find the lib it needs) but a.out continues to fail.


>
> > - can you run the executable with the loader explicitly?
>
> run
>
> /lib/ld-musl-ARCH.so.1 ./a.out
>

Yes, this works! albiet i used /lib/libc.so


>
> > > - strace the executable, where does it fail?
>
> strace ./a.out
>

execve("./a.out", ["./a.out"], [/* 13 vars */]) = 0
brk(0)                                  = 0x892b000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb775b000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=14405, ...}) = 0
mmap2(NULL, 14405, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7757000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
open("/lib/i386-linux-gnu/tls/i686/sse2/cmov/libc.so", O_RDONLY) = -1
ENOENT (No such file or directory)
stat64("/lib/i386-linux-gnu/tls/i686/sse2/cmov", 0xbfde3550) = -1 ENOENT
(No such file or directory)
open("/lib/i386-linux-gnu/tls/i686/sse2/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/lib/i386-linux-gnu/tls/i686/sse2", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/lib/i386-linux-gnu/tls/i686/cmov/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/lib/i386-linux-gnu/tls/i686/cmov", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/lib/i386-linux-gnu/tls/i686/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/lib/i386-linux-gnu/tls/i686", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/lib/i386-linux-gnu/tls/sse2/cmov/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/lib/i386-linux-gnu/tls/sse2/cmov", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/lib/i386-linux-gnu/tls/sse2/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/lib/i386-linux-gnu/tls/sse2", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/lib/i386-linux-gnu/tls/cmov/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/lib/i386-linux-gnu/tls/cmov", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/lib/i386-linux-gnu/tls/libc.so", O_RDONLY) = -1 ENOENT (No such file
or directory)
stat64("/lib/i386-linux-gnu/tls", 0xbfde3550) = -1 ENOENT (No such file or
directory)
open("/lib/i386-linux-gnu/i686/sse2/cmov/libc.so", O_RDONLY) = -1 ENOENT
(No such file or directory)
stat64("/lib/i386-linux-gnu/i686/sse2/cmov", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/lib/i386-linux-gnu/i686/sse2/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/lib/i386-linux-gnu/i686/sse2", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/lib/i386-linux-gnu/i686/cmov/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/lib/i386-linux-gnu/i686/cmov", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
open("/lib/i386-linux-gnu/i686/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/lib/i386-linux-gnu/i686", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
open("/lib/i386-linux-gnu/sse2/cmov/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/lib/i386-linux-gnu/sse2/cmov", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/lib/i386-linux-gnu/sse2/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/lib/i386-linux-gnu/sse2", 0xbfde3550) = -1 ENOENT (No such file or
directory)
open("/lib/i386-linux-gnu/cmov/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/lib/i386-linux-gnu/cmov", 0xbfde3550) = -1 ENOENT (No such file or
directory)
open("/lib/i386-linux-gnu/libc.so", O_RDONLY) = -1 ENOENT (No such file or
directory)
stat64("/lib/i386-linux-gnu", {st_mode=S_IFDIR|0755, st_size=12288, ...}) =
0
open("/usr/lib/i386-linux-gnu/tls/i686/sse2/cmov/libc.so", O_RDONLY) = -1
ENOENT (No such file or directory)
stat64("/usr/lib/i386-linux-gnu/tls/i686/sse2/cmov", 0xbfde3550) = -1
ENOENT (No such file or directory)
open("/usr/lib/i386-linux-gnu/tls/i686/sse2/libc.so", O_RDONLY) = -1 ENOENT
(No such file or directory)
stat64("/usr/lib/i386-linux-gnu/tls/i686/sse2", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/usr/lib/i386-linux-gnu/tls/i686/cmov/libc.so", O_RDONLY) = -1 ENOENT
(No such file or directory)
stat64("/usr/lib/i386-linux-gnu/tls/i686/cmov", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/usr/lib/i386-linux-gnu/tls/i686/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/usr/lib/i386-linux-gnu/tls/i686", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/usr/lib/i386-linux-gnu/tls/sse2/cmov/libc.so", O_RDONLY) = -1 ENOENT
(No such file or directory)
stat64("/usr/lib/i386-linux-gnu/tls/sse2/cmov", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/usr/lib/i386-linux-gnu/tls/sse2/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/usr/lib/i386-linux-gnu/tls/sse2", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/usr/lib/i386-linux-gnu/tls/cmov/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/usr/lib/i386-linux-gnu/tls/cmov", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/usr/lib/i386-linux-gnu/tls/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/usr/lib/i386-linux-gnu/tls", 0xbfde3550) = -1 ENOENT (No such file
or directory)
open("/usr/lib/i386-linux-gnu/i686/sse2/cmov/libc.so", O_RDONLY) = -1
ENOENT (No such file or directory)
stat64("/usr/lib/i386-linux-gnu/i686/sse2/cmov", 0xbfde3550) = -1 ENOENT
(No such file or directory)
open("/usr/lib/i386-linux-gnu/i686/sse2/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/usr/lib/i386-linux-gnu/i686/sse2", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/usr/lib/i386-linux-gnu/i686/cmov/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/usr/lib/i386-linux-gnu/i686/cmov", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
open("/usr/lib/i386-linux-gnu/i686/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/usr/lib/i386-linux-gnu/i686", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
open("/usr/lib/i386-linux-gnu/sse2/cmov/libc.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat64("/usr/lib/i386-linux-gnu/sse2/cmov", 0xbfde3550) = -1 ENOENT (No
such file or directory)
open("/usr/lib/i386-linux-gnu/sse2/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/usr/lib/i386-linux-gnu/sse2", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/usr/lib/i386-linux-gnu/cmov/libc.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat64("/usr/lib/i386-linux-gnu/cmov", 0xbfde3550) = -1 ENOENT (No such
file or directory)
open("/usr/lib/i386-linux-gnu/libc.so", O_RDONLY) = 3
read(3, "/* GNU ld script\n   Use the shar"..., 512) = 283
close(3)                                = 0
writev(2, [{"./a.out", 7}, {": ", 2}, {"error while loading shared
libra"..., 36}, {": ", 2}, {"/usr/lib/i386-linux-gnu/libc.so", 31}, {": ",
2}, {"invalid ELF header", 18}, {"", 0}, {"", 0}, {"\n", 1}], 10./a.out:
error while loading shared libraries: /usr/lib/i386-linux-gnu/libc.so:
invalid ELF header
) = 99
exit_group(127)                         = ?



>
> >
> > I dont know how to do what your asking here is there a site i can ref on
> > these troubleshooting steps?
>
> if you are not experienced with toolchains i'd try
> alpine or sabotage linux first
> you might be able to customize them to your liking
>

I tried alpine and have only glanced at sabotage. It never fails, when i
use someone elses distro there is something im not happy with. This coupled
with the fact that i want to learn all i can about linux and eventually get
my linux+ or other cert.  Thanks for showing me those tests! looks like i
have reading to understand how to use them effectively :)

I guess i just need to be different and as independent as possible which is
why i have fought with building this system without help for about 3 months
now working my way through issue after issue with only google as my friend
:)

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

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

* Re: converting gcc from glibc to musl
  2014-10-01 19:00     ` Samuel Holland
@ 2014-10-01 19:13       ` stephen Turner
  2014-10-01 19:35         ` Samuel Holland
  0 siblings, 1 reply; 18+ messages in thread
From: stephen Turner @ 2014-10-01 19:13 UTC (permalink / raw)
  To: musl

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

that worked like a charm. so i have a issue with the way i built musl then?
 apparently dynamic doesnt work without specifying the library but static
is fine.

On Wed, Oct 1, 2014 at 3:00 PM, Samuel Holland <samuel@sholland.net> wrote:

> On 10/01/2014 12:54 PM, Stephen Turner wrote:
>
>> I can compile the following program sucessfully to a.out but cannot run
>> it.
>>
>> # include <stdio.h>
>> main()
>> {
>> printf("hello world\n");
>> }
>>
>> gcc test.c && chmod +x a.out && ./a.out
>>
>
> Also try compiling it statically and then running it.
>
>     gcc -v -static test.c
>
> What compiler flags did you use when compiling musl? If static linking
> works, but dynamic doesn't, that points to a library issue, either with
> musl or libgcc.
>
> --
> Regards,
> Samuel Holland <samuel@sholland.net>
>

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

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

* Re: converting gcc from glibc to musl
  2014-10-01 19:13       ` stephen Turner
@ 2014-10-01 19:35         ` Samuel Holland
  2014-10-01 19:44           ` stephen Turner
  0 siblings, 1 reply; 18+ messages in thread
From: Samuel Holland @ 2014-10-01 19:35 UTC (permalink / raw)
  To: musl

On 10/01/2014 02:13 PM, Stephen Turner wrote:
> that worked like a charm. so i have a issue with the way i built musl
> then?  apparently dynamic doesnt work without specifying the library but
> static is fine.

That means your GCC is misconfigured. It's using the glibc dynamic 
loader. From the output in your other mail, it looks like you're using 
your distribution's gcc. Is musl /usr/lib/libc.so, /lib/libc.so, or 
something else? What about libc.a?

-- 
Regards,
Samuel Holland <samuel@sholland.net>


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

* Re: converting gcc from glibc to musl
  2014-10-01 19:35         ` Samuel Holland
@ 2014-10-01 19:44           ` stephen Turner
  2014-10-01 20:17             ` Samuel Holland
  0 siblings, 1 reply; 18+ messages in thread
From: stephen Turner @ 2014-10-01 19:44 UTC (permalink / raw)
  To: musl

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

That is incorrect i gave you a bad readout. (im using debian as a host
system which is the gcc i provided)


Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/root/targetfs --disable-nls
--disable-shared --without-headers --with-newlib --enable-languages=c
--disable-multilib --disable-bootstrap --disable-lto-plugin
Thread model: posix
gcc version 4.6.4 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
 /bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/cc1 -quiet -v -imultilib .
-imultiarch i386-linux-gnu -iprefix
/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/ test.c -quiet -dumpbase test.c
-mtune=generic -march=pentiumpro -auxbase test -version -o /tmp/ccgaOlfi.s
GNU C (GCC) version 4.6.4 (i686-pc-linux-gnu)
compiled by GNU C version 4.7.2, GMP version 5.0.1, MPFR version 3.0.0, MPC
version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory
"/bin/../lib/gcc/../../lib/gcc/i686-pc-linux-gnu/4.6.4/include"
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring duplicate directory
"/bin/../lib/gcc/../../lib/gcc/i686-pc-linux-gnu/4.6.4/include-fixed"
ignoring nonexistent directory
"/bin/../lib/gcc/../../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../i686-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i386-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/include
 /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/include-fixed
 /usr/local/include
 /bin/../lib/gcc/../../include
 /usr/include
End of search list.
GNU C (GCC) version 4.6.4 (i686-pc-linux-gnu)
compiled by GNU C version 4.7.2, GMP version 5.0.1, MPFR version 3.0.0, MPC
version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 19a478f4ddb9f7b3db2807c07c0f5a7e
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
 /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../i686-pc-linux-gnu/bin/as
--32 -o /tmp/ccgPcLnb.o /tmp/ccgaOlfi.s
COMPILER_PATH=/bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/:/bin/../libexec/gcc/:/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../i686-pc-linux-gnu/bin/
LIBRARY_PATH=/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/:/bin/../lib/gcc/:/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../i686-pc-linux-gnu/lib/:/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
 /bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/collect2 --eh-frame-hdr -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2
/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crt1.o
/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crti.o
/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtbegin.o
-L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4 -L/bin/../lib/gcc
-L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../i686-pc-linux-gnu/lib
-L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../.. /tmp/ccgPcLnb.o -lgcc
-lc -lgcc /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtend.o
/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crtn.o





On Wed, Oct 1, 2014 at 3:35 PM, Samuel Holland <samuel@sholland.net> wrote:

> On 10/01/2014 02:13 PM, Stephen Turner wrote:
>
>> that worked like a charm. so i have a issue with the way i built musl
>> then?  apparently dynamic doesnt work without specifying the library but
>> static is fine.
>>
>
> That means your GCC is misconfigured. It's using the glibc dynamic loader.
> From the output in your other mail, it looks like you're using your
> distribution's gcc. Is musl /usr/lib/libc.so, /lib/libc.so, or something
> else? What about libc.a?
>
>
> --
> Regards,
> Samuel Holland <samuel@sholland.net>
>

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

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

* Re: converting gcc from glibc to musl
  2014-10-01 19:44           ` stephen Turner
@ 2014-10-01 20:17             ` Samuel Holland
  2014-10-01 20:34               ` stephen Turner
  0 siblings, 1 reply; 18+ messages in thread
From: Samuel Holland @ 2014-10-01 20:17 UTC (permalink / raw)
  To: musl

On 10/01/2014 02:44 PM, stephen Turner wrote:
> That is incorrect i gave you a bad readout. (im using debian as a host
> system which is the gcc i provided)
>
>
> COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
>   /bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/collect2 --eh-frame-hdr -m
> elf_i386 -dynamic-linker /lib/ld-linux.so.2
> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crt1.o
> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crti.o
> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtbegin.o
> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4 -L/bin/../lib/gcc
> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../i686-pc-linux-gnu/lib
> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../.. /tmp/ccgPcLnb.o -lgcc
> -lc -lgcc /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtend.o
> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crtn.o

Okay, that makes more sense. Note that your 'dynamic-linker' is still 
set to glibc's, but you are linking to /lib/libc.so (the last -L 
option), which is the correct musl libc. Are you using the musl-cross 
gcc patch[0]? It will solve that for you.

[0] 
https://bitbucket.org/GregorR/musl-cross/src/default/patches/gcc-4.6.4-musl.diff

-- 
Regards,
Samuel Holland <samuel@sholland.net>


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

* Re: converting gcc from glibc to musl
  2014-10-01 20:17             ` Samuel Holland
@ 2014-10-01 20:34               ` stephen Turner
  2014-10-01 20:43                 ` stephen Turner
  2014-10-01 20:54                 ` Samuel Holland
  0 siblings, 2 replies; 18+ messages in thread
From: stephen Turner @ 2014-10-01 20:34 UTC (permalink / raw)
  To: musl

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

Yea i had to patch gcc just to get it to compile which due to various
issues i have only gotten to run on the target musl system when i use the
musl wrapper to compile gcc.

how would i go about fixing this linker issue? is it with binutils, gcc, or
musl?

I greatly appreciate all the help given, I would still be banging my head
on the desk if it wasn't for your help.


On Wed, Oct 1, 2014 at 4:17 PM, Samuel Holland <samuel@sholland.net> wrote:

> On 10/01/2014 02:44 PM, stephen Turner wrote:
>
>> That is incorrect i gave you a bad readout. (im using debian as a host
>> system which is the gcc i provided)
>>
>>
>> COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
>>   /bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/collect2 --eh-frame-hdr -m
>> elf_i386 -dynamic-linker /lib/ld-linux.so.2
>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crt1.o
>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crti.o
>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtbegin.o
>> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4 -L/bin/../lib/gcc
>> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../
>> i686-pc-linux-gnu/lib
>> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../.. /tmp/ccgPcLnb.o -lgcc
>> -lc -lgcc /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtend.o
>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crtn.o
>>
>
> Okay, that makes more sense. Note that your 'dynamic-linker' is still set
> to glibc's, but you are linking to /lib/libc.so (the last -L option), which
> is the correct musl libc. Are you using the musl-cross gcc patch[0]? It
> will solve that for you.
>
> [0] https://bitbucket.org/GregorR/musl-cross/src/default/
> patches/gcc-4.6.4-musl.diff
>
>
> --
> Regards,
> Samuel Holland <samuel@sholland.net>
>

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

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

* Re: converting gcc from glibc to musl
  2014-10-01 20:34               ` stephen Turner
@ 2014-10-01 20:43                 ` stephen Turner
  2014-10-01 20:54                 ` Samuel Holland
  1 sibling, 0 replies; 18+ messages in thread
From: stephen Turner @ 2014-10-01 20:43 UTC (permalink / raw)
  To: musl

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

i recompiled binutils with the musl wrapper, im assuming musl libs isnt the
issue since it doesnt make sense that it would search for itself but im
still not sure how to resolve the pointing issue. recompiling binutils with
the musl wrapper didnt resolve the issue obviously but would i need to set
an include or lib path for it or specify newlib like with gcc?

On Wed, Oct 1, 2014 at 4:34 PM, stephen Turner <stephen.n.turner@gmail.com>
wrote:

> Yea i had to patch gcc just to get it to compile which due to various
> issues i have only gotten to run on the target musl system when i use the
> musl wrapper to compile gcc.
>
> how would i go about fixing this linker issue? is it with binutils, gcc,
> or musl?
>
> I greatly appreciate all the help given, I would still be banging my head
> on the desk if it wasn't for your help.
>
>
> On Wed, Oct 1, 2014 at 4:17 PM, Samuel Holland <samuel@sholland.net>
> wrote:
>
>> On 10/01/2014 02:44 PM, stephen Turner wrote:
>>
>>> That is incorrect i gave you a bad readout. (im using debian as a host
>>> system which is the gcc i provided)
>>>
>>>
>>> COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
>>>   /bin/../libexec/gcc/i686-pc-linux-gnu/4.6.4/collect2 --eh-frame-hdr -m
>>> elf_i386 -dynamic-linker /lib/ld-linux.so.2
>>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crt1.o
>>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crti.o
>>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtbegin.o
>>> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4 -L/bin/../lib/gcc
>>> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../../
>>> i686-pc-linux-gnu/lib
>>> -L/bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../.. /tmp/ccgPcLnb.o -lgcc
>>> -lc -lgcc /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/crtend.o
>>> /bin/../lib/gcc/i686-pc-linux-gnu/4.6.4/../../../crtn.o
>>>
>>
>> Okay, that makes more sense. Note that your 'dynamic-linker' is still set
>> to glibc's, but you are linking to /lib/libc.so (the last -L option), which
>> is the correct musl libc. Are you using the musl-cross gcc patch[0]? It
>> will solve that for you.
>>
>> [0] https://bitbucket.org/GregorR/musl-cross/src/default/
>> patches/gcc-4.6.4-musl.diff
>>
>>
>> --
>> Regards,
>> Samuel Holland <samuel@sholland.net>
>>
>
>

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

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

* Re: converting gcc from glibc to musl
  2014-10-01 19:11       ` stephen Turner
@ 2014-10-01 20:44         ` Szabolcs Nagy
  0 siblings, 0 replies; 18+ messages in thread
From: Szabolcs Nagy @ 2014-10-01 20:44 UTC (permalink / raw)
  To: musl

* stephen Turner <stephen.n.turner@gmail.com> [2014-10-01 15:11:25 -0400]:
> On Wed, Oct 1, 2014 at 2:13 PM, Szabolcs Nagy <nsz@port70.net> wrote:
> > i meant running
> >
> >  gcc -v test.c
> >
...
> COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=i586'
>  /usr/lib/gcc/i486-linux-gnu/4.7/collect2 --sysroot=/ --build-id
> --no-add-needed --eh-frame-hdr -m elf_i386 --hash-style=both
> -dynamic-linker /lib/ld-linux.so.2

this is not a musl based toolchain, it uses the wrong dynamic-linker

> > check if the musl loader is set up as expected:
> >
> >  readelf -l a.out
> >
> > (in case of dynamic linking the interpreter should be
> > /lib/ld-musl-ARCH.so.1 otherwise there should be no
> > interpreter)
> >
> 
> 
> Elf file type is EXEC (Executable file)
> Entry point 0x8048240
> There are 7 program headers, starting at offset 52
> 
> Program Headers:
>   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   PHDR           0x000034 0x08048034 0x08048034 0x000e0 0x000e0 R E 0x4
>   INTERP         0x000114 0x08048114 0x08048114 0x00013 0x00013 R   0x1
>       [Requesting program interpreter: /lib/ld-linux.so.2]

here it should say /lib/ld-musl-$ARCH.so.1

> > ls -l /lib/ld-musl-*
> >
> 
> not exactly, i found /lib/libc.so but no ld-musl* i created a symlink of
> ld-musl* to libc.so and gcc is able to work (initially gcc doesnt work as
> it cant find the lib it needs) but a.out continues to fail.
> 
> > run
> >
> > /lib/ld-musl-ARCH.so.1 ./a.out
> >
> 
> Yes, this works! albiet i used /lib/libc.so
> 

ok so fix your toolchain to pass the right -dynamic-linker
to the linker and it will probably work


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

* Re: converting gcc from glibc to musl
  2014-10-01 20:34               ` stephen Turner
  2014-10-01 20:43                 ` stephen Turner
@ 2014-10-01 20:54                 ` Samuel Holland
  2014-10-02 20:31                   ` stephen Turner
  1 sibling, 1 reply; 18+ messages in thread
From: Samuel Holland @ 2014-10-01 20:54 UTC (permalink / raw)
  To: musl

On 10/01/2014 03:34 PM, stephen Turner wrote:
> Yea i had to patch gcc just to get it to compile which due to various
> issues i have only gotten to run on the target musl system when i use
> the musl wrapper to compile gcc.
>
> how would i go about fixing this linker issue? is it with binutils, gcc,
> or musl?

See lines 77-79 of the musl-cross patch. When you set your triple to 
i686-linux-musl instead of i686-linux-gnu, it sets musl as the default 
linker. You didn't, so it defaults to glibc, but you can still tell it 
to use musl manually, either by putting -mmusl in CFLAGS or the command 
line, or by editing the specs file, like the musl-gcc wrapper does.

Once you get it working, though, I recommend recompiling gcc with 
--host=i686-linux-musl

-- 
Regards,
Samuel Holland <samuel@sholland.net>


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

* Re: converting gcc from glibc to musl
  2014-10-01 20:54                 ` Samuel Holland
@ 2014-10-02 20:31                   ` stephen Turner
  2014-10-02 20:47                     ` Samuel Holland
  0 siblings, 1 reply; 18+ messages in thread
From: stephen Turner @ 2014-10-02 20:31 UTC (permalink / raw)
  To: musl

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

since patching with the recommended patch (the one i had wasnt a full patch
apparently) i have been able to use this option --host=i686-linux-musl
however now when i compile i run into new issues.

Firstly gmp, mpfr, and mpc do not like this flag obviously since they do
not have the musl settings patched in so i cant compile with the musl
wrapper because i cannot include those math libraries and when i try to
prebuild them and use the flag --with-mpfr=/target/location it errors out
saying it cant find any compatible versions of these libs/headers.

that brings me to compiling without the musl wrapper but with
--host=i686-linux-musl and that does work until you try to run the binary
of gcc made static which gives the error cant execute or doesnt exist.
Checking with ldd shows its static so the binary itself is corrupted in
some way.

My question now becomes, what would be the troubleshooting steps to see how
its broke if possible?

On Wed, Oct 1, 2014 at 4:54 PM, Samuel Holland <samuel@sholland.net> wrote:

> On 10/01/2014 03:34 PM, stephen Turner wrote:
>
>> Yea i had to patch gcc just to get it to compile which due to various
>> issues i have only gotten to run on the target musl system when i use
>> the musl wrapper to compile gcc.
>>
>> how would i go about fixing this linker issue? is it with binutils, gcc,
>> or musl?
>>
>
> See lines 77-79 of the musl-cross patch. When you set your triple to
> i686-linux-musl instead of i686-linux-gnu, it sets musl as the default
> linker. You didn't, so it defaults to glibc, but you can still tell it to
> use musl manually, either by putting -mmusl in CFLAGS or the command line,
> or by editing the specs file, like the musl-gcc wrapper does.
>
> Once you get it working, though, I recommend recompiling gcc with
> --host=i686-linux-musl
>
>
> --
> Regards,
> Samuel Holland <samuel@sholland.net>
>

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

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

* Re: converting gcc from glibc to musl
  2014-10-02 20:31                   ` stephen Turner
@ 2014-10-02 20:47                     ` Samuel Holland
  2014-10-02 22:40                       ` stephen Turner
  0 siblings, 1 reply; 18+ messages in thread
From: Samuel Holland @ 2014-10-02 20:47 UTC (permalink / raw)
  To: musl; +Cc: stephen Turner

On 2014-10-02 15:31, stephen Turner wrote:
> since patching with the recommended patch (the one i had wasnt a full 
> patch
> apparently) i have been able to use this option --host=i686-linux-musl
> however now when i compile i run into new issues.
> 
> Firstly gmp, mpfr, and mpc do not like this flag obviously since they 
> do
> not have the musl settings patched in so i cant compile with the musl
> wrapper because i cannot include those math libraries and when i try to
> prebuild them and use the flag --with-mpfr=/target/location it errors 
> out
> saying it cant find any compatible versions of these libs/headers.

Overriding the host is really only necessary for a few programs like 
gcc. Most
will work fine with musl, even though they detect your system as 
"i686-pc-linux-gnu".
That said, if you want to use --host on all of your programs, all you 
need is a
patch like the one here[0]. There are four or five different variations 
of the patch
though, depending on what version/configuration of autotools the project 
uses.

[0] 
https://github.com/smaeul/starch/blob/master/pkgbuilds/libmpfr/libmpfr-musl.patch

--
Regards,
Samuel Holland <samuel@sholland.net>


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

* Re: converting gcc from glibc to musl
  2014-10-02 20:47                     ` Samuel Holland
@ 2014-10-02 22:40                       ` stephen Turner
  2014-10-03 13:51                         ` stephen Turner
  0 siblings, 1 reply; 18+ messages in thread
From: stephen Turner @ 2014-10-02 22:40 UTC (permalink / raw)
  To: musl

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

Gcc is dying with /bin/bash i686-linux-musl-gcc command not found about
half to 3/4 way through build.  I know this is not enough info to help
diagnose the issue but unlike errors during config, its not pointing me to
a compile error log. I will be more than happy to provide anything you need
just let me know what that is.

thanks for your help.

On Thu, Oct 2, 2014 at 4:47 PM, Samuel Holland <samuel@sholland.net> wrote:

> On 2014-10-02 15:31, stephen Turner wrote:
>
>> since patching with the recommended patch (the one i had wasnt a full
>> patch
>> apparently) i have been able to use this option --host=i686-linux-musl
>> however now when i compile i run into new issues.
>>
>> Firstly gmp, mpfr, and mpc do not like this flag obviously since they do
>> not have the musl settings patched in so i cant compile with the musl
>> wrapper because i cannot include those math libraries and when i try to
>> prebuild them and use the flag --with-mpfr=/target/location it errors out
>> saying it cant find any compatible versions of these libs/headers.
>>
>
> Overriding the host is really only necessary for a few programs like gcc.
> Most
> will work fine with musl, even though they detect your system as
> "i686-pc-linux-gnu".
> That said, if you want to use --host on all of your programs, all you need
> is a
> patch like the one here[0]. There are four or five different variations of
> the patch
> though, depending on what version/configuration of autotools the project
> uses.
>
> [0] https://github.com/smaeul/starch/blob/master/pkgbuilds/
> libmpfr/libmpfr-musl.patch
>
> --
> Regards,
> Samuel Holland <samuel@sholland.net>
>

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

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

* Re: converting gcc from glibc to musl
  2014-10-02 22:40                       ` stephen Turner
@ 2014-10-03 13:51                         ` stephen Turner
  0 siblings, 0 replies; 18+ messages in thread
From: stephen Turner @ 2014-10-03 13:51 UTC (permalink / raw)
  To: musl

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

Thanks for the help, that fixed the issue.

On Thu, Oct 2, 2014 at 6:40 PM, stephen Turner <stephen.n.turner@gmail.com>
wrote:

> Gcc is dying with /bin/bash i686-linux-musl-gcc command not found about
> half to 3/4 way through build.  I know this is not enough info to help
> diagnose the issue but unlike errors during config, its not pointing me to
> a compile error log. I will be more than happy to provide anything you need
> just let me know what that is.
>
> thanks for your help.
>
> On Thu, Oct 2, 2014 at 4:47 PM, Samuel Holland <samuel@sholland.net>
> wrote:
>
>> On 2014-10-02 15:31, stephen Turner wrote:
>>
>>> since patching with the recommended patch (the one i had wasnt a full
>>> patch
>>> apparently) i have been able to use this option --host=i686-linux-musl
>>> however now when i compile i run into new issues.
>>>
>>> Firstly gmp, mpfr, and mpc do not like this flag obviously since they do
>>> not have the musl settings patched in so i cant compile with the musl
>>> wrapper because i cannot include those math libraries and when i try to
>>> prebuild them and use the flag --with-mpfr=/target/location it errors out
>>> saying it cant find any compatible versions of these libs/headers.
>>>
>>
>> Overriding the host is really only necessary for a few programs like gcc.
>> Most
>> will work fine with musl, even though they detect your system as
>> "i686-pc-linux-gnu".
>> That said, if you want to use --host on all of your programs, all you
>> need is a
>> patch like the one here[0]. There are four or five different variations
>> of the patch
>> though, depending on what version/configuration of autotools the project
>> uses.
>>
>> [0] https://github.com/smaeul/starch/blob/master/pkgbuilds/
>> libmpfr/libmpfr-musl.patch
>>
>> --
>> Regards,
>> Samuel Holland <samuel@sholland.net>
>>
>
>

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

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

end of thread, other threads:[~2014-10-03 13:51 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-01 15:37 converting gcc from glibc to musl stephen Turner
2014-10-01 16:10 ` Szabolcs Nagy
2014-10-01 17:54   ` stephen Turner
2014-10-01 18:13     ` Szabolcs Nagy
2014-10-01 19:11       ` stephen Turner
2014-10-01 20:44         ` Szabolcs Nagy
2014-10-01 19:00     ` Samuel Holland
2014-10-01 19:13       ` stephen Turner
2014-10-01 19:35         ` Samuel Holland
2014-10-01 19:44           ` stephen Turner
2014-10-01 20:17             ` Samuel Holland
2014-10-01 20:34               ` stephen Turner
2014-10-01 20:43                 ` stephen Turner
2014-10-01 20:54                 ` Samuel Holland
2014-10-02 20:31                   ` stephen Turner
2014-10-02 20:47                     ` Samuel Holland
2014-10-02 22:40                       ` stephen Turner
2014-10-03 13:51                         ` stephen Turner

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