]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'master' of git://git.denx.de/u-boot-arm
authorStefano Babic <sbabic@denx.de>
Tue, 16 Sep 2014 14:30:11 +0000 (16:30 +0200)
committerStefano Babic <sbabic@denx.de>
Tue, 16 Sep 2014 14:30:11 +0000 (16:30 +0200)
Kbuild
Makefile
arch/arm/include/asm/global_data.h
arch/arm/lib/eabi_compat.c
arch/arm/lib/spl.c
arch/arm/lib/vectors.S
common/board_r.c
doc/README.clang [new file with mode: 0644]
include/linux/kbuild.h
scripts/Kbuild.include

diff --git a/Kbuild b/Kbuild
index 6e1698c5bf63aba67cf8bb6a02dfd23432f94c57..ef97787bf45945ee22803325a641d13b9c4468d9 100644 (file)
--- a/Kbuild
+++ b/Kbuild
@@ -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;}"
index fdda3ec0535bea0f5069d98f3b03a695d2661af4..42263e4de28cf86d1a01d665fb9b5ea666650ecf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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
 
index 63e4ad5a6744bd777b0d66ec390fca22c97e3fcf..c69d0646f58099caf2e9f664bcaf0ce4cc30fe7e 100644 (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 */
index 10d19333fc1306bb87daac5c867a7f84e2927ee7..a2cb06e49ae0248c2287a4a5538dccfad6e54674 100644 (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);
+}
index dfcc596815432b4357114f6aef01b11a66596e04..75ab546923f298f4238b784684e120a146002d75 100644 (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);
 }
 
index 493f3373f3cd7ed61ff0df45fba8e77ed71e7a54..0cb87cee7f611ddb250b0ced65c5c816db0cc930 100644 (file)
  *************************************************************************
  */
 
+_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
index f9647e13583f262a0fd78a389405027bc2108adb..551429c8431fe5a0ab0d322b0e68872a3e0d7963 100644 (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
 
diff --git a/doc/README.clang b/doc/README.clang
new file mode 100644 (file)
index 0000000..9ad689f
--- /dev/null
@@ -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 "$@"
+
index ab7805a3b44330931a4be453f85cc86597590753..8a9f645e429712c25e83e2c8989bed4dda24eada 100644 (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
index c664e39be6a6a193ca9b6448c6c01e28b18099b8..4c333599c1fe19e1775d6f5a51d88b7e87c65262 100644 (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