From 1bbdab41d2e87a47aafd11471a74a6e02df67099 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 7 Oct 2018 21:29:45 +0200 Subject: [PATCH] all: improve compiler-rt compilation A few changes to make sure compiler-rt is correctly compiled (and doesn't include host headers, for example). This improves support for AVR, but it still doesn't work. Compiler-rt itself doesn't really work for AVR either. --- builtins.go | 2 +- src/runtime/runtime_arm.go | 8 ++++++++ targets/microbit.json | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/builtins.go b/builtins.go index 8c1817ed..58589de7 100644 --- a/builtins.go +++ b/builtins.go @@ -161,7 +161,7 @@ func loadBuiltins(target string) (path string, err error) { objpath := filepath.Join(dir, name+".o") objs = append(objs, objpath) srcpath := filepath.Join(builtinsDir, name+".c") - cmd := exec.Command(commands["clang"], "-c", "-Oz", "-g", "-Werror", "-Wall", "-std=c11", "--target="+target, "-o", objpath, srcpath) + cmd := exec.Command(commands["clang"], "-c", "-Oz", "-g", "-Werror", "-Wall", "-std=c11", "-fshort-enums", "-nostdlibinc", "--target="+target, "-o", objpath, srcpath) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Dir = dir diff --git a/src/runtime/runtime_arm.go b/src/runtime/runtime_arm.go index 1bc1a056..d47d40b8 100644 --- a/src/runtime/runtime_arm.go +++ b/src/runtime/runtime_arm.go @@ -53,3 +53,11 @@ func abort() { func align(ptr uintptr) uintptr { return (ptr + 3) &^ 3 } + +// Implement memset for compiler-rt. +//go:export memset +func memset(ptr unsafe.Pointer, c byte, size uintptr) { + for i := uintptr(0); i < size; i++ { + *(*byte)(unsafe.Pointer(uintptr(ptr) + i)) = c + } +} diff --git a/targets/microbit.json b/targets/microbit.json index 03bbe721..de932934 100644 --- a/targets/microbit.json +++ b/targets/microbit.json @@ -12,7 +12,6 @@ "-Wl,--gc-sections", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections", - "-fno-short-enums", "-Os", "-DNRF51", "-Ilib/CMSIS/CMSIS/Include",