Duncan Coutts pushed to branch wip/dcoutts/foreign-label-source-refactoring at Glasgow Haskell Compiler / GHC Commits: 53eead15 by Wolfgang Jeltsch at 2026-09-24T20:12:03-04:00 Correct the documentation of `explicitUnits` Resolves #27787. - - - - - 35bf6f4b by Simon Jakobi at 2026-09-24T20:12:49-04:00 Remove stale specHeader bullet from Note [Don't make fillers for constraint types] The Note said that Specialise.specHeader also calls mkAbsentFiller. abfc224a27c removed that call: the specialiser no longer drops dead arguments at all, see Note [Do not drop dead args from specialisations] in GHC.Core.Opt.Specialise. Assisted-by: Claude Fable 5.1 - - - - - 1abef1ef by Wolfgang Jeltsch at 2026-09-25T17:02:07-04:00 Improve the `mhu-closure` makefile - - - - - a79a68ea by Wolfgang Jeltsch at 2026-09-25T17:02:07-04:00 Make `ghci-multi` hide all unneeded packages - - - - - d6e72450 by Wolfgang Jeltsch at 2026-09-25T17:02:07-04:00 Improve the definition of the home unit closure property - - - - - c9a2766d by Wolfgang Jeltsch at 2026-09-25T17:02:07-04:00 Re-implement the home unit closure check Compared to the previous implementation, the new one has the following advantages: * It is correct. - It distinguishes between units that have the same unit ID but different ABI hashes. - When `-hide-all-packages` is not used, it considers as home unit dependencies also units that are made implicitly available because they are in the package database. * It seems to be faster in usual settings. - In particular, it does not have a preparation phase in which it merges the dependency information from all home units, so that its running time does not grow linearly with the size of the package database in normal Cabal scenarios. * It is (hopefully) clearer. * It is better documented. - - - - - fa96acf8 by Wolfgang Jeltsch at 2026-09-25T17:02:07-04:00 Remove erroneous GHC flag in `hadrian-multi` The flag was `-Werror=-Wno-error=incomplete-record-selectors`. Its purpose was to permit incomplete record selectors, but because of the illegal combination of `-Werror=` and `-Wno-error` it was ignored, without any negative consequences. - - - - - 9f48a5b9 by Alan Zimmerman at 2026-09-25T17:02:50-04:00 EPA: Add specific layout field to AnnList Up to now AnnList has effectively served to represent lists of things having layout, regardless of whether they do or not. In Haskell, layout is optional in many places, as there is also an alternative syntax using braces and semi-colons, which is free-form. This commit introduces AnnListLayout, a data structure capturing this distinction. It is deliberately set up similarly to EpLayout, so that these two can be merged in time. The transition is done mechanically, where AnnListBraces is not used yet, the original Nothing case maps to AnnListNoLayout, and the Just case to AnnListLayout. Later commits will fine tune these against the actual parser layout. - - - - - 234bab08 by Vladislav Zavialov at 2026-09-29T17:22:54-04:00 Add regression test for #7803 Commit 2effe18ab5, first shipped with GHC 8.2.1, fixed #7803 "Superclass methods are left unspecialized". This change turns the example from the ticket description into a regression test, checking that foo1 is fully specialised at Double, with no calls to the overloaded exp5Tail. Closes #7803 Assisted-by: Claude Opus 5 - - - - - c406135c by Andreas Klebinger at 2026-10-01T06:57:28-04:00 RTS: Update flag parsing/handling: Using 0 as argument to any of these flags now resets the flags setting to default: - ``-n0`` disables nursery chunking. - ``-K0`` (or a bare ``-K``) removes the stack size limit. - ``-M0`` removes the heap size limit. - ``-H0`` resets the suggested heap size, including the nursery scaling set by ``-H``. - ``-AL0`` makes the large object allocation limit follow ``-A`` again. GC Generations are now limited to 64. -n larger than -A now emits a warning and disables chunking. Fixes #27830 #27829 - - - - - 984ee82b by Andreas Klebinger at 2026-10-01T06:58:10-04:00 Fix MultiLayerModules timeout multiplier. We accidentally used the compile multiplier for ghci commands which use the run timeout setting to set the timeout. Fixes #26263 and #27796. - - - - - 50a9cf26 by Andreas Klebinger at 2026-10-01T06:58:10-04:00 testsuite: Include runtime in JUnit report. - - - - - e358619f by Alan Zimmerman at 2026-10-01T06:59:01-04:00 EPA: Use EpaLocation in EpVirtualBraces Haddock processing uses EpLayout.EpVirtualBraces to record the current layout column, for allocating haddock comments correctly. For exact printing, we need the line as well as the col, so we know how many lines to skip when the indented code block starts. This commit updates EpLayout.EpVirtualBraces so that it carries an EpaLocation instead of just the Int column, to allow it to be used for both purposes. It is a simple mechanical change, with no other impact, but it allows us to use EpLayout instead of AnnListLayout in AnnList, in the next commit in this series. - - - - - 1d2a26ee by Andrew Lelechenko at 2026-10-01T20:22:04-04:00 Remove bitSize from MINIMAL pragma of class Bits Cf. https://github.com/haskell/core-libraries-committee/issues/441 The function is deprecated for 12 years and has a default implementation, yet it was never removed from the MINIMAL pragma, putting library authors in a very awkward position. Let's finally remove bitSize from MINIMAL. - - - - - 3cc21e4c by Hannes Siebenhandl at 2026-10-01T20:22:59-04:00 Add regression test for #27641 - - - - - c35096f5 by Hannes Siebenhandl at 2026-10-01T20:23:00-04:00 Don't `:add` modules the loader will reject Only home modules can be actually added to the loader context, thus we only accept the module if it belongs to a home unit. - - - - - a563cb27 by Simon Jakobi at 2026-10-02T17:37:36-04:00 ci: accept modified changelog.d entries in lint-changelog The changelog guide says to extend an existing entry rather than add a new one when the feature is already documented. lint_changelog only counted added files, so such MRs failed before the validator ran. Fixes #27779. Assisted-by: Claude Fable 5.1 - - - - - 03082cd4 by Simon Jakobi at 2026-10-02T17:38:17-04:00 changelog.d: Fix warning flag name in the semaphore-v2 entry The entry refers to -Wsemaphore-version-mismatch, which does not exist. The warning GHC emits when it cannot use a -jsem semaphore, including on a protocol version mismatch, is -Wsemaphore-open-failure. Context: !15729, #25087 Assisted-by: Claude Fable 5.1 - - - - - a93705ee by Simon Jakobi at 2026-10-02T17:38:17-04:00 changelog.d: Fix the CLC proposal link in the T27455 entry The entry used the Sphinx :ref: role with a URL as its target. :ref: resolves only internal labels, so the generated release notes would show the proposal name without a link. Use the plain hyperlink form like the other entries. Context: !16274, #27455 Assisted-by: Claude Fable 5.1 - - - - - 54381079 by Hannes Siebenhandl at 2026-10-02T17:39:01-04:00 Extend the `TrustOverlay` for wired-in units The TrustOverlay only contained the `UnitId` of all on-disk units. However, wired-in units are referred to by their wired-in unit id, which is not the same as the on-disk unit id. Thus, trust checks for wired-in units failed because the lookup was using the wired-in unit, which wasn't present in the `TrustOverlay`. We fix #27834, by copying the trust info for wired-in unit ids. - - - - - c159372f by Duncan Coutts at 2026-10-06T14:46:51+01:00 Move data FunctionOrData from GHC.Types.Basic to .ForeignCall It makes more sense here, and we will soon use it in other related types in this module. Adjust all the other imports. - - - - - fcb0f581 by Duncan Coutts at 2026-10-06T14:46:51+01:00 Rename type FunctionOrData to ForeignLabelIsFunctionOrData And its constructors from IsFunction | IsData to ForeignLabelIsFunction | ForeignLabelIsData This name better fits the names of the related types that it is used with. - - - - - 3fc95aae by Duncan Coutts at 2026-10-06T14:46:51+01:00 Change dsCCall to take a CCallSpec and change callers as appropriate. There should be no semantic change. It's just moving the CCallSpec construction into the two callers. It is currently only used by the C & JS functions that generate code for the foreign import wrapper constructs (in the call to createAdjustor). - - - - - c1bb9828 by Duncan Coutts at 2026-10-06T14:46:52+01:00 Change calls to createAdjustor to specify that it comes from the rts Previously it said TargetIsInThisUnit, meaning that createAdjustor lives in the local library. This is false since createAdjustor is defined in the RTS. In practice, this false source information did not matter because the source information is not used (yet). However in future it will be, for better Windows DLL support (which does care about such distinctions). It doesn't really matter that we say it's the RTS (though that is actually true), what's important is that it will always be external to the current shared library. - - - - - 5a8aec6b by Duncan Coutts at 2026-10-06T14:46:52+01:00 Remove unused TargetIsInThisUnit case from CCallStaticTargetUnit The CCallStaticTargetUnit infortmation in the XStaticTarget (TTG exstension point) is actually pretty dubious. Historically it was a (Maybe Unit) and the comments say that it is only used by out-of-line primop calls on Windows. Indeed it is only used on Windows for the dynamic way, when each unit is built as a separate DLL (which we currently do not support). And even in that hypothetical situation, the information that actually gets filled in is completely bogus. It _could_ be used in the windows dll case to correctly distinguish making an out-of-line call to a cmm primop that is defined in the current dll or in an external dll. But the information gets filled in in the renaming phase with the _current_ unit. This is blatently wrong. Many out-of-line primops are defined in the rts, which is obviously not the current unit. It _could_ be a reasonable default, that cmm primops are expected to be in the current dll, but we would have to have support to specify a different location, i.e. the rts. Furthermore, in addition to TargetIsInThisUnit being unused (after the previous patch) it should never be used because it uses an implicit "this" which will be wrong as soon as the information is inlined across units. Instead of an implicit unit, it should use an explicit unit which can be initialised to the defining unit and then be compared later to the current unit. This will work correctly when looking at unfoldings across unit boundaries. - - - - - 0536471b by Duncan Coutts at 2026-10-07T14:13:13+01:00 Rename CCallStaticTargetUnit to CLabelTargetLibrary And the constructor TargetIsInThat to CLabelTargetInUnit. We will end up using this type both for calls and for labels/addresses (used in core literals), so adjust the name to be about C names/labels rather than about calls specifically. Also improve related code docs. And introduce a conversion function from CLabelTargetLibrary to ForeignLabelSource. We will extend this conversion when we add more constructors to CLabelTargetLibrary. - - - - - 53592d0a by Duncan Coutts at 2026-10-07T14:13:13+01:00 Change data PrimOp to use a UnitId rather than Unit This simplifies the conversions slightly, but more importantly in a later change we are going to want to specify a unit where we will only have a UnitId to hand, not a Unit. - - - - - 34a74091 by Duncan Coutts at 2026-10-07T16:20:32+01:00 Extend 'foreign import prim' syntax to allow specifying the source package that is: the package where the cmm entity comes from. The package name is stashed in the "header" field for the FFI call, and then the renamer resolves the package name to a unit id (with a new ghc error for the failure of the package name resolution). Fixes issue #27206 Adds test case T27206 - - - - - 2bf19f2d by Duncan Coutts at 2026-10-07T16:20:32+01:00 Use new package name syntax for primops from the RTS foreign import prim "rts stg_thething" Most uses of foreign import prim in the libraries are for primops defined in .cmm files local to that library, but some import primops defined in the rts. These cases should use the new syntax to specify the package name in the ffi entity string. - - - - - de9c32f0 by Duncan Coutts at 2026-10-08T11:27:22+01:00 Change labelDynamic to labelLinkerUnit and refine the question it answers Previously asked a very vague question: -- | Does a 'CLabel' need dynamic linkage? given the plethora of platforms and linking schemes, this is not a question with a yes/no answer in general. Instead we change the question to this: -- | Does the target entity of a 'CLabel' live in the same linker unit -- as the given module? This _does_ have a clear meaning across platforms. (The notion of what a linker unit is is platform dependent it is relatively consistent). We also change the answer from Bool to a new type: data LabelLinkerUnit = LinkerUnitLocal | LinkerUnitExternal In a subsequent change we will extend this type to admit a third answer: unknown, could be either local or external. This is the case arising from all user-written FFI declarations. Update the callers: SRT generation and PIC.howToAccessLabel The latter will need more work to do nicely, which we'll do in a subsequent patch. - - - - - 019e09b4 by Duncan Coutts at 2026-10-08T11:27:22+01:00 Extend LabelLinkerUnit with a third case: unknown For user-written FFI calls, we never know where the target of the label lives: it could live in the local linker unit or it could be external. This case was not accounted for in the old labelDynamic function. Callers need to decide if they want to know about all three cases, or just want to know for sure that something is local, or for sure that something is external and thus they can bundle the unknown case into the negative. - - - - - b6c9d3de by Duncan Coutts at 2026-10-08T11:27:22+01:00 Update use of labelLinkerUnit in howToAccessLabel for unknown case Since "is it external or local" is not a yes/no question anymore, due to the "dunno, could be either" case, we update all the uses of labelLinkerUnit in howToAccessLabel so that should do the right thing for the unknown case. In practice, the unknown case doesn't _yet_ reach howToAccessLabel for non-win32 platforms because for the one case where it will occurr -- in foreign calls -- labelLinkerUnit defines this always to be LinkerUnitExternal for all platforms other than OSMinGW32. But nevertheless, this brings us a step closer to accuracy in howToAccessLabel, should we want to be more precise for foreign calls. - - - - - 683dd6ec by Duncan Coutts at 2026-10-08T11:27:22+01:00 Extend ForeignLabelSource with ForeignLabelInUnknownPackage case Initially this is treated the same way as ForeignLabelInExternalPackage. Later we will extend this for Windows/PE to support building each Haskell unit as a separate DLL, to support this unknown case specifically. - - - - - d590f9cf by Duncan Coutts at 2026-10-08T11:27:22+01:00 Extend CLabelTargetLibrary with CLabelTargetUnknown case Initially unused, but this will become the typical case, because in fact when Haskell code uses ffi imports, we do not know where the name comes from: we do not know if the named entity is defined in the current shared lib or in another one. Knowing where C entities come from is the exception rather than the rule. - - - - - e55790cd by Duncan Coutts at 2026-10-08T11:27:22+01:00 Extend LitLabel with CLabelTargetLibrary Bundle the three fields of LitLabel into a new data CLabelSpec, defined in GHC.Types.ForeignCall Apart from the binary format, this should not change behaviour. Behaviour changes are in the next patch - - - - - 5dc9e552 by Duncan Coutts at 2026-10-08T11:27:22+01:00 Reorder and group related declarations in ForeignCall module It was all a bit of a jumble. - - - - - ed813c32 by Duncan Coutts at 2026-10-08T11:27:22+01:00 Remove redundant util ccallConvAttribute and unused defaultCCallConv Historically, the stdcall calling convention required special treatment when constructing calls in the via-C backend, to declare the C prototype with the right attributes to tell the C compiler what call convention to use. We no longer support stdcall. Now ccallConvAttribute returns empty for every calling convention, or panics. So it is no longer useful. The defaultCCallConv was unused. - - - - - ca2ade4b by Duncan Coutts at 2026-10-08T12:13:07+01:00 Add Note [Tracking labels' target libraries] and [Tracking labels' target type] and reference these notes elsewhere. - - - - - 71a632dd by Duncan Coutts at 2026-10-08T12:13:07+01:00 Change FFI imports to use CLabelTargetUnknown We never know the target for normal foreign imports. Historically, this information was only actually used for "foreign import prim", and only on Windows when building with one DLL per unit (which bitrotted). The previous default of using the current package as the source was wrong, even for the limited case of Windows DLLs, because many of the imports are for primops defined in the RTS, which is certainly not the current package. - - - - - 69cf70c4 by Duncan Coutts at 2026-10-08T12:13:07+01:00 Pass through the label source in stg->cmm conversion Previously we had to hard code the (often incorrect) source ForeignLabelInThisPackage. Now the Core label literal representation carries the source, so we just convert that and pass it down. As a consequence, if the source will now be either ForeignLabelInUnknownPackage or ForeignLabelInPackage. The typical value will be ForeignLabelInUnknownPackage, since that's what we get for FFI imports of addresses. In practice is not an immediate change of behaviour, because the only user of this information is on Windows when building each Haskell unit as a separate DLl, which isn't (yet) supported. - - - - - baeb2fbf by Duncan Coutts at 2026-10-08T12:13:07+01:00 Fix source for generated C name for 'foreign import "wrapper"' For a 'foreign import "wrapper"' construct we generate a local wrapper C function. We need to refer to the name of this local C function. We _know_ that this function lives in the local shared lib, because it is compiled into the same library. Thus we set the label source to be CLabelTargetInUnit. - - - - - f18df396 by Duncan Coutts at 2026-10-08T12:13:07+01:00 Fix source for generated C name for 'foreign import capi' For a 'foreign import capi' we generate a local wrapper function and then call that. We need to refer to the name of this local C function. We _know_ that this function lives in the local shared lib, because it is compiled into the same library. Thus we set the label source to be CLabelTargetInUnit. - - - - - 9f6328ae by David Eichmann at 2026-10-08T13:12:54+01:00 Documentation: foreign imports of Cmm code must now specify source package but the current package is the default. - - - - - 120 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + changelog.d/27641 - changelog.d/T27455 - + changelog.d/T27830-rts-flag-bounds - + changelog.d/foreign-import-prim-with-package.md - changelog.d/semaphore-v2 - changelog.d/unit-index - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/LA64/CodeGen.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/RV64/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Driver/Downsweep.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/HsToCore/Foreign/Wasm.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Lit.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToJS/FFI.hs - compiler/GHC/StgToJS/Literal.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/ForeignCall.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Unit/Env.hs - compiler/GHC/Unit/External/Wired.hs - compiler/GHC/Unit/State.hs - docs/users_guide/exts/ffi.rst - docs/users_guide/runtime_control.rst - ghc/GHCi/UI.hs - hadrian/ghci-multi-cabal.in - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/AllocationLimitHandler.hs - libraries/ghc-internal/src/GHC/Internal/Bits.hs - libraries/ghc-internal/src/GHC/Internal/Prim/Ext.hs - libraries/ghc-internal/src/GHC/Internal/Prim/Panic.hs - rts/RtsFlags.c - rts/include/rts/Flags.h - rts/include/rts/storage/GC.h - rts/sm/GC.c - rts/sm/Storage.c - testsuite/driver/junit.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/driver/multipleHomeUnits/mhu-closure/Makefile - testsuite/tests/driver/multipleHomeUnits/mhu-closure/mhu-closure.stderr - testsuite/tests/driver/multipleHomeUnits/mhu-closure/mhu-closure.stdout - testsuite/tests/ghc-api/exactprint/T22919.stderr - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/ghc-api/exactprint/ZeroWidthSemi.stderr - + testsuite/tests/ghci/scripts/T27641.script - + testsuite/tests/ghci/scripts/T27641.stderr - + testsuite/tests/ghci/scripts/T27641.stdout - + testsuite/tests/ghci/scripts/T27834.hs - + testsuite/tests/ghci/scripts/T27834.script - + testsuite/tests/ghci/scripts/T27834.stdout - testsuite/tests/ghci/scripts/all.T - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/module/mod185.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T15279.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/parser/should_compile/T20452.stderr - testsuite/tests/parser/should_compile/T20718.stderr - testsuite/tests/parser/should_compile/T20718b.stderr - testsuite/tests/parser/should_compile/T20846.stderr - testsuite/tests/parser/should_compile/T23315/T23315.stderr - testsuite/tests/perf/compiler/all.T - testsuite/tests/printer/AnnotationNoListTuplePuns.stdout - testsuite/tests/printer/T18791.stderr - testsuite/tests/printer/Test20297.stdout - testsuite/tests/printer/Test24533.stdout - + testsuite/tests/rename/should_fail/T27206.hs - + testsuite/tests/rename/should_fail/T27206.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/rts/all.T - testsuite/tests/rts/rtsflags001.stderr-ws-32 - testsuite/tests/rts/rtsflags001.stderr-ws-64 - testsuite/tests/simplCore/should_compile/T16122.stderr - + testsuite/tests/simplCore/should_compile/T7803.hs - + testsuite/tests/simplCore/should_compile/T7803.stderr - + testsuite/tests/simplCore/should_compile/T7803a.hs - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs - utils/check-exact/Transform.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea588929ed5e8617f7b1a8a59d88e76... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea588929ed5e8617f7b1a8a59d88e76... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help