diff options
author | Ayke van Laethem <[email protected]> | 2022-01-02 00:26:15 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-04-10 21:03:59 +0200 |
commit | 83227e68dff83ff1c9cfacaf5defa4d2385556b0 (patch) | |
tree | 8a35ab786a15641aa46bf4e2443243ddc765e319 | |
parent | 09a3c6a16b37a23f0f753b606bd32eabb842f012 (diff) | |
download | tinygo-83227e68dff83ff1c9cfacaf5defa4d2385556b0.tar.gz tinygo-83227e68dff83ff1c9cfacaf5defa4d2385556b0.zip |
all: use compiler-rt from LLVM
-rw-r--r-- | .circleci/config.yml | 5 | ||||
-rw-r--r-- | .github/workflows/build-macos.yml | 3 | ||||
-rw-r--r-- | .github/workflows/linux.yml | 6 | ||||
-rw-r--r-- | .github/workflows/windows.yml | 3 | ||||
-rw-r--r-- | .gitmodules | 4 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | builder/builtins.go | 15 | ||||
-rw-r--r-- | builder/library.go | 16 | ||||
-rw-r--r-- | builder/mingw-w64.go | 1 | ||||
-rw-r--r-- | builder/musl.go | 2 | ||||
-rw-r--r-- | builder/picolibc.go | 2 | ||||
m--------- | lib/compiler-rt | 0 |
12 files changed, 42 insertions, 21 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index 45989bd34..51768a800 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,15 +22,16 @@ commands: steps: - restore_cache: keys: - - llvm-source-13-v1 + - llvm-source-13-v3 - run: name: "Fetch LLVM source" command: make llvm-source - save_cache: - key: llvm-source-13-v1 + key: llvm-source-13-v3 paths: - llvm-project/clang/lib/Headers - llvm-project/clang/include + - llvm-project/compiler-rt - llvm-project/lld/include - llvm-project/llvm/include hack-ninja-jobs: diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 59dc7b855..d0ab2eee6 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -35,10 +35,11 @@ jobs: uses: actions/cache@v2 id: cache-llvm-source with: - key: llvm-source-13-macos-v1 + key: llvm-source-13-macos-v2 path: | llvm-project/clang/lib/Headers llvm-project/clang/include + llvm-project/compiler-rt llvm-project/lld/include llvm-project/llvm/include - name: Download LLVM source diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 20e45fc85..46c6a8d76 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -38,10 +38,11 @@ jobs: uses: actions/cache@v2 id: cache-llvm-source with: - key: llvm-source-13-linux-v1 + key: llvm-source-13-linux-v2 path: | llvm-project/clang/lib/Headers llvm-project/clang/include + llvm-project/compiler-rt llvm-project/lld/include llvm-project/llvm/include - name: Download LLVM source @@ -179,10 +180,11 @@ jobs: uses: actions/cache@v2 id: cache-llvm-source with: - key: llvm-source-13-linux-asserts-v1 + key: llvm-source-13-linux-asserts-v2 path: | llvm-project/clang/lib/Headers llvm-project/clang/include + llvm-project/compiler-rt llvm-project/lld/include llvm-project/llvm/include - name: Download LLVM source diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c06f8b2fe..47c00dc0b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -35,10 +35,11 @@ jobs: uses: actions/cache@v2 id: cache-llvm-source with: - key: llvm-source-13-windows-v1 + key: llvm-source-13-windows-v2 path: | llvm-project/clang/lib/Headers llvm-project/clang/include + llvm-project/compiler-rt llvm-project/lld/include llvm-project/llvm/include - name: Download LLVM source diff --git a/.gitmodules b/.gitmodules index e82a938b7..35e6870c0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,10 +10,6 @@ [submodule "lib/cmsis-svd"] path = lib/cmsis-svd url = https://github.com/tinygo-org/cmsis-svd -[submodule "lib/compiler-rt"] - path = lib/compiler-rt - url = https://github.com/llvm-mirror/compiler-rt.git - branch = release_80 [submodule "lib/wasi-libc"] path = lib/wasi-libc url = https://github.com/CraneStation/wasi-libc @@ -619,7 +619,6 @@ build/release: tinygo gen-device wasi-libc $(if $(filter 1,$(USE_SYSTEM_BINARYEN @mkdir -p build/release/tinygo/bin @mkdir -p build/release/tinygo/lib/clang/include @mkdir -p build/release/tinygo/lib/CMSIS/CMSIS - @mkdir -p build/release/tinygo/lib/compiler-rt/lib @mkdir -p build/release/tinygo/lib/macos-minimal-sdk @mkdir -p build/release/tinygo/lib/mingw-w64/mingw-w64-crt/lib-common @mkdir -p build/release/tinygo/lib/mingw-w64/mingw-w64-headers/defaults @@ -641,9 +640,6 @@ endif @cp -p $(abspath $(CLANG_SRC))/lib/Headers/*.h build/release/tinygo/lib/clang/include @cp -rp lib/CMSIS/CMSIS/Include build/release/tinygo/lib/CMSIS/CMSIS @cp -rp lib/CMSIS/README.md build/release/tinygo/lib/CMSIS - @cp -rp lib/compiler-rt/lib/builtins build/release/tinygo/lib/compiler-rt/lib - @cp -rp lib/compiler-rt/LICENSE.TXT build/release/tinygo/lib/compiler-rt - @cp -rp lib/compiler-rt/README.txt build/release/tinygo/lib/compiler-rt @cp -rp lib/macos-minimal-sdk/* build/release/tinygo/lib/macos-minimal-sdk @cp -rp lib/musl/arch/aarch64 build/release/tinygo/lib/musl/arch @cp -rp lib/musl/arch/arm build/release/tinygo/lib/musl/arch @@ -680,6 +676,8 @@ endif @cp -rp lib/picolibc/newlib/libm/common build/release/tinygo/lib/picolibc/newlib/libm @cp -rp lib/picolibc-stdio.c build/release/tinygo/lib @cp -rp lib/wasi-libc/sysroot build/release/tinygo/lib/wasi-libc/sysroot + @cp -rp llvm-project/compiler-rt/lib/builtins build/release/tinygo/lib/compiler-rt-builtins + @cp -rp llvm-project/compiler-rt/LICENSE.TXT build/release/tinygo/lib/compiler-rt-builtins @cp -rp src build/release/tinygo/src @cp -rp targets build/release/tinygo/targets ./build/tinygo build-library -target=cortex-m0 -o build/release/tinygo/pkg/thumbv6m-unknown-unknown-eabi-cortex-m0/compiler-rt compiler-rt diff --git a/builder/builtins.go b/builder/builtins.go index 76ef3975c..479b541d5 100644 --- a/builder/builtins.go +++ b/builder/builtins.go @@ -1,7 +1,11 @@ package builder import ( + "os" + "path/filepath" "strings" + + "github.com/tinygo-org/tinygo/goenv" ) // These are the GENERIC_SOURCES according to CMakeList.txt. @@ -72,6 +76,7 @@ var genericBuiltins = []string{ "floatunsisf.c", "floatuntidf.c", "floatuntisf.c", + "fp_mode.c", //"int_util.c", "lshrdi3.c", "lshrti3.c", @@ -161,7 +166,15 @@ var CompilerRT = Library{ cflags: func(target, headerPath string) []string { return []string{"-Werror", "-Wall", "-std=c11", "-nostdlibinc"} }, - sourceDir: "lib/compiler-rt/lib/builtins", + sourceDir: func() string { + llvmDir := filepath.Join(goenv.Get("TINYGOROOT"), "llvm-project/compiler-rt/lib/builtins") + if _, err := os.Stat(llvmDir); err == nil { + // Release build. + return llvmDir + } + // Development build. + return filepath.Join(goenv.Get("TINYGOROOT"), "lib/compiler-rt-builtins") + }, librarySources: func(target string) []string { builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") { diff --git a/builder/library.go b/builder/library.go index c3704a1e5..56d75c17c 100644 --- a/builder/library.go +++ b/builder/library.go @@ -24,8 +24,8 @@ type Library struct { // cflags returns the C flags specific to this library cflags func(target, headerPath string) []string - // The source directory, relative to TINYGOROOT. - sourceDir string + // The source directory. + sourceDir func() string // The source files, relative to sourceDir. librarySources func(target string) []string @@ -161,6 +161,12 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ if strings.HasPrefix(target, "riscv64-") { args = append(args, "-march=rv64gc", "-mabi=lp64") } + if strings.HasPrefix(target, "xtensa") { + // Hack to work around an issue in the Xtensa port: + // https://github.com/espressif/llvm-project/issues/52 + // Hopefully this will be fixed soon (LLVM 14). + args = append(args, "-D__ELF__") + } var once sync.Once @@ -195,6 +201,8 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ }, } + sourceDir := l.sourceDir() + // Create jobs to compile all sources. These jobs are depended upon by the // archive job above, so must be run first. for _, path := range l.librarySources(target) { @@ -203,7 +211,7 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ for strings.HasPrefix(cleanpath, "../") { cleanpath = cleanpath[3:] } - srcpath := filepath.Join(goenv.Get("TINYGOROOT"), l.sourceDir, path) + srcpath := filepath.Join(sourceDir, path) objpath := filepath.Join(dir, cleanpath+".o") os.MkdirAll(filepath.Dir(objpath), 0o777) objs = append(objs, objpath) @@ -227,7 +235,7 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ // (It could be done in parallel with creating the ar file, but it probably // won't make much of a difference in speed). if l.crt1Source != "" { - srcpath := filepath.Join(goenv.Get("TINYGOROOT"), l.sourceDir, l.crt1Source) + srcpath := filepath.Join(sourceDir, l.crt1Source) job.dependencies = append(job.dependencies, &compileJob{ description: "compile " + srcpath, run: func(*compileJob) error { diff --git a/builder/mingw-w64.go b/builder/mingw-w64.go index bdab730fa..135cae945 100644 --- a/builder/mingw-w64.go +++ b/builder/mingw-w64.go @@ -26,6 +26,7 @@ var MinGW = Library{ _, err = io.Copy(outf, inf) return err }, + sourceDir: func() string { return "" }, // unused cflags: func(target, headerPath string) []string { // No flags necessary because there are no files to compile. return nil diff --git a/builder/musl.go b/builder/musl.go index 46ce92ee3..fa29496a8 100644 --- a/builder/musl.go +++ b/builder/musl.go @@ -104,7 +104,7 @@ var Musl = Library{ "-fno-stack-protector", } }, - sourceDir: "lib/musl/src", + sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/musl/src") }, librarySources: func(target string) []string { arch := compileopts.MuslArchitecture(target) globs := []string{ diff --git a/builder/picolibc.go b/builder/picolibc.go index af34f7efa..f1b061ae5 100644 --- a/builder/picolibc.go +++ b/builder/picolibc.go @@ -33,7 +33,7 @@ var Picolibc = Library{ "-I" + headerPath, } }, - sourceDir: "lib/picolibc/newlib/libc", + sourceDir: func() string { return filepath.Join(goenv.Get("TINYGOROOT"), "lib/picolibc/newlib/libc") }, librarySources: func(target string) []string { return picolibcSources }, diff --git a/lib/compiler-rt b/lib/compiler-rt deleted file mode 160000 -Subproject 5bc79797e1f9184f39e1bd30fac75d995b72cea |