Skip to content

Draft: compiler: remove the isMathFun hack in the unregisterised codegen

Cheng Shao requested to merge type-dance/ghc:unreg-no-mathfun-hack into master

Almost 15 years ago, c245355e introduced the isMathFun hack: when lowering a ccall import, avoid generating a C function prototype if it's a builtin math function. It's meant to avoid generating C function prototypes for builtin math functions. However, the compiler has changed significantly ever since. Nowadays, for the ccall imports, the header is completely ignored. The unregisterised codegen doesn't emit C function prototypes for these ccall imports, instead it just declares the symbol as an extern function with a dummy prototype, and coerce the function pointer at call sites.

This means that the isMathFun hack is no longer necessary. Furthermore, it causes trouble for certain targets (e.g. wasm), where cg007 would fail with "error: use of undeclared identifier 'gamma'". It's time to get rid of this hack altogether.

Merge request reports