Merge branch 'master' of git://git.denx.de/u-boot-arm

This commit is contained in:
Stefano Babic 2014-09-16 16:30:11 +02:00
commit d4940fc521
10 changed files with 107 additions and 17 deletions

3
Kbuild
View File

@ -53,7 +53,8 @@ targets += arch/$(ARCH)/lib/asm-offsets.s
# Default sed regexp - multiline due to syntax constraints
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
"s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \
/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"

View File

@ -197,8 +197,8 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
HOSTCC = gcc
HOSTCXX = g++
HOSTCC = cc
HOSTCXX = c++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2

View File

@ -44,10 +44,35 @@ struct arch_global_data {
#include <asm-generic/global_data.h>
#ifdef __clang__
#define DECLARE_GLOBAL_DATA_PTR
#define gd get_gd()
static inline gd_t *get_gd(void)
{
gd_t *gd_ptr;
#ifdef CONFIG_ARM64
/*
* Make will already error that reserving x18 is not supported at the
* time of writing, clang: error: unknown argument: '-ffixed-x18'
*/
__asm__ volatile("mov %0, x18\n" : "=r" (gd_ptr));
#else
__asm__ volatile("mov %0, r9\n" : "=r" (gd_ptr));
#endif
return gd_ptr;
}
#else
#ifdef CONFIG_ARM64
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("x18")
#else
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r9")
#endif
#endif
#endif /* __ASM_GBL_DATA_H */

View File

@ -20,8 +20,19 @@ int raise (int signum)
/* Dummy function to avoid linker complaints */
void __aeabi_unwind_cpp_pr0(void)
{
};
}
void __aeabi_unwind_cpp_pr1(void)
{
};
}
/* Copy memory like memcpy, but no return value required. */
void __aeabi_memcpy(void *dest, const void *src, size_t n)
{
(void) memcpy(dest, src, n);
}
void __aeabi_memset(void *dest, size_t n, int c)
{
(void) memset(dest, c, n);
}

View File

@ -28,9 +28,6 @@ void __weak board_init_f(ulong dummy)
/* Clear the BSS. */
memset(__bss_start, 0, __bss_end - __bss_start);
/* Set global data pointer. */
gd = &gdata;
board_init_r(NULL, 0);
}

View File

@ -45,12 +45,13 @@
*************************************************************************
*/
_start:
#ifdef CONFIG_SYS_DV_NOR_BOOT_CFG
.word CONFIG_SYS_DV_NOR_BOOT_CFG
#endif
_start:
ldr pc, _reset
b reset
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
@ -77,7 +78,6 @@ _start:
.globl _irq
.globl _fiq
_reset: .word reset
_undefined_instruction: .word undefined_instruction
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort

View File

@ -912,7 +912,7 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
int i;
#endif
#ifndef CONFIG_X86
#if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
gd = new_gd;
#endif

56
doc/README.clang Normal file
View File

@ -0,0 +1,56 @@
The biggest problem when trying to compile U-boot with clang is that
almost all archs rely on storing gd in a global register and clang user
manual states: "clang does not support global register variables; this
is unlikely to be implemented soon because it requires additional LLVM
backend support."
Since version 3.4 the ARM backend can be instructed to leave r9 alone.
Global registers themselves are not supported so some inline assembly is
used to get its value. This does lead to larger code then strictly
necessary, but at least works.
NOTE: target compilation only work for _some_ ARM boards at the moment.
Also Aarch64 is not supported: Most notably boards which aren't using
the generic board will fail to compile, but since those are expected
to be converted this will solve itself. Boards which reassign gd in c
will also fail to compile, but there is in no strict reason to do so
in the ARM world, since crt0.S takes care of this. These assignments
can be avoided by changing the init calls but this is not in mainline yet.
NOTE: without the -mllvm -arm-use-movt=0 flags u-boot will compile
fine, but llvm might hardcode addresses in movw / movt pairs, which
cannot be relocated and u-boot will fail at runtime.
Debian (based)
--------------
Binary packages can be installed as usual, e.g.:
sudo apt-get install clang
To compile U-Boot with clang on linux without IAS use e.g.:
export TRIPLET=arm-linux-gnueabi && export CROSS_COMPILE="$TRIPLET-"
make HOSTCC=clang CC="clang -target $TRIPLET -mllvm -arm-use-movt=0 -no-integrated-as" rpi_b_defconfig
make HOSTCC=clang CC="clang -target $TRIPLET -mllvm -arm-use-movt=0 -no-integrated-as" all V=1 -j8
FreeBSD 11 (Current):
--------------------
Since llvm 3.4 is currently in the base system, the integrated as is
incapable of building U-Boot. Therefore gas from devel/arm-eabi-binutils
is used instead. It needs a symlinks to be picked up correctly though:
ln -s /usr/local/bin/arm-eabi-as /usr/bin/arm-freebsd-eabi-as
# The following commands compile U-Boot using the clang xdev toolchain.
# NOTE: CROSS_COMPILE and target differ on purpose!
export CROSS_COMPILE=arm-eabi-
gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd -no-integrated-as -mllvm -arm-use-movt=0" rpi_b_defconfig
gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd -no-integrated-as -mllvm -arm-use-movt=0" -j8
Given that u-boot will default to gcc, above commands can be
simplified with a simple wrapper script, listed below.
/usr/local/bin/arm-eabi-gcc
---
#!/bin/sh
exec clang -target arm-freebsd-eabi --sysroot /usr/arm-freebsd -no-integrated-as -mllvm -arm-use-movt=0 "$@"

View File

@ -7,14 +7,14 @@
#define __LINUX_KBUILD_H
#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
#define BLANK() asm volatile("\n->" : : )
#define BLANK() asm volatile("\n.ascii \"->\"" : : )
#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))
#define COMMENT(x) \
asm volatile("\n->#" x)
asm volatile("\n.ascii \"->#" x "\"")
#endif

View File

@ -113,12 +113,12 @@ as-instr = $(call try-run,\
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
cc-option = $(call try-run,\
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
# cc-option-yn
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
cc-option-yn = $(call try-run,\
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
# cc-option-align
# Prefix align with either -falign or -malign