
#13513: Incorrect behavior on arm64 with optimisations -------------------------------------+------------------------------------- Reporter: achirkin | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: aarch64 Type of failure: Incorrect result | Test Case: at runtime | Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by achirkin): I feel I need to add more information here for one who decides to work on this. At first, I use two Ubuntu 16.04 machines to test it: Samsung Chromebook plus (arm64) and x86_64 machine with static arm64 qemu (was quite easy to set up using following instructions [https://wiki.debian.org/Arm64Qemu]). The second one runs quite slow; e.g. fully optimized build of GHC takes 10-20 hours. I compiled several versions of GHC-8.0.2 and saved configuration/build options I used; accessible by the following link [https://drive.google.com/open?id=1aO4owbg8oAt7F3tjfPXUntmaEXBj_6HH7aNgRFffti...]. Ticket [https://ghc.haskell.org/trac/ghc/ticket/10174] says that somebody failed to compile GHC using quick-llvm, but succeeded using perf-llvm. This might be related to my issue. In contrast to 10174, [https://ghc.haskell.org/trac/ghc/ticket/10383] shows that some tests fail with optimization, but pass without it. {{{ $ ghc --info [ ("Project name","The Glorious Glasgow Haskell Compilation System") ,("GCC extra via C opts"," -fwrapv -fno-builtin") ,("C compiler command","/usr/bin/gcc") ,("C compiler flags"," -fno-stack-protector") ,("C compiler link flags"," -fuse-ld=gold -Wl,-z,noexecstack") ,("C compiler supports -no-pie","YES") ,("Haskell CPP command","/usr/bin/gcc") ,("Haskell CPP flags","-E -undef -traditional") ,("ld command","/usr/bin/ld.gold") ,("ld flags"," -z noexecstack") ,("ld supports compact unwind","YES") ,("ld supports build-id","YES") ,("ld supports filelist","NO") ,("ld is GNU ld","YES") ,("ar command","/usr/bin/ar") ,("ar flags","q") ,("ar supports at file","YES") ,("touch command","touch") ,("dllwrap command","/bin/false") ,("windres command","/bin/false") ,("libtool command","libtool") ,("perl command","/usr/bin/perl") ,("cross compiling","NO") ,("target os","OSLinux") ,("target arch","ArchARM64") ,("target word size","8") ,("target has GNU nonexec stack","True") ,("target has .ident directive","True") ,("target has subsections via symbols","False") ,("Unregisterised","NO") ,("LLVM llc command","/usr/bin/llc-3.7") ,("LLVM opt command","/usr/bin/opt-3.7") ,("Project version","8.0.2") ,("Project Git commit id","8c7250379d0d2bad1d07dfd556812ff7aa2c42e8") ,("Booter version","8.0.2") ,("Stage","2") ,("Build platform","aarch64-unknown-linux") ,("Host platform","aarch64-unknown-linux") ,("Target platform","aarch64-unknown-linux") ,("Have interpreter","YES") ,("Object splitting supported","NO") ,("Have native code generator","NO") ,("Support SMP","YES") ,("Tables next to code","YES") ,("RTS ways","l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn l_dyn thr_l_dyn") ,("RTS expects libdw","NO") ,("Support dynamic-too","YES") ,("Support parallel --make","YES") ,("Support reexported-modules","YES") ,("Support thinning and renaming package flags","YES") ,("Requires unified installed package IDs","YES") ,("Uses package keys","YES") ,("Uses unit IDs","YES") ,("Dynamic by default","NO") ,("GHC Dynamic","YES") ,("GHC Profiled","NO") ,("Leading underscore","NO") ,("Debug on","False") ,("LibDir","/usr/local/ghc-8.0.2/lib/ghc-8.0.2") ,("Global Package DB","/usr/local/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d") ] }}} Finally, for those who want to try unregisterized build of ghc-8.0.2 on arm right now, these stack options are working for me (precompiled stack and ghc can be found in my google drive): {{{ $ cat ~/.stack/config.yaml system-ghc: true jobs: 4 local-bin-path: /home/achirkin/.local/stackbin ghc-options: "*": -O1 -fllvm -fliberate-case -fregs-graph -fspec-constr -optlc-O3 apply-ghc-options: everything }}} The ghc options I specified are the closest ones to `-O2` that do not cause the strange bug discussed in this ticket (at least, for me). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13513#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler