<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style='--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;'>
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>

<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>


<style>img {
max-width: 100%; height: auto;
}
body {
font-size: 0.875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px;
}
body {
font-family: var(--default-regular-font, "GitLab Sans"),-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px; font-family: var(--default-regular-font, "GitLab Sans"),-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>
<div class="content">

<h3 style="margin-top: 20px; margin-bottom: 10px;">
Ben Gamari pushed to branch wip/T23415-9.8 at <a href="https://gitlab.haskell.org/ghc/ghc">Glasgow Haskell Compiler / GHC</a>
</h3>
<h4 style="margin-top: 10px; margin-bottom: 10px;">
Commits:
</h4>
<ul>
<li>
<strong style="font-weight: bold;"><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/2f8b55423119c6f0b5811c5ade3471c4e4142e8a">2f8b5542</a></strong>
<div>
<span> by Rodrigo Mesquita </span> <i> at 2024-06-08T12:05:28-04:00 </i>
</div>
<pre class="commit-message" style='white-space: pre-wrap; display: block; font-size: 14px; color: #333238; position: relative; font-family: var(--default-mono-font, "GitLab Mono"),"JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; border-radius: 2px; margin: 0; padding: 8px 12px; border: 1px solid #dcdcde;'>rts: free error message before returning

Fixes a memory leak in rts/linker/PEi386.c

(cherry picked from commit dd530bb7e22e953e4cec64a5fd6c39fddc152c6f)
</pre>
</li>
<li>
<strong style="font-weight: bold;"><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/fbec131eeb59655fe5cb793f28df32fccd46dcd8">fbec131e</a></strong>
<div>
<span> by Alexis King </span> <i> at 2024-06-08T12:05:28-04:00 </i>
</div>
<pre class="commit-message" style='white-space: pre-wrap; display: block; font-size: 14px; color: #333238; position: relative; font-family: var(--default-mono-font, "GitLab Mono"),"JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; border-radius: 2px; margin: 0; padding: 8px 12px; border: 1px solid #dcdcde;'>linker: Avoid linear search when looking up Haskell symbols via dlsym

See the primary Note [Looking up symbols in the relevant objects] for a
more in-depth explanation.

When dynamically loading a Haskell symbol (typical when running a splice or
GHCi expression), before this commit we would search for the symbol in
all dynamic libraries that were loaded. However, this could be very
inefficient when too many packages are loaded (which can happen if there are
many package dependencies) because the time to lookup the would be
linear in the number of packages loaded.

This commit drastically improves symbol loading performance by
introducing a mapping from units to the handles of corresponding loaded
dlls. These handles are returned by dlopen when we load a dll, and can
then be used to look up in a specific dynamic library.

Looking up a given Name is now much more precise because we can get
lookup its unit in the mapping and lookup the symbol solely in the
handles of the dynamic libraries loaded for that unit.

In one measurement, the wait time before the expression was executed
went from +-38 seconds down to +-2s.

This commit also includes Note [Symbols may not be found in pkgs_loaded],
explaining the fallback to the old behaviour in case no dll can be found
in the unit mapping for a given Name.

Fixes #23415

Co-authored-by: Rodrigo Mesquita (@alt-romes)
(cherry picked from commit e008a19a7f9e8f22aada0b4e1049744f49d39aad)
</pre>
</li>
<li>
<strong style="font-weight: bold;"><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/e60e15ec56eb7f9969c84eec1eb52abb4c7f9146">e60e15ec</a></strong>
<div>
<span> by Rodrigo Mesquita </span> <i> at 2024-06-08T12:05:28-04:00 </i>
</div>
<pre class="commit-message" style='white-space: pre-wrap; display: block; font-size: 14px; color: #333238; position: relative; font-family: var(--default-mono-font, "GitLab Mono"),"JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; border-radius: 2px; margin: 0; padding: 8px 12px; border: 1px solid #dcdcde;'>rts: Make addDLL a wrapper around loadNativeObj

Rewrite the implementation of `addDLL` as a wrapper around the more
principled `loadNativeObj` rts linker function. The latter should be
preferred while the former is preserved for backwards compatibility.

`loadNativeObj` was previously only available on ELF platforms, so this
commit further refactors the rts linker to transform loadNativeObj_ELF
into loadNativeObj_POSIX, which is available in ELF and MachO platforms.

The refactor made it possible to remove the `dl_mutex` mutex in favour
of always using `linker_mutex` (rather than a combination of both).

Lastly, we implement `loadNativeObj` for Windows too.

(cherry picked from commit dcfaa190e1e1182a2efe4e2f601affbb832a49bb)
</pre>
</li>
<li>
<strong style="font-weight: bold;"><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/3f91d9cce4ceffb0f07802184560d8ecf0d1ccde">3f91d9cc</a></strong>
<div>
<span> by Rodrigo Mesquita </span> <i> at 2024-06-08T12:05:28-04:00 </i>
</div>
<pre class="commit-message" style='white-space: pre-wrap; display: block; font-size: 14px; color: #333238; position: relative; font-family: var(--default-mono-font, "GitLab Mono"),"JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; border-radius: 2px; margin: 0; padding: 8px 12px; border: 1px solid #dcdcde;'>Use symbol cache in internal interpreter too

This commit makes the symbol cache that was used by the external
interpreter available for the internal interpreter too.

This follows from the analysis in #23415 that suggests the internal
interpreter could benefit from this cache too, and that there is no good
reason not to have the cache for it too. It also makes it a bit more
uniform to have the symbol cache range over both the internal and
external interpreter.

This commit also refactors the cache into a function which is used by
both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the
caching logic to `lookupSymbolInDLL` too.

(cherry picked from commit 12931698261a1cee6a00b731d143270cd60e5f2d)
</pre>
</li>
<li>
<strong style="font-weight: bold;"><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/6c8a69303f4129d405872cce8acb77b0709ee58c">6c8a6930</a></strong>
<div>
<span> by Ben Gamari </span> <i> at 2024-06-08T12:05:28-04:00 </i>
</div>
<pre class="commit-message" style='white-space: pre-wrap; display: block; font-size: 14px; color: #333238; position: relative; font-family: var(--default-mono-font, "GitLab Mono"),"JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; border-radius: 2px; margin: 0; padding: 8px 12px; border: 1px solid #dcdcde;'>testsuite: Add test for lookupSymbolInNativeObj

(cherry picked from commit dccd3ea159b03cc1972cf47ee3cf8bda73ec0c5a)
</pre>
</li>
</ul>
<h4 style="margin-top: 10px; margin-bottom: 10px;">
30 changed files:
</h4>
<ul>
<li class="file-stats">
<a href="#d0d96a6d03668aeab20ebe05e2c4ccb798c7e64c">
compiler/GHC.hs
</a>
</li>
<li class="file-stats">
<a href="#11e6f6a348be9920cecad0893a25350137524b4f">
compiler/GHC/ByteCode/Linker.hs
</a>
</li>
<li class="file-stats">
<a href="#9a679a2680ef6061397f1987091ea9f96ffe095d">
compiler/GHC/Driver/Main.hs
</a>
</li>
<li class="file-stats">
<a href="#c4236c3de9fb0253d53aab2fe6dbdd3a2aa8b8bc">
compiler/GHC/Driver/Plugins.hs
</a>
</li>
<li class="file-stats">
<a href="#5aa3321b0f5c08d7ebfa1a4a3340d4451258988b">
compiler/GHC/Linker/Loader.hs
</a>
</li>
<li class="file-stats">
<a href="#195d402e82767aba8bfcc1bc191497dc297d3962">
compiler/GHC/Linker/MacOS.hs
</a>
</li>
<li class="file-stats">
<a href="#d4c7e80d0458dd6a2a45a2f3c1ca5826d3fa1cba">
compiler/GHC/Linker/Types.hs
</a>
</li>
<li class="file-stats">
<a href="#efe7444c09eed0fdaa83e6904e6328fb435620bf">
compiler/GHC/Runtime/Interpreter.hs
</a>
</li>
<li class="file-stats">
<a href="#6522eb478fcef05ded3ea7e20ca577c6d85a5fd8">
compiler/GHC/Runtime/Interpreter/JS.hs
</a>
</li>
<li class="file-stats">
<a href="#6b29c1575b27588edcc0f976faedbffeb8343176">
compiler/GHC/Runtime/Interpreter/Types.hs
</a>
</li>
<li class="file-stats">
<a href="#ed5b77135b8d6077d6f77541d166d7b8fe93f9de">
libraries/ghci/GHCi/Message.hs
</a>
</li>
<li class="file-stats">
<a href="#4ba2f0376a3857da0c781f2a39ae648ec42663f8">
libraries/ghci/GHCi/ObjLink.hs
</a>
</li>
<li class="file-stats">
<a href="#fdd34ceb84d7b95dccbd9172ce507eaea9b5abd4">
libraries/ghci/GHCi/Run.hs
</a>
</li>
<li class="file-stats">
<a href="#044fe9284335a9bfd17546e06c2e5c40a680dd3d">
rts/Linker.c
</a>
</li>
<li class="file-stats">
<a href="#687f0b17315e54a1692de64626391e572ca298e9">
rts/LinkerInternals.h
</a>
</li>
<li class="file-stats">
<a href="#16c842a51a135c8ef2c7c7f94336544868348a3c">
rts/RtsSymbols.c
</a>
</li>
<li class="file-stats">
<a href="#9704e324b87028becd10cc4a86f77fca392da81e">
rts/include/rts/Linker.h
</a>
</li>
<li class="file-stats">
<a href="#b7ec52d5e302083ed03503182f1293694dda24f3">
rts/linker/Elf.c
</a>
</li>
<li class="file-stats">
<a href="#427e40b26b348edf7bc8d906629d672f3c26bdec">
rts/linker/Elf.h
</a>
</li>
<li class="file-stats">
<a href="#f85f6430a2594d4b119a087a61cfc7c6b89181f4">
<span class="new-file">
+
rts/linker/LoadNativeObjPosix.c
</span>
</a>
</li>
<li class="file-stats">
<a href="#a9c6639baaa61abcc6849030ba8cf3ebe7c44d45">
<span class="new-file">
+
rts/linker/LoadNativeObjPosix.h
</span>
</a>
</li>
<li class="file-stats">
<a href="#9670354b74fe55079feca82e1510129734b46f4f">
rts/linker/PEi386.c
</a>
</li>
<li class="file-stats">
<a href="#d373a5481c2da8b16d7b59009c7565a297cc7a36">
rts/linker/PEi386.h
</a>
</li>
<li class="file-stats">
<a href="#e432c7b248b68100c3cc37db36ee80d975efd697">
rts/rts.cabal.in
</a>
</li>
<li class="file-stats">
<a href="#e02ef59033a0dfda9a510b9f4bc3005fdfd0477d">
testsuite/tests/ghci/linking/dyn/T3372.hs
</a>
</li>
<li class="file-stats">
<a href="#da57e082759f3298bec45394ade7d28acc5bef78">
testsuite/tests/rts/linker/T2615.hs
</a>
</li>
<li class="file-stats">
<a href="#9a902b464ab5a23fc03b6cf08241fdffb02914ac">
<span class="new-file">
+
testsuite/tests/rts/linker/lookupSymbolInNativeObj/Makefile
</span>
</a>
</li>
<li class="file-stats">
<a href="#08fdef8bf7bfd6bb3d43c86fbb53a9427544913c">
<span class="new-file">
+
testsuite/tests/rts/linker/lookupSymbolInNativeObj/all.T
</span>
</a>
</li>
<li class="file-stats">
<a href="#3fdf155bc0168650275f86100ec375d6271a1443">
<span class="new-file">
+
testsuite/tests/rts/linker/lookupSymbolInNativeObj/lookupSymbolInNativeObj1.c
</span>
</a>
</li>
<li class="file-stats">
<a href="#ff09a98f3d23d9581484ac86dd2d94be2e01d1ef">
<span class="new-file">
+
testsuite/tests/rts/linker/lookupSymbolInNativeObj/lookupSymbolInNativeObj1.stdout
</span>
</a>
</li>
</ul>
<h5 style="margin-top: 10px; margin-bottom: 10px; font-size: 0.875rem;">
The diff was not included because it is too large.
</h5>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #737278;">

<br>
<a href="https://gitlab.haskell.org/ghc/ghc/-/compare/d44a18fbb50ff568b89f26fd9224ddc55bb43e16...6c8a69303f4129d405872cce8acb77b0709ee58c">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.haskell.org">gitlab.haskell.org</a>. <a href="https://gitlab.haskell.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.haskell.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>



</p>
</div>
</body>
</html>