From 0dcd5e9b5a098671dc86060fa4dcb59d56c8f830 Mon Sep 17 00:00:00 2001 From: Michael LeMay Date: Wed, 29 Jul 2015 07:28:13 -0700 Subject: [PATCH] x86: Revise CFLAGS and LDFLAGS for LLVM Clang compatibility This patch slightly revises CFLAGS and LDFLAGS to specify the optimization and debugging options and linker script in a way that is compatible with using Clang as the C compiler and to invoke the linker (i.e. CC = clang and LD = clang). --- cpu/x86/Makefile.x86_common | 6 +++++- cpu/x86/Makefile.x86_quarkX1000 | 2 +- platform/galileo/README.md | 13 +++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cpu/x86/Makefile.x86_common b/cpu/x86/Makefile.x86_common index 23095a493..12192db39 100644 --- a/cpu/x86/Makefile.x86_common +++ b/cpu/x86/Makefile.x86_common @@ -16,5 +16,9 @@ ifeq ($(BUILD_RELEASE),1) CFLAGS += -Os -fno-strict-aliasing LDFLAGS += -Wl,--strip-all else - CFLAGS += -Og -ggdb3 + ifeq ($(findstring clang,$(CC)),clang) + CFLAGS += -O0 -g + else + CFLAGS += -Og -ggdb3 + endif endif diff --git a/cpu/x86/Makefile.x86_quarkX1000 b/cpu/x86/Makefile.x86_quarkX1000 index cdc9dec52..4cbdc94b6 100644 --- a/cpu/x86/Makefile.x86_quarkX1000 +++ b/cpu/x86/Makefile.x86_quarkX1000 @@ -5,5 +5,5 @@ CONTIKI_CPU_DIRS += drivers/legacy_pc drivers/quarkX1000 init/legacy_pc CONTIKI_SOURCEFILES += bootstrap_quarkX1000.S rtc.c pit.c pic.c irq.c nmi.c pci.c uart-16x50.c uart.c CFLAGS += -m32 -march=i586 -mtune=i586 -LDFLAGS += -m32 -T $(CONTIKI)/cpu/x86/quarkX1000.ld +LDFLAGS += -m32 -Xlinker -T -Xlinker $(CONTIKI)/cpu/x86/quarkX1000.ld ASFLAGS += --32 -march=i586 -mtune=i586 diff --git a/platform/galileo/README.md b/platform/galileo/README.md index c108bd185..ba0c79670 100644 --- a/platform/galileo/README.md +++ b/platform/galileo/README.md @@ -48,9 +48,14 @@ command: $ ./platform/galileo/bsp/libc/build_newlib.sh ``` -Once newlib is built, you are ready to build applications. To build -applications for Galileo platform you should set TARGET variable to 'galileo'. -For instance, building the hello-world application should look like this: +Once newlib is built, you are ready to build applications. By default, the +following steps will use gcc as the C compiler and to invoke the linker. To +use LLVM clang instead, change the values for both the CC and LD variables in +cpu/x86/Makefile.x86_common to 'clang'. + +To build applications for the Galileo platform you should set the TARGET +variable to 'galileo'. For instance, building the hello-world application +should look like this: ``` $ cd examples/hello-world/ && make TARGET=galileo ``` @@ -125,7 +130,7 @@ $ multiboot /hello-world.galileo $ boot ``` -This should boot the Contiki image, resulted in the following messages being +This should boot the Contiki image, resulting in the following messages being sent to the serial console: ``` Starting Contiki