Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
867c2675
by Cheng Shao at 2025-09-20T06:49:28-04:00
6 changed files:
- + testsuite/tests/ghci-wasm/Makefile
- + testsuite/tests/ghci-wasm/T26430.hs
- + testsuite/tests/ghci-wasm/T26430A.c
- + testsuite/tests/ghci-wasm/T26430B.c
- + testsuite/tests/ghci-wasm/all.T
- utils/jsffi/dyld.mjs
Changes:
| 1 | +TOP=../..
|
|
| 2 | +include $(TOP)/mk/boilerplate.mk
|
|
| 3 | +include $(TOP)/mk/test.mk
|
|
| 4 | + |
|
| 5 | +T26430_setup :
|
|
| 6 | + '$(TEST_HC)' $(TEST_HC_OPTS) $(ghciWayFlags) -shared T26430A.c -o libT26430A.so
|
|
| 7 | + '$(TEST_HC)' $(TEST_HC_OPTS) $(ghciWayFlags) -shared -L. -lT26430A T26430B.c -o libT26430B.so |
| 1 | +foreign import ccall unsafe "baz" main :: IO () |
| 1 | +void foo(void);
|
|
| 2 | + |
|
| 3 | +void bar(void (*)(void));
|
|
| 4 | + |
|
| 5 | +__attribute__((export_name("baz"))) void baz(void) { bar(foo); } |
| 1 | +__attribute__((export_name("foo"))) void foo(void) {}
|
|
| 2 | + |
|
| 3 | +__attribute__((export_name("bar"))) void bar(void (*f)(void)) { f(); } |
| 1 | +setTestOpts([
|
|
| 2 | + unless(arch('wasm32'), skip),
|
|
| 3 | + only_ways(['ghci', 'ghci-opt']),
|
|
| 4 | + extra_ways(['ghci', 'ghci-opt'])
|
|
| 5 | +])
|
|
| 6 | + |
|
| 7 | +test('T26430', [
|
|
| 8 | + extra_files(['T26430A.c', 'T26430B.c']),
|
|
| 9 | + pre_cmd('$MAKE -s --no-print-directory T26430_setup ghciWayFlags=' + config.ghci_way_flags),
|
|
| 10 | + extra_hc_opts('-L. -lT26430B')]
|
|
| 11 | +, compile_and_run, ['']
|
|
| 12 | +) |
| ... | ... | @@ -1013,10 +1013,13 @@ class DyLD { |
| 1013 | 1013 | // anything, if it's required later a GOT.func entry will be
|
| 1014 | 1014 | // created on demand.
|
| 1015 | 1015 | if (this.#gotFunc[k]) {
|
| 1016 | - // ghc-prim/ghc-internal may export functions imported by
|
|
| 1017 | - // rts
|
|
| 1018 | - console.assert(this.#gotFunc[k].value === DyLD.#poison);
|
|
| 1019 | - this.#table.set(this.#gotFunc[k].value, v);
|
|
| 1016 | + const got = this.#gotFunc[k];
|
|
| 1017 | + if (got.value === DyLD.#poison) {
|
|
| 1018 | + const idx = this.#table.grow(1, v);
|
|
| 1019 | + got.value = idx;
|
|
| 1020 | + } else {
|
|
| 1021 | + this.#table.set(got.value, v);
|
|
| 1022 | + }
|
|
| 1020 | 1023 | }
|
| 1021 | 1024 | continue;
|
| 1022 | 1025 | }
|