Skip to content

Cabal + Make based build #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 586 commits into
base: tmp/make-build-offset
Choose a base branch
from

Conversation

angerman
Copy link

This builds upon wip/make-build, and integrates some of the andrea/make-build parts.

@angerman angerman self-assigned this May 10, 2025
@angerman angerman changed the base branch from master to wip/make-build May 10, 2025 03:31
@angerman angerman changed the base branch from wip/make-build to tmp/make-build-offset May 10, 2025 04:45
@angerman angerman force-pushed the wip/make-build-pre-zig branch from 74fdffe to a3d41c0 Compare May 10, 2025 08:34
TerrorJack and others added 26 commits May 20, 2025 17:22
This commit makes all the FFIInfo needed in CCALL instructions
serializable. Previously, when doing STG to BCO lowering, we would
allocate a libffi ffi_cif struct and keep its remote pointer as
FFIInfo; but actually we can just keep the type signature as FFIInfo
and defer the actual allocation to link-time.
This commit removes the redundant NewBreakModule message from ghci: it
just allocates two strings! This functionality can be implemented with
existing MallocStrings in one iserv call.
This commit makes breakpoint module name and unit id serializable, in
BRK_FUN instructions as well as ModBreaks. We can simply keep the
module name and unit ids, and defer the buffer allocation to link
time.
This commit removes the now unused newModule function from GHC.
This commit adds BCONPtrFS as a BCO non-pointer literal kind, which
has the same semantics of BCONPtrStr, except it contains a FastString
instead of a ByteString. By using BCONPtrFS to represent top level
string literals that are already FastString in the compilation
pipeline, we enjoy the FastString interning logic and avoid allocating
a bunch of redundant ByteStrings for the same FastStrings, especially
when we lower the BRK_FUN instruction.
This fixes #26017.

  * `integerRecipMod x 1` now returns `(# 1 | #)` for all x; previously it
    incorrectly returned `(# | () #)`, indicating failure.

  * `integerPowMod 0 e m` now returns `(# | () #)` for e<0 and m>1, indicating
    failure; previously it incorrectly returned `(# 0 | #)`.
It was fairly complex to do so and it doesn't seem to improve anything.
Nofib allocations were unaffected as well.

See also Historical Note [Floating dictionaries out of cases]
This commit adds support for a number of primops directly
to the interpreter. This avoids the indirection of going
through the primop wrapper for those primops speeding interpretation
of optimized code up massively.

Code involving IntSet runs about 25% faster with optimized core and these
changes. For core without breakpoints it's even more pronouced and I
saw reductions in runtime by up to 50%.

Running GHC itself in the interpreter was sped up by ~15% through this
change.

Additionally this comment does a few other related changes:

testsuite:
* Run foundation test in ghci and ghci-opt ways to test these
primops.
* Vastly expand the foundation test to cover all basic primops
  by comparing result with the result of calling the wrapper.

Interpreter:
* When pushing arguments for interpreted primops extend each argument to
  at least word with when pushing. This avoids some issues with big
  endian. We can revisit this if it causes performance issues.
* Restructure the stack chunk check logic. There are now macros for
  read accesses which might cross stack chunk boundries and macros which
  omit the checks which are used when we statically know we access an
  address in the current stack chunk.
This commit ensures we do a shape test before unifying. This ensures
we don't try to unify a TyVarTv with a non-tyvar, e.g.

  alpha[tyv] := Int

On the way, we refactor simpleUnifyCheck:

  1. Move the checkTopShape check into simpleUnifyCheck
  2. Refactors simpleUnifyCheck to return a value of the new type
     SimpleUnifyResult type. Now, simpleUnifyCheck returns "can unify",
     "cannot unify" or "dunno" (with "cannot unify" being the new result
     it can return). Now:
       - touchabilityTest is included; it it fails we return "cannot unify"
       - checkTopShape now returns "cannot unify" instead of "dunno" upon failure
  3. Move the call to simpleUnifyCheck out of checkTouchableTyVarEq.
     After that, checkTouchableTyVarEq becames a simple call to
     checkTyEqRhs, so we inline it.

This allows the logic in canEqCanLHSFinish_try_unification to be simplified.
In particular, we now avoid calling 'checkTopShape' twice.
Two further changes suggested by Simon were also implemented:

  - In canEqCanLHSFinish, if checkTyEqRhs returns PuFail with
    'do_not_prevent_rewriting', we now **continue with this constraint**.
    This allows us to use the constraint for rewriting.

  - checkTyEqRhs now has a top-level check to avoid flattening a tyfam app
    in a top-level equality of the form alpha ~ F tys, as this is
    going around in circles. This simplifies the implementation without
    any change in behaviour.

Fixes #25950
Fixes #26030
This commit tweaks the FixedRuntimeRepError case of pprTcSolverReportMsg,
to avoid including an explanation which refers to a type variable that
appears nowhere else.

For example, the old error message could look like the following:

  The pattern binding does not have a fixed runtime representation.
  Its type is:
    T :: TYPE R
  Cannot unify ‘R’ with the type variable ‘c0’
  because the former is not a concrete ‘RuntimeRep’.

With this commit, we now omit the last two lines, because the concrete
type variable (here 'c0') does not appear in the type displayed to the
user (here 'T :: TYPE R').
If ghcversion.h can't be found, don't try to include it. This happens
when there is no rts package in the package db and when -ghcversion-file
argument isn't passed.

Co-authored-by: Syvlain Henry <sylvain@haskus.fr>
In accordance with GHC Proposal #581 "Namespace-specified imports",
section 2.3 "Deprecate use of pattern in import/export lists", the
`pattern` namespace specifier is now deprecated.

Test cases: T25900 T25900_noext
Previously the linker's "proddable blocks" check relied on a simple
linked list of spans. This resulted in extremely poor complexity while
linking objects with lots of small sections (e.g. objects built with
split sections).

Rework the mechanism to instead use a simple interval set implemented
via binary search.

Fixes #26009.
The `LOAD_LIBRARY_SEARCH_USER_DIRS` and
`LOAD_LIBRARY_SEARCH_DEFAULT_DIRS` were introduced in Windows Vista and
have been available every since. As we no longer support Windows XP we
can drop this check.

Addresses #26009.
This is a useful helper which can be used for non-strings as well.
Previously the happy path of PEi386 used `break` in a double-`for` loop
resulting in redundant calls to `LoadLibraryEx`.

Fixes #26052.
Previously every DLL-imported symbol would result in a call to
`LoadLibraryEx`. This ended up constituting over 40% of the runtime of
`ghc --interactive -e 42` on Windows. Avoid this by maintaining a
hash-set of loaded DLL names, skipping the call if we have already
loaded the requested DLL.

Addresses #26009.
hsyl20 and others added 14 commits May 27, 2025 08:01
Use --target=foo to select a target installed in $topdir/targets/foo/
It requires zig 0.14 at least to compile xxhash.h which uses evex512.

Wrappers are needed because zig needs its first argument (`cc` or `c++`)
always. Trying to pass it as CFLAGS fails with: ghc-toolchain, GHC's
response files used to call the linker (this arg isn't supported by zig in the
response file), configure scripts that call the C compiler without
passing the specified CFLAGS. Use the wrappers like this:

  CC=/path/to/zig-cc  CXX=/path/to/zig-c++ make
We need to use wrappers for, which is not pretty, as neither ghc nor cabal can deal with `zig ...`
E.g.

make _build/stage0/bin/cabal

make test CABAL=$PWD/_build/stage0/bin/cabal

This must not be automated, the build tools should be distinctly separate from what we are building, no intertwining.
@angerman angerman force-pushed the wip/make-build-pre-zig branch from 15d5708 to 4ef9539 Compare May 27, 2025 11:24
angerman and others added 8 commits May 28, 2025 09:55
Replaced separate logging for stderr with `tee` command to capture both stdout and stderr in the same log file for better clarity and debugging.
(cherry picked from commit ffa530c)
(cherry picked from commit b1ca8d4)
@angerman angerman force-pushed the wip/make-build-pre-zig branch 4 times, most recently from 201b6dc to f7375b8 Compare June 14, 2025 00:36
@angerman angerman force-pushed the wip/make-build-pre-zig branch from f7375b8 to 2345fd5 Compare June 14, 2025 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants