Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d99f8326 by Cheng Shao at 2025-12-11T19:14:18-05:00 compiler: remove unused CPP code in foreign stub This patch removes unused CPP code in the generated foreign stub: - `#define IN_STG_CODE 0` is not needed, since `Rts.h` already includes this definition - The `if defined(__cplusplus)` code paths are not needed in the `.c` file, since we don't generate C++ stubs and don't include C++ headers in our stubs. But it still needs to be present in the `.h` header since it might be later included into C++ source files. - - - - - 1 changed file: - compiler/GHC/Driver/CodeOutput.hs Changes: ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -329,15 +329,8 @@ outputForeignStubs logger tmpfs dflags unit_state mod location stubs stub_c_file_exists <- outputForeignStubs_help stub_c stub_c_output_w - ("#define IN_STG_CODE 0\n" ++ - "#include <Rts.h>\n" ++ - rts_includes ++ - ffi_includes ++ - cplusplus_hdr) - cplusplus_ftr - -- We're adding the default hc_header to the stub file, but this - -- isn't really HC code, so we need to define IN_STG_CODE==0 to - -- avoid the register variables etc. being enabled. + (rts_includes ++ + ffi_includes) "" return (stub_h_file_exists, if stub_c_file_exists then Just stub_c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d99f8326ff2658f1170f520016284d38... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d99f8326ff2658f1170f520016284d38... You're receiving this email because of your account on gitlab.haskell.org.