mailing list of musl libc
 help / color / mirror / code / Atom feed
* Compile error doing cross build on arm
@ 2013-07-08 15:58 Ian Denhardt
  2013-07-08 17:51 ` Harald Becker
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Denhardt @ 2013-07-08 15:58 UTC (permalink / raw)
  To: musl

Hey,

So I just hit a compilation error trying to cross compile musl for arm:

arm-elf-gcc -std=c99 -nostdinc -ffreestanding -fexcess-precision=standard -frounding-math -D_XOPEN_SOURCE=700 -I./arch/arm -I./src/internal -I./include  -Os -pipe -fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables -Wa,--noexecstack -falign-functions=1 -falign-labels=1 -falign-loops=1 -falign-jumps=1 -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith -fno-stack-protector  -c -o src/stdio/vfwprintf.o src/stdio/vfwprintf.c
src/stdio/vfwprintf.c: In function 'wprintf_core':
src/stdio/vfwprintf.c:195:3: error: pointer targets in passing argument 2 of 'wcsspn' differ in signedness [-Werror=pointer-sign]
In file included from src/stdio/vfwprintf.c:7:0:
./include/wchar.h:62:8: note: expected 'const wchar_t *' but argument is of type 'int *'
cc1: some warnings being treated as errors
make: *** [src/stdio/vfwprintf.o] Error 1
make: *** Waiting for unfinished jobs....

I'm using the 0.9.11 release. My config.mak looks like:

# This version of config.mak was generated by configure
# Any changes made here will be lost if configure is re-run
ARCH = arm
prefix = ../arm
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(prefix)/lib
includedir = $(prefix)/include
syslibdir = /lib
CC = arm-elf-gcc
CFLAGS= -Os -pipe -fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables -Wa,--noexecstack -falign-functions=1 -falign-labels=1 -falign-loops=1 -falign-jumps=1 -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith -fno-stack-protector 
CFLAGS_C99FSE = -std=c99 -nostdinc -ffreestanding -fexcess-precision=standard -frounding-math
CPPFLAGS = 
LDFLAGS = -Wl,--hash-style=both 
CROSS_COMPILE = 
LIBCC = -lgcc
SHARED_LIBS =

The compiler is gcc 4.7.2 (installed the archlinux arm-elf-gcc-base package.)

If I remove the -Werror=pointer-sign flag, it builds, but I try not to just
ignore such things. Thoughts?


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

* Re: Compile error doing cross build on arm
  2013-07-08 15:58 Compile error doing cross build on arm Ian Denhardt
@ 2013-07-08 17:51 ` Harald Becker
  2013-07-08 18:35   ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Harald Becker @ 2013-07-08 17:51 UTC (permalink / raw)
  Cc: musl, ian

Hi Ian !

08-07-2013 11:58 Ian Denhardt <ian@zenhack.net>:

> So I just hit a compilation error trying to cross compile musl
> for arm:
> -fno-stack-protector  -c -o src/stdio/vfwprintf.o
> src/stdio/vfwprintf.c src/stdio/vfwprintf.c: In function
> 'wprintf_core': src/stdio/vfwprintf.c:195:3: error: pointer
> targets in passing argument 2 of 'wcsspn' differ in signedness
> [-Werror=pointer-sign] In file included from
> src/stdio/vfwprintf.c:7:0: ./include/wchar.h:62:8: note:
> expected 'const wchar_t *' but argument is of type 'int *' cc1:

> CFLAGS= -Os -pipe -fomit-frame-pointer -fno-unwind-tables
> -fno-asynchronous-unwind-tables -Wa,--noexecstack
> -falign-functions=1 -falign-labels=1 -falign-loops=1
> -falign-jumps=1 -Werror=implicit-function-declaration
> -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith
> -fno-stack-protector CFLAGS_C99FSE = -std=c99 -nostdinc
> -ffreestanding -fexcess-precision=standard -frounding-math

It is curious, but I had similar compile error on native ARM
compile (gcc 4.6.4). They vanished after removing some of the
option on my CFLAGS list. Didn't analyze this, but probable
candidates the unwind-tables and math options. So play a bit with
your CFLAGS list, try "CFLAGS=-Os" if problem vanishes.

--
Harald


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

* Re: Compile error doing cross build on arm
  2013-07-08 17:51 ` Harald Becker
@ 2013-07-08 18:35   ` Rich Felker
  2013-07-08 22:32     ` Ian Denhardt
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2013-07-08 18:35 UTC (permalink / raw)
  To: musl; +Cc: ian

On Mon, Jul 08, 2013 at 07:51:52PM +0200, Harald Becker wrote:
> Hi Ian !
> 
> 08-07-2013 11:58 Ian Denhardt <ian@zenhack.net>:
> 
> > So I just hit a compilation error trying to cross compile musl
> > for arm:
> > -fno-stack-protector  -c -o src/stdio/vfwprintf.o
> > src/stdio/vfwprintf.c src/stdio/vfwprintf.c: In function
> > 'wprintf_core': src/stdio/vfwprintf.c:195:3: error: pointer
> > targets in passing argument 2 of 'wcsspn' differ in signedness
> > [-Werror=pointer-sign] In file included from
> > src/stdio/vfwprintf.c:7:0: ./include/wchar.h:62:8: note:
> > expected 'const wchar_t *' but argument is of type 'int *' cc1:
> 
> > CFLAGS= -Os -pipe -fomit-frame-pointer -fno-unwind-tables
> > -fno-asynchronous-unwind-tables -Wa,--noexecstack
> > -falign-functions=1 -falign-labels=1 -falign-loops=1
> > -falign-jumps=1 -Werror=implicit-function-declaration
> > -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith
> > -fno-stack-protector CFLAGS_C99FSE = -std=c99 -nostdinc
> > -ffreestanding -fexcess-precision=standard -frounding-math
> 
> It is curious, but I had similar compile error on native ARM
> compile (gcc 4.6.4). They vanished after removing some of the
> option on my CFLAGS list. Didn't analyze this, but probable
> candidates the unwind-tables and math options. So play a bit with
> your CFLAGS list, try "CFLAGS=-Os" if problem vanishes.

The direct source of this error is that the compiler's wchar_t is
defined as int rather than unsigned. ARM EABI requires (stupidly) that
wchar_t be unsigned, so we follow that.

The indirect cause of the error, and the real problem, is almost
surely that the compiler was configured for old, pre-EABI ARM ABI.
This ABI is NOT supported by musl, and will lead to various major
problems that could otherwise go undetected for a long time, like
misaligned structures (the old ABI only had 4-byte alignment for
64-bit types, for example). So this issue needs to be checked and
fixed before moving ahead.

Rich


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

* Re: Compile error doing cross build on arm
  2013-07-08 18:35   ` Rich Felker
@ 2013-07-08 22:32     ` Ian Denhardt
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Denhardt @ 2013-07-08 22:32 UTC (permalink / raw)
  To: musl; +Cc: Rich Felker

> The indirect cause of the error, and the real problem, is almost
> surely that the compiler was configured for old, pre-EABI ARM ABI.
> This ABI is NOT supported by musl, and will lead to various major
> problems that could otherwise go undetected for a long time, like
> misaligned structures (the old ABI only had 4-byte alignment for
> 64-bit types, for example). So this issue needs to be checked and
> fixed before moving ahead.

Right you are, good catch. Works fine after swapping out the compiler.

Thanks,

-Ian


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

end of thread, other threads:[~2013-07-08 22:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-08 15:58 Compile error doing cross build on arm Ian Denhardt
2013-07-08 17:51 ` Harald Becker
2013-07-08 18:35   ` Rich Felker
2013-07-08 22:32     ` Ian Denhardt

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