diff --git a/builder/builder_test.go b/builder/builder_test.go index cff43db88..c38d360af 100644 --- a/builder/builder_test.go +++ b/builder/builder_test.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "testing" "github.com/tinygo-org/tinygo/compileopts" @@ -60,7 +61,11 @@ func TestClangAttributes(t *testing.T) { {GOOS: "darwin", GOARCH: "arm64"}, {GOOS: "windows", GOARCH: "amd64"}, } { - t.Run("GOOS="+options.GOOS+",GOARCH="+options.GOARCH, func(t *testing.T) { + name := "GOOS=" + options.GOOS + ",GOARCH=" + options.GOARCH + if options.GOARCH == "arm" { + name += ",GOARM=" + options.GOARM + } + t.Run(name, func(t *testing.T) { testClangAttributes(t, options) }) } @@ -131,12 +136,12 @@ func testClangAttributes(t *testing.T, options *compileopts.Options) { t.Errorf("target has CPU %#v but Clang makes it CPU %#v", config.CPU(), cpu) } if features != config.Features() { - if llvm.Version != "11.0.0" { - // This needs to be removed once we switch to LLVM 12. - // LLVM 11.0.0 uses a different "target-features" string than LLVM - // 11.1.0 for Thumb targets. The Xtensa fork is still based on LLVM - // 11.0.0, so we need to skip this check on that version. - t.Errorf("target has LLVM features %#v but Clang makes it %#v", config.Features(), features) + if hasBuiltinTools || runtime.GOOS != "linux" { + // Skip this step when using an external Clang invocation on Linux. + // The reason is that Debian has patched Clang in a way that + // modifies the LLVM features string, changing lots of FPU/float + // related flags. We want to test vanilla Clang, not Debian Clang. + t.Errorf("target has LLVM features\n\t%#v\nbut Clang makes it\n\t%#v", config.Features(), features) } } } diff --git a/compileopts/target.go b/compileopts/target.go index 2e5f5487d..ba19cae08 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -262,7 +262,7 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) { case "armv6": spec.Features = "+armv6,+dsp,+fp64,+strict-align,+vfp2,+vfp2sp,-thumb-mode" case "armv7": - spec.Features = "+armv7-a,+dsp,+fp64,+vfp2,+vfp2sp,+vfp3d16,+vfp3d16sp,-thumb-mode" + spec.Features = "+armv7-a,+d32,+dsp,+fp64,+neon,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,-thumb-mode" } case "arm64": spec.CPU = "generic" diff --git a/targets/cortex-m0.json b/targets/cortex-m0.json index fe3568058..315d66582 100644 --- a/targets/cortex-m0.json +++ b/targets/cortex-m0.json @@ -2,5 +2,5 @@ "inherits": ["cortex-m"], "llvm-target": "thumbv6m-unknown-unknown-eabi", "cpu": "cortex-m0", - "features": "+armv6-m,+soft-float,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-d32,-dotprod,-dsp,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fp64,-fpregs,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-neon,-ras,-sb,-sha2,-vfp2,-vfp2sp,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" + "features": "+armv6-m,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-dotprod,-dsp,-fp16fml,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-ras,-sb,-sha2" } diff --git a/targets/cortex-m0plus.json b/targets/cortex-m0plus.json index a21d06ca7..6ac9b531e 100644 --- a/targets/cortex-m0plus.json +++ b/targets/cortex-m0plus.json @@ -2,5 +2,5 @@ "inherits": ["cortex-m"], "llvm-target": "thumbv6m-unknown-unknown-eabi", "cpu": "cortex-m0plus", - "features": "+armv6-m,+soft-float,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-d32,-dotprod,-dsp,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fp64,-fpregs,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-neon,-ras,-sb,-sha2,-vfp2,-vfp2sp,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" + "features": "+armv6-m,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-dotprod,-dsp,-fp16fml,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-ras,-sb,-sha2" } diff --git a/targets/cortex-m3.json b/targets/cortex-m3.json index 7b878d52e..07d88dfe6 100644 --- a/targets/cortex-m3.json +++ b/targets/cortex-m3.json @@ -2,5 +2,5 @@ "inherits": ["cortex-m"], "llvm-target": "thumbv7m-unknown-unknown-eabi", "cpu": "cortex-m3", - "features": "+armv7-m,+hwdiv,+soft-float,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-d32,-dotprod,-dsp,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fp64,-fpregs,-fullfp16,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-neon,-ras,-sb,-sha2,-vfp2,-vfp2sp,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" + "features": "+armv7-m,+hwdiv,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-dotprod,-dsp,-fp16fml,-fullfp16,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-ras,-sb,-sha2" } diff --git a/targets/gameboy-advance.json b/targets/gameboy-advance.json index 24e16cdad..2467b4b91 100644 --- a/targets/gameboy-advance.json +++ b/targets/gameboy-advance.json @@ -1,7 +1,7 @@ { "llvm-target": "armv4t-unknown-unknown-eabi", "cpu": "arm7tdmi", - "features": "+armv4t,+soft-float,+strict-align,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-d32,-dotprod,-dsp,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fp64,-fpregs,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-neon,-ras,-sb,-sha2,-thumb-mode,-vfp2,-vfp2sp,-vfp3,-vfp3d16,-vfp3d16sp,-vfp3sp,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp", + "features": "+armv4t,+strict-align,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-dotprod,-dsp,-fp16fml,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-ras,-sb,-sha2,-thumb-mode", "build-tags": ["gameboyadvance", "arm7tdmi", "baremetal", "linux", "arm"], "goos": "linux", "goarch": "arm",