diff options
author | Cheng Shao <astrohavoc@gmail.com> | 2022-10-24 13:37:20 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-11-11 00:26:55 -0500 |
commit | df6bb1124154bf95527bfe0645b81c89ee869940 (patch) | |
tree | 5e99777212974bd13d12f2647e05783f0b97d989 /compiler/GHC/Driver | |
parent | 06f01c747551954e37108b714950f1fca8b6cd66 (diff) | |
download | haskell-df6bb1124154bf95527bfe0645b81c89ee869940.tar.gz |
driver: pass -Wa,--no-type-check for wasm32 when runAsPhase
This patch passes -Wa,--no-type-check for wasm32 when compiling
assembly. See the added note for more detailed explanation.
Diffstat (limited to 'compiler/GHC/Driver')
-rw-r--r-- | compiler/GHC/Driver/Pipeline/Execute.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs index 5e34309019..2a1e877292 100644 --- a/compiler/GHC/Driver/Pipeline/Execute.hs +++ b/compiler/GHC/Driver/Pipeline/Execute.hs @@ -323,6 +323,10 @@ runAsPhase with_cpp pipe_env hsc_env location input_fn = do , not $ target32Bit (targetPlatform dflags) ] + -- See Note [-Wa,--no-type-check on wasm32] + ++ [ GHC.SysTools.Option "-Wa,--no-type-check" + | platformArch (targetPlatform dflags) == ArchWasm32] + ++ (if any (asmInfo ==) [Clang, AppleClang, AppleClang51] then [GHC.SysTools.Option "-Qunused-arguments"] else []) @@ -1247,3 +1251,30 @@ Archeology commit called "Fix the filename passed to unlit" (1eedbc6b). So the `normalise` is no longer necessary. -} + +{- +Note [-Wa,--no-type-check on wasm32] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Wasm32 has a type system and corresponding validation rules, so it's +possible to produce syntactically valid object code that doesn't pass +validation. + +We have no problem with that, but we do have a problem with clang. +When clang takes an assembly input for wasm32, it uses its internal +type-checker, which is a huge source of trouble (see llvm ticket +#56935 #58438): it may reject valid assembly, and even worse, it may +silently alter the output object code!!! The worsest of all, is the +person that added the wasm32 asm typechecker logic has moved on from +Google/LLVM, and while other LLVM devs may be knowledgable enough to +fix this mess, they likely got tons of other stuff on their table and +don't care enough. + +We do have an escape hatch, just pass -Wa,--no-type-check to clang to +bypass the entire wasm32 asm typechecking logic. There's little point +in type-checking object code at compile-time anyway, the wasm engines +will do type-checking at run-time. And even if we want to add some +linting flag to do compile-time checks, we should just rely on +battle-tested external tools instead of a completely broken horror +story. +-} |