mailing list of musl libc
 help / color / mirror / code / Atom feed
* Re: MUSL 1.1.10 Static linking issue
@ 2015-12-02 21:37 N Jain
  2015-12-02 23:33 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: N Jain @ 2015-12-02 21:37 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

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

Hi Rich,

Thanks. I was trying to find the correct email id as my previous message
bounced.


> I assume you mean gcc 5.2.0 targeting musl?

Yes it is correct I am using musl 1.1.10 with gcc5.2.0.

 > Can you show the actual error you're getting?

I am getting run time failure and the issue is in __set_thread_area.c file

int __set_thread_area(void *p)
{
#if !__ARM_ARCH_7A__ && !__ARM_ARCH_7R__ && __ARM_ARCH < 7
if (__hwcap & HWCAP_TLS) {
                .....
}
} else {
*int ver = *(int *)0xffff0ffc;*
* SET(gettp, kuser);*
* SET(cas, kuser);*
* SET(barrier, kuser);*
* if (ver < 2) a_crash();*
* if (ver < 3) SET(barrier, oldkuser);*
}
#endif
return __syscall(0xf0005, p);
}

I used debugger to root cause and found that while generating toolchain
__ARM_ARCH_7A option is not getting configured correctly.
I am reaching to "else" part and getting abort at 0xffff0ffc.

> I can't tell from your email exactly what you're trying
to do, though.

I am trying to compile an ARM OS user application using generated toolchain
(I am following link -
https://github.com/GregorR/musl-cross).

I can generate the toolchain successfully though not sure what
configuration options I am missing during toolchain generation as passing
 " -mcpu=cortex-a15"  to compiler is not configuring __ARM_ARCH_7A__ macro ?

I am using scripts config.sh but only configuring "ARCH=arm". I need
toolchain for cortex-a15 but there is no option to do so ?

Can you please give me some pointers as how to resolve this ?

Thanks,
NJ



On Tue, Dec 1, 2015 at 7:37 PM, Rich Felker <dalias@libc.org> wrote:

> I've CC'd the musl list which I think you intended to do; your
> original cc was to musl-admin rather than musl so it didn't make it to
> the list.
>
> On Tue, Dec 01, 2015 at 12:37:28PM -0500, N Jain wrote:
> > Hi,
> >
> >
> > I am using MUSL 5.2.0 latest compiler for compiling my ARM application
> but
>
> I assume you mean gcc 5.2.0 targeting musl?
>
> > when I try to run the application I am getting issue at __set_thread_area
> > API.
>
> Can you show the actual error you're getting?
>
> > I am not sure if the static linking is broken for MUSL 5.2.0 ? I am using
> > following command to compile the application and using "-static" option
> > while linking to ignore dynamic linking.
> >
> > Please let me know how to avoid dynamic linking and how to resolve this
> ? I
> > do want dynamic as well static linking capabilities so I am generating
> > compile with default configuration.
> >
> > arm-linux-musleabi-gcc -static-libgcc -static-libstdc++ -I. -MD -MP
> > -mcpu=cortex-a15  -O2 -g  -Wall -Werror  -std=gnu11  -D_POSIX_SOURCE -c
> > hello.c -o hello.o
> >
> > arm-linux-musleabi-ld -static -nostartfiles $(OBJS) libs.a -Tlink.ld -o
> > app.elf
>
> Using ld directly is not expected to work unless you reproduce all the
> options the compiler driver (gcc) would pass to it; the main place you
> _might_ want to invoke ld directly is when doing
> freestanding/bare-metal development, but musl is not going to be
> useful for this out of the box; you'd need to customize it to your
> environment. I can't tell from your email exactly what you're trying
> to do, though.
>
> Rich
>

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

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

* Re: Re: MUSL 1.1.10 Static linking issue
  2015-12-02 21:37 MUSL 1.1.10 Static linking issue N Jain
@ 2015-12-02 23:33 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2015-12-02 23:33 UTC (permalink / raw)
  To: musl; +Cc: Rich Felker

* N Jain <jain61@gmail.com> [2015-12-02 16:37:33 -0500]:
>  > Can you show the actual error you're getting?
> 
> I am getting run time failure and the issue is in __set_thread_area.c file
> 
> int __set_thread_area(void *p)
> {
> #if !__ARM_ARCH_7A__ && !__ARM_ARCH_7R__ && __ARM_ARCH < 7
> if (__hwcap & HWCAP_TLS) {
>                 .....
> }
> } else {
> *int ver = *(int *)0xffff0ffc;*
> * SET(gettp, kuser);*
> * SET(cas, kuser);*
> * SET(barrier, kuser);*
> * if (ver < 2) a_crash();*
> * if (ver < 3) SET(barrier, oldkuser);*
> }
> #endif
> return __syscall(0xf0005, p);
> }
> 
> I used debugger to root cause and found that while generating toolchain
> __ARM_ARCH_7A option is not getting configured correctly.
> I am reaching to "else" part and getting abort at 0xffff0ffc.
> 

you compiled musl for < armv7-a
(musl keeps compatibility so the binary should work
on >=armv7-a too).

the kernel did not report tls support in hwcap,
nor it had the kernel helper pages.
sounds like a broken kernel to me.

dumping the auxv and /proc/cpuinfo could be useful,
(but dont know how to display the auxv easily).

> I am trying to compile an ARM OS user application using generated toolchain
> (I am following link -
> https://github.com/GregorR/musl-cross).
> 
> I can generate the toolchain successfully though not sure what
> configuration options I am missing during toolchain generation as passing
>  " -mcpu=cortex-a15"  to compiler is not configuring __ARM_ARCH_7A__ macro ?
> 

in musl-cross you need something like

TRIPLE=arm-linux-musleabihf
GCC_BOOTSTRAP_CONFFLAGS="--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16"
GCC_CONFFLAGS="--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16"

for more gcc options see
http://gcc.gnu.org/install/configure.html

you can test the toolchain by

 gcc -v

and

 gcc -E -dM - </dev/null |grep ARM

shows the predefined arm macros

http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/index.html

> I am using scripts config.sh but only configuring "ARCH=arm". I need
> toolchain for cortex-a15 but there is no option to do so ?
> 

pass the -m* options in CFLAGS when configuring musl
if you want further control over code generation.

http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html


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

end of thread, other threads:[~2015-12-02 23:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 21:37 MUSL 1.1.10 Static linking issue N Jain
2015-12-02 23:33 ` 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).