@@ -480,6 +480,14 @@ func main() {
480480 }
481481 }
482482
483+ if len (os .Args ) > 1 && os .Args [1 ] == "-check-goarm" {
484+ useVFPv1 () // might fail with SIGILL
485+ println ("VFPv1 OK." )
486+ useVFPv3 () // might fail with SIGILL
487+ println ("VFPv3 OK." )
488+ os .Exit (0 )
489+ }
490+
483491 xinit ()
484492 xmain ()
485493 xexit (0 )
@@ -515,40 +523,21 @@ func xgetgoarm() string {
515523 // OpenBSD currently only supports softfloat.
516524 return "5"
517525 }
518- if goos != "linux" {
519- // All other arm platforms that we support
520- // require ARMv7.
526+
527+ // Try to exec ourselves in a mode to detect VFP support.
528+ // Seeing how far it gets determines which instructions failed.
529+ // The test is OS-agnostic.
530+ out := run ("" , 0 , os .Args [0 ], "-check-goarm" )
531+ v1ok := strings .Contains (out , "VFPv1 OK." )
532+ v3ok := strings .Contains (out , "VFPv3 OK." )
533+
534+ if v1ok && v3ok {
521535 return "7"
522536 }
523- cpuinfo := readfile ("/proc/cpuinfo" )
524- goarm := "5"
525- for _ , line := range splitlines (cpuinfo ) {
526- line := strings .SplitN (line , ":" , 2 )
527- if len (line ) < 2 {
528- continue
529- }
530- if strings .TrimSpace (line [0 ]) != "Features" {
531- continue
532- }
533- features := splitfields (line [1 ])
534- sort .Strings (features ) // so vfpv3 sorts after vfp
535-
536- // Infer GOARM value from the vfp features available
537- // on this host. Values of GOARM detected are:
538- // 5: no vfp support was found
539- // 6: vfp (v1) support was detected, but no higher
540- // 7: vfpv3 support was detected.
541- // This matches the assertions in runtime.checkarm.
542- for _ , f := range features {
543- switch f {
544- case "vfp" :
545- goarm = "6"
546- case "vfpv3" :
547- goarm = "7"
548- }
549- }
537+ if v1ok {
538+ return "6"
550539 }
551- return goarm
540+ return "5"
552541}
553542
554543func min (a , b int ) int {
0 commit comments