$ /e/ghc_regSpill/inplace/bin/ghc-stage2.exe Repro.hs -O2 -fllvm -O2Loaded package environment from C:\ghc\msys64\home\Andi\tmp\minmax\unpred\.ghc.environment.x86_64-mingw32-8.7.20190215[1 of 1] Compiling Main ( Repro.hs, Repro.o )C:\\ghc\\msys64\\tmp\\ghc385768_0\\ghc_6.s: Assembler messages:C:\\ghc\\msys64\\tmp\\ghc385768_0\\ghc_6.s:354: Error: junk at end of line, first unrecognized character is `,'`gcc.exe' failed in phase `Assembler'. (Exit code: 1)
I've reproduced this with ghc 8.4/8.6 and HEAD using llvm 7.0.1 on windows.
Andi@Horzube MINGW64 ~/tmp/minmax/llvm$ opt -O3 Repro.ll > opt.bcAndi@Horzube MINGW64 ~/tmp/minmax/llvm$ llc opt.bc -o llc.s -O3Andi@Horzube MINGW64 ~/tmp/minmax/llvm$ as llc.sllc.s: Assembler messages:llc.s:367: Error: junk at end of line, first unrecognized character is `,'
$ as --versionGNU assembler (GNU Binutils) 2.30Copyright (C) 2018 Free Software Foundation, Inc.This program is free software; you may redistribute it under the terms ofthe GNU General Public License version 3 or later.This program has absolutely no warranty.This assembler was configured for a target of `x86_64-w64-mingw32'.
I don't think it would be wise to let this issue hold us back on an old llvm release. However, the other options aren't much better. Ideally we would just use llvm-mc but this is easier said than done since we use invoke the assembler through gcc. Using as directly is complicated by the fact that we would then be responsible for running cpp ourselves.
The problem with mc is that we can get assembly with CPP directives in it:
8:52 PM AndreasK> bgamari: our generated assembly contains CPP directives?8:55 PM <bgamari> no, but a TH splice may have added an assembler source file that does
We could (depending on the backend used) invoke gcc on the generated assembly just for CPP and the pass the result on to as/llvm-mc depending on the backend.
AndreasK> bgamari: We could pipe assembly through the gcc CPP, and then pipe the result through as/llvm-mc depending on backend though right?9:00 PM <bgamari> AndreasK, yes9:00 PM we already have support for invoking the preprocessor9:00 PM so really this is likely just a matter of plumbing
Given that LLVM will likely keep things specific to their assembler when it suits them I don't think we can count on this being resolved through upstream changes.
So I'm reopening this. Just needs someone to dive into the plumbing.
This is a regression in %8.8.1. However, I don't think this is affecting enough people to prioritize for %8.8.2. Let's try to fix for %8.10.1, however.
For what it's worth, we now use a clang-based toolchain on Windows (see #21019 (closed)), which avoids this particular issue on that platform. However, fixing this in general will require using an LLVM-based toolchain for assembling code produced by the LLVM backend on all platforms until we can eliminate the LLVM mangler (#11138 ).
This has come up again in the context of FMA instructions on x86-64. It appears that LLVM generates FMA syntax that GNU as does not understand. I suspect the solution here needs to be to move to using llvm-as when generating code via the LLVM backend.
I don't think it's to do with FMA instructions. The assembler sees a .section directive with ".data.ZCMain_main_closure$def","awR",@progbits but gcc assembler doesn't understand R.