Re: cross compile dietlibc (on x86_64 for arm)

Felix von Leitner <[email protected]> Wed, 24 Jan 2018 10:21:31 +0100
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
> I'm trying to cross compile dietlibc for arm:

> # make ARCH=arm CROSS="arm-cortexa15-linux-gnueabihf-" EXTRACFLAGS="-O2 -Wall -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 -mabi=aapcs-linux -mtune=cortex-a15 -fno-stack-protector -std=gnu99" all
> ...
> ...
> bin-x86_64/diet arm-cortexa15-linux-gnueabihf-gcc -D__dietlibc__ -pipe -nostdinc -D_REENTRANT -O2 -Wall -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 -mabi=aapcs-linux -mtune=cortex-a15 -fno-stack-protector -std=gnu99 -O2 -fomit-frame-pointer -fstrict-aliasing -O0 -g -Wall -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 -mabi=aapcs-linux -mtune=cortex-a15 -fno-stack-protector -std=gnu99 -W -Wall -Wextra -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wno-unused -Wredundant-decls -Wshadow -o bin-arm/elftrunc contrib/elftrunc.c
> make[4]: bin-x86_64/diet: Command not found
> make[4]: *** [Makefile:352: bin-arm/elftrunc] Error 127

> The failing make target is in the root Makefile:

> ...
> $(OBJDIR)/elftrunc: $(OBJDIR)/diet contrib/elftrunc.c
> 	bin-$(MYARCH)/diet $(CCC) $(CFLAGS) -o $@ contrib/elftrunc.c
> ...

> here $(OBJDIR)/elftrunc depends on $(OBJDIR)/diet but in the recipe bin-$(MYARCH)/diet
> is used.

> Do I have to build the dietlibc src tree natively first and then cross ?

Yes and no.
At this point the library itself has already been built.
So you can start cross-compiling dietlibc binaries with it.

However, for convenience, you'd probably want to use the diet binary for
that, which you'd need in a version for the build host architecture to
run it. So I recommend building a native dietlibc, too, so you can use
its diet wrapper program.

Regards,

Felix