aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-06-03 17:32:10 +0200
committerAyke van Laethem <[email protected]>2018-06-03 17:38:16 +0200
commit588910792d7fd701f573d5f487b50a108430cbc6 (patch)
treea6aba4456bd4f407cfebaa83325d53beed505bcf /Makefile
parenta9bbed2f6ca1b7d8365262a3e13da34e817f4635 (diff)
downloadtinygo-588910792d7fd701f573d5f487b50a108430cbc6.tar.gz
tinygo-588910792d7fd701f573d5f487b50a108430cbc6.zip
Translate bootstrapping main from C to LLVM IR
This avoids needing a C compiler for every platform.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile30
1 files changed, 20 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 7fa1c332b..1120719c5 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@ tgo: build/tgo
LLVM := $(shell go env GOPATH)/src/llvm.org/llvm/bindings/go/llvm/workdir/llvm_build/bin/
LINK = $(LLVM)llvm-link
LLC = $(LLVM)llc
+LLAS = $(LLVM)llvm-as
CFLAGS = -Wall -Werror -Os -g -fno-exceptions -flto -ffunction-sections -fdata-sections $(LLFLAGS)
@@ -16,7 +17,14 @@ RUNTIME_PARTS = build/runtime.bc
TARGET ?= unix
-ifeq ($(TARGET),pca10040)
+ifeq ($(TARGET),unix)
+# Regular *nix system.
+GCC = gcc
+LD = clang
+SIZE = size
+
+else ifeq ($(TARGET),pca10040)
+# PCA10040: nRF52832 development board
GCC = arm-none-eabi-gcc
LD = arm-none-eabi-ld -T arm.ld --gc-sections
SIZE = arm-none-eabi-size
@@ -30,14 +38,12 @@ CFLAGS += -I$(CURDIR)/lib/CMSIS/CMSIS/Include
CFLAGS += -DNRF52832_XXAA
CFLAGS += -Wno-uninitialized
RUNTIME_PARTS += build/runtime_nrf.bc
-RUNTIME_PARTS += build/system_nrf52.bc
-OBJ += build/startup_nrf51.o # TODO nrf52, see https://bugs.llvm.org/show_bug.cgi?id=31601
+RUNTIME_PARTS += build/nrfx_system_nrf52.bc
+OBJ += build/nrfx_startup_nrf51.o # TODO nrf52, see https://bugs.llvm.org/show_bug.cgi?id=31601
+
+else
+$(error Unknown target)
-else ifeq ($(TARGET),unix)
-# Regular *nix system.
-GCC = gcc
-LD = clang
-SIZE = size
endif
@@ -75,13 +81,17 @@ build/%.bc: src/runtime/%.c src/runtime/*.h
@mkdir -p build
clang $(CFLAGS) -c -o $@ $<
+# Compile LLVM bitcode from LLVM source.
+build/%.bc: src/runtime/%.ll
+ $(LLAS) -o $@ $<
+
# Compile system_* file for the nRF.
-build/%.bc: lib/nrfx/mdk/%.c
+build/nrfx_%.bc: lib/nrfx/mdk/%.c
@mkdir -p build
clang $(CFLAGS) -c -o $@ $^
# Compile startup_* file for the nRF.
-build/%.o: lib/nrfx/mdk/gcc_%.S
+build/nrfx_%.o: lib/nrfx/mdk/gcc_%.S
@mkdir -p build
clang $(CFLAGS) -c -o $@ $^