main: add aeabi builtins to arm targets
Some builtins require these __aeabi_* functions.
Этот коммит содержится в:
родитель
e50c6f1af1
коммит
96f07243a4
1 изменённых файлов: 164 добавлений и 130 удалений
294
builtins.go
294
builtins.go
|
@ -5,133 +5,162 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These are the GENERIC_SOURCES according to CMakeList.txt.
|
// These are the GENERIC_SOURCES according to CMakeList.txt.
|
||||||
var genericBuiltins = []string{
|
var genericBuiltins = []string{
|
||||||
"absvdi2",
|
"absvdi2.c",
|
||||||
"absvsi2",
|
"absvsi2.c",
|
||||||
"absvti2",
|
"absvti2.c",
|
||||||
"adddf3",
|
"adddf3.c",
|
||||||
"addsf3",
|
"addsf3.c",
|
||||||
"addtf3",
|
"addtf3.c",
|
||||||
"addvdi3",
|
"addvdi3.c",
|
||||||
"addvsi3",
|
"addvsi3.c",
|
||||||
"addvti3",
|
"addvti3.c",
|
||||||
"apple_versioning",
|
"apple_versioning.c",
|
||||||
"ashldi3",
|
"ashldi3.c",
|
||||||
"ashlti3",
|
"ashlti3.c",
|
||||||
"ashrdi3",
|
"ashrdi3.c",
|
||||||
"ashrti3",
|
"ashrti3.c",
|
||||||
"bswapdi2",
|
"bswapdi2.c",
|
||||||
"bswapsi2",
|
"bswapsi2.c",
|
||||||
"clzdi2",
|
"clzdi2.c",
|
||||||
"clzsi2",
|
"clzsi2.c",
|
||||||
"clzti2",
|
"clzti2.c",
|
||||||
"cmpdi2",
|
"cmpdi2.c",
|
||||||
"cmpti2",
|
"cmpti2.c",
|
||||||
"comparedf2",
|
"comparedf2.c",
|
||||||
"comparesf2",
|
"comparesf2.c",
|
||||||
"ctzdi2",
|
"ctzdi2.c",
|
||||||
"ctzsi2",
|
"ctzsi2.c",
|
||||||
"ctzti2",
|
"ctzti2.c",
|
||||||
"divdc3",
|
"divdc3.c",
|
||||||
"divdf3",
|
"divdf3.c",
|
||||||
"divdi3",
|
"divdi3.c",
|
||||||
"divmoddi4",
|
"divmoddi4.c",
|
||||||
"divmodsi4",
|
"divmodsi4.c",
|
||||||
"divsc3",
|
"divsc3.c",
|
||||||
"divsf3",
|
"divsf3.c",
|
||||||
"divsi3",
|
"divsi3.c",
|
||||||
"divtc3",
|
"divtc3.c",
|
||||||
"divti3",
|
"divti3.c",
|
||||||
"divtf3",
|
"divtf3.c",
|
||||||
"extendsfdf2",
|
"extendsfdf2.c",
|
||||||
"extendhfsf2",
|
"extendhfsf2.c",
|
||||||
"ffsdi2",
|
"ffsdi2.c",
|
||||||
"ffssi2",
|
"ffssi2.c",
|
||||||
"ffsti2",
|
"ffsti2.c",
|
||||||
"fixdfdi",
|
"fixdfdi.c",
|
||||||
"fixdfsi",
|
"fixdfsi.c",
|
||||||
"fixdfti",
|
"fixdfti.c",
|
||||||
"fixsfdi",
|
"fixsfdi.c",
|
||||||
"fixsfsi",
|
"fixsfsi.c",
|
||||||
"fixsfti",
|
"fixsfti.c",
|
||||||
"fixunsdfdi",
|
"fixunsdfdi.c",
|
||||||
"fixunsdfsi",
|
"fixunsdfsi.c",
|
||||||
"fixunsdfti",
|
"fixunsdfti.c",
|
||||||
"fixunssfdi",
|
"fixunssfdi.c",
|
||||||
"fixunssfsi",
|
"fixunssfsi.c",
|
||||||
"fixunssfti",
|
"fixunssfti.c",
|
||||||
"floatdidf",
|
"floatdidf.c",
|
||||||
"floatdisf",
|
"floatdisf.c",
|
||||||
"floatsidf",
|
"floatsidf.c",
|
||||||
"floatsisf",
|
"floatsisf.c",
|
||||||
"floattidf",
|
"floattidf.c",
|
||||||
"floattisf",
|
"floattisf.c",
|
||||||
"floatundidf",
|
"floatundidf.c",
|
||||||
"floatundisf",
|
"floatundisf.c",
|
||||||
"floatunsidf",
|
"floatunsidf.c",
|
||||||
"floatunsisf",
|
"floatunsisf.c",
|
||||||
"floatuntidf",
|
"floatuntidf.c",
|
||||||
"floatuntisf",
|
"floatuntisf.c",
|
||||||
//"int_util",
|
//"int_util.c",
|
||||||
"lshrdi3",
|
"lshrdi3.c",
|
||||||
"lshrti3",
|
"lshrti3.c",
|
||||||
"moddi3",
|
"moddi3.c",
|
||||||
"modsi3",
|
"modsi3.c",
|
||||||
"modti3",
|
"modti3.c",
|
||||||
"muldc3",
|
"muldc3.c",
|
||||||
"muldf3",
|
"muldf3.c",
|
||||||
"muldi3",
|
"muldi3.c",
|
||||||
"mulodi4",
|
"mulodi4.c",
|
||||||
"mulosi4",
|
"mulosi4.c",
|
||||||
"muloti4",
|
"muloti4.c",
|
||||||
"mulsc3",
|
"mulsc3.c",
|
||||||
"mulsf3",
|
"mulsf3.c",
|
||||||
"multi3",
|
"multi3.c",
|
||||||
"multf3",
|
"multf3.c",
|
||||||
"mulvdi3",
|
"mulvdi3.c",
|
||||||
"mulvsi3",
|
"mulvsi3.c",
|
||||||
"mulvti3",
|
"mulvti3.c",
|
||||||
"negdf2",
|
"negdf2.c",
|
||||||
"negdi2",
|
"negdi2.c",
|
||||||
"negsf2",
|
"negsf2.c",
|
||||||
"negti2",
|
"negti2.c",
|
||||||
"negvdi2",
|
"negvdi2.c",
|
||||||
"negvsi2",
|
"negvsi2.c",
|
||||||
"negvti2",
|
"negvti2.c",
|
||||||
"os_version_check",
|
"os_version_check.c",
|
||||||
"paritydi2",
|
"paritydi2.c",
|
||||||
"paritysi2",
|
"paritysi2.c",
|
||||||
"parityti2",
|
"parityti2.c",
|
||||||
"popcountdi2",
|
"popcountdi2.c",
|
||||||
"popcountsi2",
|
"popcountsi2.c",
|
||||||
"popcountti2",
|
"popcountti2.c",
|
||||||
"powidf2",
|
"powidf2.c",
|
||||||
"powisf2",
|
"powisf2.c",
|
||||||
"powitf2",
|
"powitf2.c",
|
||||||
"subdf3",
|
"subdf3.c",
|
||||||
"subsf3",
|
"subsf3.c",
|
||||||
"subvdi3",
|
"subvdi3.c",
|
||||||
"subvsi3",
|
"subvsi3.c",
|
||||||
"subvti3",
|
"subvti3.c",
|
||||||
"subtf3",
|
"subtf3.c",
|
||||||
"trampoline_setup",
|
"trampoline_setup.c",
|
||||||
"truncdfhf2",
|
"truncdfhf2.c",
|
||||||
"truncdfsf2",
|
"truncdfsf2.c",
|
||||||
"truncsfhf2",
|
"truncsfhf2.c",
|
||||||
"ucmpdi2",
|
"ucmpdi2.c",
|
||||||
"ucmpti2",
|
"ucmpti2.c",
|
||||||
"udivdi3",
|
"udivdi3.c",
|
||||||
"udivmoddi4",
|
"udivmoddi4.c",
|
||||||
"udivmodsi4",
|
"udivmodsi4.c",
|
||||||
"udivmodti4",
|
"udivmodti4.c",
|
||||||
"udivsi3",
|
"udivsi3.c",
|
||||||
"udivti3",
|
"udivti3.c",
|
||||||
"umoddi3",
|
"umoddi3.c",
|
||||||
"umodsi3",
|
"umodsi3.c",
|
||||||
"umodti3",
|
"umodti3.c",
|
||||||
|
}
|
||||||
|
|
||||||
|
var aeabiBuiltins = []string{
|
||||||
|
"arm/aeabi_cdcmp.S",
|
||||||
|
"arm/aeabi_cdcmpeq_check_nan.c",
|
||||||
|
"arm/aeabi_cfcmp.S",
|
||||||
|
"arm/aeabi_cfcmpeq_check_nan.c",
|
||||||
|
"arm/aeabi_dcmp.S",
|
||||||
|
"arm/aeabi_div0.c",
|
||||||
|
"arm/aeabi_drsub.c",
|
||||||
|
"arm/aeabi_fcmp.S",
|
||||||
|
"arm/aeabi_frsub.c",
|
||||||
|
"arm/aeabi_idivmod.S",
|
||||||
|
"arm/aeabi_ldivmod.S",
|
||||||
|
"arm/aeabi_memcmp.S",
|
||||||
|
"arm/aeabi_memcpy.S",
|
||||||
|
"arm/aeabi_memmove.S",
|
||||||
|
"arm/aeabi_memset.S",
|
||||||
|
"arm/aeabi_uidivmod.S",
|
||||||
|
"arm/aeabi_uldivmod.S",
|
||||||
|
}
|
||||||
|
|
||||||
|
func builtinFiles(target string) []string {
|
||||||
|
builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins
|
||||||
|
if target[:3] == "arm" {
|
||||||
|
builtins = append(builtins, aeabiBuiltins...)
|
||||||
|
}
|
||||||
|
return builtins
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the builtins archive, possibly generating it as needed.
|
// Get the builtins archive, possibly generating it as needed.
|
||||||
|
@ -139,9 +168,10 @@ func loadBuiltins(target string) (path string, err error) {
|
||||||
outfile := "librt-" + target + ".a"
|
outfile := "librt-" + target + ".a"
|
||||||
builtinsDir := filepath.Join(sourceDir(), "lib", "compiler-rt", "lib", "builtins")
|
builtinsDir := filepath.Join(sourceDir(), "lib", "compiler-rt", "lib", "builtins")
|
||||||
|
|
||||||
srcs := make([]string, len(genericBuiltins))
|
builtins := builtinFiles(target)
|
||||||
for i, name := range genericBuiltins {
|
srcs := make([]string, len(builtins))
|
||||||
srcs[i] = filepath.Join(builtinsDir, name+".c")
|
for i, name := range builtins {
|
||||||
|
srcs[i] = filepath.Join(builtinsDir, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if path, err := cacheLoad(outfile, commands["clang"], srcs); path != "" || err != nil {
|
if path, err := cacheLoad(outfile, commands["clang"], srcs); path != "" || err != nil {
|
||||||
|
@ -156,11 +186,15 @@ func loadBuiltins(target string) (path string, err error) {
|
||||||
|
|
||||||
// Compile all builtins.
|
// Compile all builtins.
|
||||||
// TODO: use builtins optimized for a given target if available.
|
// TODO: use builtins optimized for a given target if available.
|
||||||
objs := make([]string, 0, len(genericBuiltins))
|
objs := make([]string, 0, len(builtins))
|
||||||
for _, name := range genericBuiltins {
|
for _, name := range builtins {
|
||||||
objpath := filepath.Join(dir, name+".o")
|
objname := name
|
||||||
|
if strings.LastIndexByte(objname, '/') >= 0 {
|
||||||
|
objname = objname[strings.LastIndexByte(objname, '/'):]
|
||||||
|
}
|
||||||
|
objpath := filepath.Join(dir, objname+".o")
|
||||||
objs = append(objs, objpath)
|
objs = append(objs, objpath)
|
||||||
srcpath := filepath.Join(builtinsDir, name+".c")
|
srcpath := filepath.Join(builtinsDir, name)
|
||||||
cmd := exec.Command(commands["clang"], "-c", "-Oz", "-g", "-Werror", "-Wall", "-std=c11", "-fshort-enums", "-nostdlibinc", "--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.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче